I’m trying to calculate the trans_render_to_view_of_shadowcam matrix myself (yes, I need it ), but anyhow my shadows aren’t really correct:
I’m calculating the shadow matrix via:
projMat = Mat4.convertMat(
CSYupRight,
cam2Lens.getCoordinateSystem()) * cam2Lens.getProjectionMat()
transformMat = TransformState.makeMat(
Mat4.convertMat(base.win.getGsg().getInternalCoordinateSystem(),
CSZupRight))
modelViewMat = transformMat.invertCompose(render.getTransform(cam2Node)).getMat()
shadowMat = modelViewMat * projMat;
and In the vertex shader I’m reconstructing the depth with:
vec4 coords = (biasMatrix * shadowMat) * vec4(surfacePos, 1.0);
vec3 projCoords = coords.xyz / coords.w ;
// I could use texture2DProj, too, but no difference
float otherZ = texture2D(shadowDepth, projCoords.xy / projCoords.z).x;
Anybody has Ideas what I’m doing wrong? It’s definetly the shadowMatrix, but I don’t know what’s exactly missing … I tried several different combinations but none worked …