Original Post
Hello, So I have created a render which stores the depth information and I did a simple To get it in a texture. Now how do I calculate the 2d position of a pixel om my screen? (2d in light space). I pass the ModelViewProjectionMatrix of the light to the shader. Wikipedia ( http://en.wikipedia.org/wiki/Shadow_mapping ) under "Light space coordinates" said: "The matrix used to transform the world coordinates into the light's viewing coordinates is the same as the one used to render the shadow map in the first step (under OpenGL this is the product of the modelview and projection matrices). This will produce a set of homogeneous coordinates that need a perspective division (see 3D projection) to become normalized device coordinates" How do I do that perspective division? Or how do I turn it into a 2d point in general?
//copy to texture
glBindTexture(GL_TEXTURE_2D, m_shadowTexture );
glReadBuffer( GL_BACK );
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, screenWidth, screenHeight, 0);