by the Codermind team. |
Question
«I've rendered a polygon with a smooth color gradient on it and I can very perceptibly see some banding on the surface. What did I do wrong ? Shouldn't 256 values be well enough for a smooth gradient ? Why haven't I seen that already in more games ?»
Answer
Not only is 256 values often not enough (and it's even worse on LCD displays as they are limited to 5/6 bits of actual precision) but there is a side effect of the eye that catches fast transitions more easily than slow transition : it can see the difference between two near color if they are next to each other because there is a fast moving gradient between them. But it cannot differentiate even somehow wildly different values if they are far away from each other.
One of the frequent solution to the banding effect, is to render with dithering (or noise), so you may need slightly more than 8 bits of precision when you render and when you write to the frame buffer you dither explicitly (that's what Photoshop will do automatically if you ask for a black to white gradient). Or you make sure that none of your scene consists of a single untextured gradient. If there is a texture with high frequency detail the result will be too noisy for you to capture those small transitions. Which is probably the reason you never saw that in a game.




