Shadow map and depth texture coordinates

Started by
0 comments, last by dpadam450 10 years, 3 months ago

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)?

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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement