- const char txtShader_DeferredShadowFragment[] = {
- "uniform sampler2D Texture0; // Color - Texture\n"
- "uniform sampler2D Texture1; // Camera - Depth - Texture\n"
- "uniform sampler2D Texture2; // Light - Depth - Texture\n\n"
- "void main() {\n"
- "vec2 texcoord = vec2(gl_TexCoord[0]);\n"
- "float fDepth = texture2D(Texture1, texcoord).r;\n\n"
- // Vertex - Position von Pixel berechnen
- "vec4 vVertex;\n"
- "vVertex.xy = texcoord.st * 2.0 - 1.0;\n"
- "vVertex.z = fDepth * 2.0 - 1.0;\n"
- "vVertex.w = 1.0;\n"
- "vVertex = gl_ProjectionMatrixInverse * vVertex;\n"
- "vVertex.xyz /= vVertex.w;\n\n"
- // gl_TextureMatrix[7] = bias * projection * modelview der lichtquelle
- "vec4 ShadowCoord = gl_TextureMatrix[7] * vVertex;
- "vec4 shadowCoordinateWdivide = ShadowCoord / ShadowCoord.w;\n"
- "shadowCoordinateWdivide.z += 0.000025;\n\n"
- "float distanceFromLight = texture2D(Texture2, shadowCoordinateWdivide.xy).z;\n\n"
- "float shadow = distanceFromLight < shadowCoordinateWdivide.z ? 0.25 : 1.0;\n\n"
- "gl_FragColor = shadow * texture2D(Texture0, texcoord);\n"
- "}\n"
- };