Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Shadow mapping math.

Started by Dolf Oct 5, 2008 at 5:29 AM 0 replies 450+ views
Original Post
Dolf
Dolf
Hello, So I have created a render which stores the depth information and I did a simple

//copy to texture
glBindTexture(GL_TEXTURE_2D, m_shadowTexture );
glReadBuffer( GL_BACK );
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, screenWidth, screenHeight, 0);


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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.