From ed5d922fd58c5cb1fc7502c93983d37fc871ddf5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 4 Jul 2019 00:06:00 +0300 Subject: [PATCH] Guard against sample points behind the camera in ambient occlusion --- shaderlib/ambientocclusion.glsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shaderlib/ambientocclusion.glsl b/shaderlib/ambientocclusion.glsl index a9873b1d..89d13357 100644 --- a/shaderlib/ambientocclusion.glsl +++ b/shaderlib/ambientocclusion.glsl @@ -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; } -- 2.45.2