r/GraphicsProgramming • • Oct 09 '21

Question Why does this light spread out so strange?

The point in the middle is as I'd expect but as it spreads out you see these chunks of radius that aren't decreasing in modularity by the pixel as I'd expect them to, rather by quite a few chunks of pixel. I've noticed this in 3D scenes too... why is that? How do I fix it?

0 Upvotes

6 comments sorted by

8

u/msqrt Oct 10 '21

You mean the banding? There's only so many color values a monitor can display, and the chunks you're seeing are the distinct pixel values (one of the chunks is (9,9,9), the next is (10,10,10) and so on). The easiest way to deal with this is to add a tiny bit of noise to your result. This essentially dithers the end result so that you can't see the specific bands, but the noise should be perceptually unnoticeable. Something like vec3(rnd()/256.) should be fine (for a random function rnd that returns a random value between 0 and 1, you can find a bunch of random noise functions by googling or on shadertoy.)

3

u/TheNextJohnCarmack Oct 10 '21

Banding. That’s what it’s called. Also thanks. Will try.

4

u/jntesteves Oct 10 '21 edited Oct 10 '21

I really recommend these two resources on color banding and dithering:

YouTube video from GDC Europe 2016: Low Complexity, High Fidelity: The Rendering of INSIDE

Slide deck from Lottes at GDC 2016: GdcVdrLottes.pdf