Hi, i have a problem with concepts of perspective transformation.
There are a way to get back the z at view space after perspective transformation? I have the next code, about something related to a texture projection, but i need the view space depth, not the (0,1) clipped one:
modelViewMatrix.look_at(lightPosition,lightPosition()+lightSpotDirection(), vec3(0.0f, 1.0f, 0.0f));
projectionMatrix.perspective(lightSpotCutOff(), 1.3333, Dmin, Dmax);
mul_mat4_mat4(scaleMatrix, aux, modelViewProjectionMatrix);
projectedVertex = modelViewProjectionMatrix * vertex;
/* perspective division /
projectedVertex /= projectedVertex.w;
/ now z clipped to 0 1*/
lightViewVertices[i].z = projectedVertex.z*(Dmax - Dmin)+Dmin;
/* and now? */
But the last “transformation” doesn’t works, i compare it to the operation, dot((vertexPosition - eyePosition), direction) and to the depth before projective transformation.
My “transformation” is based that after the scale matrix and perspective division (/=w) z is clipped to (0,1).
What i’m doing wrong?