]> git.tdb.fi Git - libs/gl.git/commitdiff
Guard against sample points behind the camera in ambient occlusion
authorMikko Rasa <tdb@tdb.fi>
Wed, 3 Jul 2019 21:06:00 +0000 (00:06 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 3 Jul 2019 21:06:00 +0000 (00:06 +0300)
shaderlib/ambientocclusion.glsl

index a9873b1d1fe2a4778fed2cd6fe664e404ff13ea5..89d13357b67404dd5f06c180541d5723f372a34b 100644 (file)
@@ -18,6 +18,8 @@ uniform AmbientOcclusionParams
 #pragma MSP stage(fragment)
 vec3 project(vec3 position)
 {
+       if(position.z>=0.0)
+               return vec3(0.0, 0.0, -1.0);
        vec4 pp = projection_matrix*vec4(position, 1.0);
        return pp.xyz/pp.w;
 }