Sign in to follow this  
CDProp

Banding using GGX specular

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:

 

ukADQtm.png

 

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

 

rCoKz22.png

 

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) {
		float3 c = shaderTexture.Load(texCoord, i).rgb;
		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:

8M7k5Bt.png

 

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