Update ssao.frag
samplePos.z bias can remove banding
This commit is contained in:
parent
144b58a253
commit
364c4695a9
1 changed files with 4 additions and 2 deletions
|
|
@ -40,6 +40,8 @@ void main()
|
|||
|
||||
// Calculate occlusion value
|
||||
float occlusion = 0.0f;
|
||||
// remove banding
|
||||
float bais = 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 + bais ? 1.0f : 0.0f) * rangeCheck;
|
||||
#else
|
||||
occlusion += (sampleDepth >= samplePos.z ? 1.0f : 0.0f);
|
||||
occlusion += (sampleDepth >= samplePos.z + bais ? 1.0f : 0.0f);
|
||||
#endif
|
||||
}
|
||||
occlusion = 1.0 - (occlusion / float(SSAO_KERNEL_SIZE));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue