Sign in to follow this  
Quat

ray tracer--pointlight

Recommended Posts

Quat    568
Hi, I have a simple scene with a plane and a point light above it (this is done with a ray tracer, not a polygon engine): Screenshot As you can see, for some reason there are circular "rings" created by the lighting instead of smooth transition. I have commented out all lighting code except for the diffuse term, so it is the diffuse term that is the problem. But I don't see why. For each intersection point P, I compute the light vector: L = Normalize( S - P ); // S is light position d = Max( DotProduct(L, N), 0 ); // N is normal at P (and is unit length) Then I just multiply d by the diffuse material term. Has anyone seen this before?

Share this post


Link to post
Share on other sites
PfhorSlayer    316
I have. It's due to the fact that you've only got 256 different grayscale values - you don't have enough color resolution to display it smoothly! If you render that scene to a higher quality image format (ie, not a JPG), and then check it in photoshop, you should see that each 'band' is a single grayscale value away from the one next to it!

Share this post


Link to post
Share on other sites
LeGreg    754
Quote:
Original post by Quat
Has anyone seen this before?


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 explicitely (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.

LeGreg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this