Advertisement Jump to content
Sign in to follow this  
KaiserJohan

OpenGL Shadow map and depth texture coordinates

This topic is 1835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Doing Shadowmapping with directional light in an OpenGL 4.3 deferred renderer, and I've filled the depth map from the directional lights point of view like below - the directional light is to the right of the camera, looking left:

 

http://s21.postimg.org/8qx8wsaev/shadowmap2.png

 

The scene from the cameras point of view looks like this:

 

http://s21.postimg.org/ivvwmcszb/shadowmap1.png

 

Now my question is, how do I get the correct texture coordinates for the depth texture when doing the lighting pass for the directional light (from the cameras point of view)?

Share this post


Link to post
Share on other sites
Advertisement

for each vertex the user sees you have to put it into the depth/texture (lights space). Take the input vertex, apply the objects transform (its rotated and translated 10 units from the origin  etc). At that point you have the vertex in world space.

Put that through the light/depth textures matrices just like you do with your camera.

 

That result is in range -1 to 1 for (x,y). In order to sample those need to be in range 0 to 1. so you scale by .5, and add .5 to that result. Plenty of examples on shadow mapping if you look them up.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!