Banding artifacts in specular lighting

Started by
2 comments, last by phil_t 11 years, 1 month ago

When applying a specular shader function to my pixel shader, the highlights appear correct but I get some odd artifacts in the color. I'm using a basic Blinn-Phong specular implementation. The artifacts are some banding of darker colors in the bright white color of the highlight, kinda like a Moire pattern but not really. They become more apparent with higher specular powers.

This is done in a lighting pass for a deferred renderer by the way. It's drawing to a HDRblendable render target, don't know if that's relevant or not. I will post a screenshot later that shows the problem. For now, here is the specular shader code that I am using:

// Blinn D1 (Phong) specular distribution
float BlinnPhong(float3 normal, float3 view, float3 light, float specPower)
{
float3 halfVector = normalize(light + view);
return pow(saturate(dot(normal, halfVector)), specPower);
}

// How it's used in the main function

float specLight = specIntensity * BlinnPhong(normal, directionToCamera, lightDirection, specPower);

New game in progress: Project SeedWorld

My development blog: Electronic Meteor

Advertisement
How are you normals stored in your G-buffer?

My normals are stored in view space, with Z always 1 and X and Y converted from [-1, 1] to a [0, 1] range. Basically with the hue range very similar to this picture.

New game in progress: Project SeedWorld

My development blog: Electronic Meteor

Ok, well I was wondering what the precision was. If you're using only 8 bits per component, it's possible that the precision may not be sufficient to avoid banding in your scenario. If you switch to 16 bits per component, or use it in a forward rendering scenario, does the banding go away?

Another way to test if precision is the issue is to see if the banding matches up with changes in the value of the normal in your G-buffer.

This topic is closed to new replies.

Advertisement