mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-03 23:33:23 +08:00
Merge pull request #202 from NicholasBlaskey/master
Renamed sample -> samplePos because sample is a keyword in future glsl versions
This commit is contained in:
@@ -34,11 +34,11 @@ void main()
|
|||||||
for(int i = 0; i < kernelSize; ++i)
|
for(int i = 0; i < kernelSize; ++i)
|
||||||
{
|
{
|
||||||
// get sample position
|
// get sample position
|
||||||
vec3 sample = TBN * samples[i]; // from tangent to view-space
|
vec3 samplePos = TBN * samples[i]; // from tangent to view-space
|
||||||
sample = fragPos + sample * radius;
|
samplePos = fragPos + samplePos * radius;
|
||||||
|
|
||||||
// project sample position (to sample texture) (to get position on screen/texture)
|
// project sample position (to sample texture) (to get position on screen/texture)
|
||||||
vec4 offset = vec4(sample, 1.0);
|
vec4 offset = vec4(samplePos, 1.0);
|
||||||
offset = projection * offset; // from view to clip-space
|
offset = projection * offset; // from view to clip-space
|
||||||
offset.xyz /= offset.w; // perspective divide
|
offset.xyz /= offset.w; // perspective divide
|
||||||
offset.xyz = offset.xyz * 0.5 + 0.5; // transform to range 0.0 - 1.0
|
offset.xyz = offset.xyz * 0.5 + 0.5; // transform to range 0.0 - 1.0
|
||||||
@@ -48,7 +48,7 @@ void main()
|
|||||||
|
|
||||||
// range check & accumulate
|
// range check & accumulate
|
||||||
float rangeCheck = smoothstep(0.0, 1.0, radius / abs(fragPos.z - sampleDepth));
|
float rangeCheck = smoothstep(0.0, 1.0, radius / abs(fragPos.z - sampleDepth));
|
||||||
occlusion += (sampleDepth >= sample.z + bias ? 1.0 : 0.0) * rangeCheck;
|
occlusion += (sampleDepth >= samplePos.z + bias ? 1.0 : 0.0) * rangeCheck;
|
||||||
}
|
}
|
||||||
occlusion = 1.0 - (occlusion / kernelSize);
|
occlusion = 1.0 - (occlusion / kernelSize);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user