[Bug?] 3.2 Weird behaviour with Tint function :: "jumping colours"

Started by Yeppoh, Sat 25/12/2010 21:26:10

Previous topic - Next topic

Yeppoh

I was debugging my RGB to HSV function for compatibility issues between 3.1.2 and 3.2 version of the Tint function that was reverted back to its original behaviour from previous versions.
I discovered, when incrementing or decrementing one the rgb parameters, the colours "jump" instead of a smooth change of the hue.

The "bug" happens if either the blue value or the red value are less than the green value, and only if the green value is lesser than 255 : ( (g > b || g >r) && g<255 ).

For example :  Character.Tint(255,255,0,100,100) gives the genuine Yellow hue;
But when I decrement green by 1 :  Character.Tint(255, 254, 0, 100, 100) gives Red unexpectedly, as if I typed Character.Tint(255, 0, 0, 100, 100);
When decrementing green by 4 : Character.Tint(255, 251, 0, 100, 100) gives the expected really slightly redder Yellow;
After that, every 7-10 decrements, it either jumps between the pure Red or the expected redder hues of Yellow to Orange;
Except, after 128, it doesn't change from orange to red, it jumps between hues of Magenta and Red : Character.Tint(255, 1, 0, 100, 100) gives Magenta instead of a Red with 1 of green, as if I typed Character.Tint(255, 0, 255, 100, 100).

For me intuitively those jumps look like a bug, but maybe the Tint function works within a different pattern. But if that's so, can someone tell me how the parameters of the Tint function are processed?

Calin Leafshade

Yea, i flagged up this bug a while ago when i was making a tintmap module a couple of months ago.

I sent CJ the source and a description of the problem but he hasnt got back to me about it yet.

Probably just have to wait to see if the engine source gets released so it can be fixed.

Pumaman


Yeppoh

Only in D3D. It works fine in DX5.

Oh! I almost forgot. Happy New Year CJ!

Yeppoh

I discovered something new about this bug while trying to find a pattern to maybe correct it through script (actually looks possible).

I discovered that everytime the bug occurs, instead of visually returning the normal Tint( R, G, B, 100, 100 ), it returns as it was Tint( R, B, (R-G)+B, 100, 100 ).

The occurence of the bug looks random though, depending of what value are put into the function.

And I also discovered if I want to obtain what should, for ex., return Tint(255, 242, 0, 100, 100), I need to type Tint(254, 241, 0, 100, 100) and... tada! The former colour is there. It follows this rule : R - G = 255 - G , but sometimes this rule applies, sometimes not, and for now I need to manually find the right combination of values to find the right colour. There must be a pattern, but I didn't find it yet.

Hope this helps to find and correct the bug. I'll post more when I found something new.

Pumaman

Quote from: Nefasto on Sat 25/12/2010 21:26:10
For example :  Character.Tint(255,255,0,100,100) gives the genuine Yellow hue;
But when I decrement green by 1 :  Character.Tint(255, 254, 0, 100, 100) gives Red unexpectedly, as if I typed Character.Tint(255, 0, 0, 100, 100);
When decrementing green by 4 : Character.Tint(255, 251, 0, 100, 100) gives the expected really slightly redder Yellow;
After that, every 7-10 decrements, it either jumps between the pure Red or the expected redder hues of Yellow to Orange;
Except, after 128, it doesn't change from orange to red, it jumps between hues of Magenta and Red : Character.Tint(255, 1, 0, 100, 100) gives Magenta instead of a Red with 1 of green, as if I typed Character.Tint(255, 0, 255, 100, 100).

I just tried this and couldn't reproduce the problem.

I created a 32-bit game using Direct3D, and tried the following:

player.Tint(255,255,0,100,100); <-- tints yellow as expected

player.Tint(255,254,0,100,100); <-- also tints yellow, looks the same

player.Tint(255,0,0,100,100); <-- tints red as expected

player.Tint(255,1,0,100,100); <-- also tints red, looks the same

Calin, sorry I remember you did send me your game and I never got round to it, I'll see if I can see any problems there.

Calin Leafshade

It does seem to be specific to nVidia chips i think. Or ATI.. i cant remember which.

Yeppoh

I tried on my Intel chipset graphic card and the Nvidia one on another computer. The problem appears on both. When I enter, for ex., Tint(255,240,0) it returns  me (255,0,15).

However, from how the bug appears, it almost feels like a badly processed float is generating the issue.


Pumaman

I'm closing this thread -- please continue discussion in the other one that Calin just linked to

SMF spam blocked by CleanTalk