Use gl_FrontFacing to determine mirrored surface side, enable clipping (Refs #190)

This commit is contained in:
saschawillems 2016-07-06 21:13:24 +02:00
parent becdc7c9dc
commit 876f5714eb
7 changed files with 18 additions and 23 deletions

View file

@ -8,18 +8,17 @@ layout (binding = 2) uniform sampler2D samplerColorMap;
layout (location = 0) in vec2 inUV;
layout (location = 1) in vec4 inPos;
layout (location = 2) in vec3 inNormal;
layout (location = 0) out vec4 outFragColor;
void main()
{
vec4 tmp = vec4(1.0 / inPos.w);
vec4 projCoord = inPos * tmp;
vec4 projCoord = inPos * tmp;
// Scale and bias
projCoord += vec4(1.0);
projCoord *= vec4(0.5);
projCoord += vec4(1.0);
projCoord *= vec4(0.5);
// Slow single pass blur
// For demonstration purposes only
@ -28,7 +27,9 @@ void main()
vec4 color = texture(samplerColorMap, inUV);
outFragColor = color * 0.25;
if (inNormal.z > 0) {
if (gl_FrontFacing)
{
// Only render mirrored scene on front facing (upper) side of mirror surface
vec4 reflection = vec4(0.0);
for (int x = -3; x <= 3; x++)
{
@ -38,5 +39,5 @@ void main()
}
}
outFragColor += reflection * 1.5 * (color.r);
}
};
}