Jump to content
  • Advertisement
Sign in to follow this  

Banding using GGX specular

This topic is 749 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



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



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

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.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!