Banding effect on graphics

Blitz3D Forums/Blitz3D Beginners Area/Banding effect on graphics

Drekinn(Posted 2005) [#1]
Hi all, just a couple of graphics questions:

1) Is it necessary to use FreeImage to free all the images when changing screen modes with the Graphics command? I'm assuming not.

2) In windowed mode my graphics look fine, but in full-screen mode some of my graphics with gradients appear as 'bands' of colour instead of a seamless blend. I use Illustrator to create my graphics, then import to Photoshop for saving off in .png. The same 'banding' effect happens with both .bmp and .jpg.
Does anyone have any solutions?


Erroneouss(Posted 2005) [#2]
1) No.
2) I hate that effect. I am also wondering this...


sswift(Posted 2005) [#3]
Drek:

Are you running in a 16 bit color mode when running full screen?

If your desktop is 24bit, then windowed 3D will run at 24bit.

16 bit can be dithered to reduce banding, I think the command is "Dither True", but it should be on by default.

I have not seen any banding effects in Blitz other than those caused by 16 bit color. 16bit color just doesn't have enough colors to represent most smooth gradients smoothly.

Heck, even 24bit color has its limitations. I can see banding there too sometimes, but I can see that in photoshop as well, so it's not a problem with Blitz.


GfK(Posted 2005) [#4]
SSwift is right. You'll get the 'banding' effect in 16-bit colour.

Even if you specify a colour depth, if you're running in windowed mode on a 16-bit desktop, then your game window will also be 16-bit.

Likewise, don't assume that if you don't specify a colour depth, then your program will magically 'know' which one you wanted. Always specify colour depth, always run your desktop in 32-bit colour, and you're sorted.


big10p(Posted 2005) [#5]
Heck, even 24bit color has its limitations. I can see banding there too sometimes


Really!? I thought the 16million+ colours of 24-bit is more colours that the human eye can perceive. That's what I read somewhere, anyways. :P


sswift(Posted 2005) [#6]
big10p:

Yes, well they say that, but it's bs. I can percieve it quite easily. Download this and take a look at the sky. You may have to magnify it in photoshop depending on how good your monitor is and how well it's calibrated.

http://www.nikkopay.com/swift/tanks.zip

Of course in this example it will be very hard to see, because I specifically tweaked the thing carefully in photoshop with the effects gradient setting for the layer so you can see the gradient change in realtime. But I can percieve it even in this image if I look closely enough. It was much easier to see though when I was tweaking the gradient.

I don't know if you saw that pic I made around xmas of santa being sucked into the jet engine, but the problem was there too... I had major problems getting the sky to look decent because each time I'd addn an effect it would make the banding problem worse, and blurring the sky with gaussian blur would not fix the banding, so I had to keep going back to older cleaner versions and try again from there.

It's just not true at all that you can't perceive the changes. There's only 256 different shades of blue for example in 24 bit color. It may not be possible to percieve the changes between those 256 shades alone, but when you start having gradients that are desaturated so you're going between blur 128 and blue 256, and green 64 and green 96 ... Then you start losing the smoothness.

Try painting the top half of the screen one shade of blue, and then change the shade by one and paint the bottom half with that different shade. If you can tell they're different shades, and see the line between them, then you can indeed percieve the difference. :-)

Og course part of this depends on how well your monitor is calibrated. Mine is set up to have as much contrast as possible and be as beight as possible without pure black illuminating the phosphors. Most people have their monitors all screwed up and/or dim, which reduces the contrast between colors, and reduces the change from one to the next.


sswift(Posted 2005) [#7]
Well I just did a test with making one half the screen one shade off, and I can't see a difference there, but I know for certain that smooth gradients are affected. I think they just forgot to take something into account.

I think what the problem might be is that when you have a graident and blue changes at a different rate than green or red in the gradient, you end up with bands that do not have the same hue as neighboring bands. It is that change in hue that you can detect.


sswift(Posted 2005) [#8]
Another correction... I just did a test in photoshop. When I make a gradient from white to black, I cannot see the bands in the topmost and bottommost sections, but in the center I can see tons of banding.

I do have adobe's gamma tool installed... It corrects the color in windows. It is possible that this itself instroduces banding in the color, but I'm not sure. I'll have to do some research. I would think it would not, because it's supposed to be something professionals use.


BlackJumper(Posted 2005) [#9]
The human eye responds differently to different wavelengths of light (most sensitive to yellow + green if I remember) so the actual shades that Sswift chose to test with could make a difference. Banding will appear in some parts of the blue spectrum more noticably than in others.

As alluded to by Sean, the colour gamut of the monitor will also have a bearing here - the phosphors in a CRT will have a differnet response curve to the light source in a TFT. When asked to display a marginally different shade of blue there might not be a linear jump in hue at all RGB triplets, leading to a perceivable difference (i.e. banding)


big10p(Posted 2005) [#10]
OMG, you're right sswift. I never noticed this before. I did a black to white gradient and the banding was TERRIBLE. Thinking about it, I shouldn't be surprised, really: black to white is a 'worse case' as the 2 colours are as far apart from each other as is possible, yet there's only 256 steps to interpolate between the two.

BlackJumper, I quess the quality of the monitor must have an effect, also. I wonder if digital monitors are worse than analogue?

P.S. sswift, your tank game is coming along nicely but how do you fire? Or haven't you done that yet?


jfk EO-11110(Posted 2005) [#11]
>>I did a black to white gradient and the banding was TERRIBLE.<<

Of course it is, the reason why is, although you have 24 bit (16 millions of colours), you still only have 256 true greyscales.

I doubt that any average human eye would recognize the diffrence of eg. 24 Bit and 48 Bit of a picture without huge gradients. I'd rather like to know if sswift also has some problems with krypton or something ;)


big10p(Posted 2005) [#12]
Of course it is, the reason why is, although you have 24 bit (16 millions of colours), you still only have 256 true greyscales.


Isn't that what I said?


jfk EO-11110(Posted 2005) [#13]
oops, yes :°)


Paolo(Posted 2005) [#14]
Ok, small question:

when I run in 16bit I can see bands in the gradients, that's ok for the reasons you said above...

... but if I load a texture with the flag 512 then it shows perfectly and I'm still running in 16bit, so
how is it possible that?, I'm still running in 16 but now the proper colors ARE found to show the texture correctly ...


NewtSoup(Posted 2005) [#15]
heres a more fun example

create a 1024x768 texture with exactly one half black and one half white. Use blitz to render the texture to the screen 2d or 3d it only needs to fill the screen.

See what I mean?.. You see banding again dont you?

This is called mach banding.. and its got nothing to do with how many colours the eye can percieve or the quality of your hardware.. its an optical illusion and theres nothing you can do about it.. well there is.. CGI experts use all sorts of trickery to lessen the effect.

Theres another effect which is (erroneously?) refered to as mach banding and thats when you have a single coloured mesh rendered to the screen with ambient lighting only and yet you still see colour gradients over polygon boundaries. gouraud/phong shading helps smooth this out but of course if you wanted to be able to see the poly edges (flat shaded model) then this isnt much help :/

see
Computer Graphics practices and principles
Foley at al
Addison and Wesley publishers

for a good explanation of all this and much much more.. superb book.. its the industry standard text on computer graphics.. Costs $100 but is money well spend in my opinion (Ive bought 2 now.. 1st and second ed)


sswift(Posted 2005) [#16]
"but if I load a texture with the flag 512 then it shows perfectly and I'm still running in 16bit, so
how is it possible that?"

Textures are stored in 24bit format, and all 3D output is dithered. Dithering hides the banding, though only if you don't know to look for it. :-) If you look closely you will be able to see dots moving about rapidly as the dither pattern changes constantly to make it less obvious.

If you set Dither False in your program, then assuming dithering is not being forced on by the driver, you should be able to see the banding again. I did that in my tank game because I can't stand dithering.

2D output is not dithered, hence the bands being visible.


As for Luke's mach banding thing, I don't know anything about that, but I think I've heard the term before. What you're seeing is probably not mach banding though.


BlackJumper(Posted 2005) [#17]
Yeah... try this







[edit]
P.S. apologies to anyone who ends up with scratch marks all over their monitor due to cat attacks on the 'moving' image above ;-)
[/edit]


NewtSoup(Posted 2005) [#18]
Now that's impressively freaky :D love it!!!


Drekinn(Posted 2005) [#19]
sswift,

Are you running in a 16 bit color mode when running full screen?


I had left the Graphics bitdepth parameter as '0' as I assumed both the window's and full screen's bitdepth would be the same. I was wrong. I did some tests and it seems Blitz was dropping my full screen bitdepth to 16 bit, even though windowed mode was running in 32 bit. In forced 32 bit mode my gradients display perfectly. :)
Thanks for the help! :)

GfK,

Likewise, don't assume that if you don't specify a colour depth, then your program will magically 'know' which one you wanted. Always specify colour depth, always run your desktop in 32-bit colour, and you're sorted.


Thanks for the tip GfK. I'll be sure to implement highest bitdepth available checks when changing graphics modes from now on. ;)


sswift(Posted 2005) [#20]
Someone once told me that 0 was supposed to select the best graphics mode, but obviously that's not true. In fact, on my card I think it just complained it couldn't set any graphics mode at all. So don't use 0, check for available modes and select manually! :-)


NewtSoup(Posted 2005) [#21]
Drekinn and sswift, youre not using voodo banshee based cards are you?

those cards couldnt do more than 16bit colour in fullscreen 3d. or rather any 3dfx card could not do more than 16 bit colour in fullscreen 3d and often could not do 3d in windowed mode at all (so if you have one of these cards and are getting 3d in windowed mode with 32 bit colour its likely you are not using hardware acceleration any more)


Oso(Posted 2005) [#22]
There is also the entertaining effect sometimes obtained when drawing sets of close, parallel curves, say with an algebraic 2D function. Often shapes appear by what I assume is a sort of Moire interference with the grid of pixels, usually taking the form of ovals, hyperbolas and Napoleon hat cubics (just why these forms I haven't worked out yet).
When a zoomed plot is done they disappear. In the case of my code they're an interesting bonus.


NewtSoup(Posted 2005) [#23]
Yep thats exactly what you are seeing, interference between arrays of close dots with small changes in seperation. It's an optical illusion and thats why they dissapear as you "zoom in" because you are effectively increasing the dot seperation. :)


Drekinn(Posted 2005) [#24]
Luke,
No, I'm using an NVIDIA GeForce2 graphics card. Windowed 3D looks fine.


sswift(Posted 2005) [#25]
Luke,
I am your father's, mother's, brother's, second cousin!