Merge pull request #635 from liuhongyi0101/patch-3

Update ssao.frag
This commit is contained in:
Sascha Willems 2019-12-05 20:18:06 +01:00 committed by GitHub
commit 991f7953c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,8 @@ void main()
// Calculate occlusion value
float occlusion = 0.0f;
// remove banding
const float bias = 0.01f;
for(int i = 0; i < SSAO_KERNEL_SIZE; i++)
{
vec3 samplePos = TBN * uboSSAOKernel.samples[i].xyz;
@ -57,9 +59,9 @@ void main()
#ifdef RANGE_CHECK
// Range check
float rangeCheck = smoothstep(0.0f, 1.0f, SSAO_RADIUS / abs(fragPos.z - sampleDepth));
occlusion += (sampleDepth >= samplePos.z ? 1.0f : 0.0f) * rangeCheck;
occlusion += (sampleDepth >= samplePos.z + bias ? 1.0f : 0.0f) * rangeCheck;
#else
occlusion += (sampleDepth >= samplePos.z ? 1.0f : 0.0f);
occlusion += (sampleDepth >= samplePos.z + bias ? 1.0f : 0.0f);
#endif
}
occlusion = 1.0 - (occlusion / float(SSAO_KERNEL_SIZE));