• Advertisement
Sign in to follow this  

Banding artifacts in specular lighting

This topic is 1785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
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. Edited by phil_t

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement