I have a problem with debugging my GLSL shadow mapping shader.
The problem is that the depth when read from the Shadow Map seems to be always 1.0.
But when I render the shadowmap, I get depths between 0.95 and 1.0. (normal depth image, rendering using smoothstep)
My Vertex Shader:
uniform highp mat4 ProjModelView;
uniform highp mat4 ShadowTexProj;
attribute mediump vec4 vertex;
varying highp vec4 shadowCoord;
void main() {
gl_Position = ProjModelView*vertex;
shadowCoord = ShadowTexProj*vertex;
}
Fragment Shader:
uniform sampler2D myTex;
uniform sampler2D depthTex;
varying highp vec4 shadowCoord;
void main() {
highp float comp = (shadowCoord.z / shadowCoord.w);
highp float depth = texture2D(depthTex, shadowCoord.xy).x;
float varDot = max(dot(normalize(normal), lightDir), 0.0);
gl_FragColor = depth == 1.0 ? vec4(1) : vec4(0);
}
Then I also wonder why the Bias matrix has look like:
QMatrix4x4(type:General
0.5 0 0 0
0 0.5 0 0
0 0 0.5 0
0.5 0.5 0.5 1
)
instead of
// matBias.translate(0.5,0.5,0.5);
// matBias.scale(0.5);
// =>
QMatrix4x4(type:Translation,Scale
0.5 0 0 0.5
0 0.5 0 0.5
0 0 0.5 0.5
0 0 0 1
)