# Banding using GGX specular

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

## Recommended Posts

Greetings,

I'm implementing specular using a GGX distribution and I'm noticing some unpleasant banding in the dark colors. Here is my HLSL code for the GGX distribution function:

float GGX(float NdotH, float a) {
float asq = a*a;
float denom = NdotH * NdotH * (asq - 1.0) + 1.0;
return asq / (PI * denom * denom);
}


Here is what it looks like if I shade a cube using only the GGX distribution function, with roughness = 0.25:

From what I can tell, the GGX function is totally continuous with respect to NdotH, with no stepping:

Granted, it's pretty sharp and so everything below NdotH = 0.8 is basically black. Not a lot of shades in 8-bit color down there, but so what? The only way I can imagine that it matters is if I'm doing gamma correction wrong. Here's my MSAA resolve shader to show that I'm doing the gamma correction:

float3 pixelShader(PSInput input) : SV_TARGET {
int3 texCoord = int3((int2) input.texCoord, 0);

float3 color = 0.0;
[unroll]
for (int i = 0 ; i < 4; ++i) {
color += c;
}

color *= 0.25;

return pow(color, 1.0 / 2.2);
}


What could be the problem? Am I using the wrong gamma function for my monitor, perhaps? Is there a better way to do gamma?

Edit: By the way, I'm seeing plenty of banding in my Fresnel, too, and it's not even that dark:

HLSL for the Fresnel:

float R0 = 0.05;
float RF = R0 + (1.0 - R0)*pow(1.0 - NdotV, 5.0);


Starting to think I'm just doing something really wrong with my gamma...

Edited by CDProp

##### Share on other sites

Oh! You're right. Even in the Fresnel screenshot, the bands are only 1/255 different. That's great to know, thanks! Thought I was going crazy for a sec.