Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shadow map and depth texture coordinates


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 KaiserJohan   Members   -  Reputation: 1085

Like
0Likes
Like

Posted 05 January 2014 - 01:50 PM

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



Sponsor:

#2 dpadam450   Members   -  Reputation: 858

Like
0Likes
Like

Posted 08 January 2014 - 05:31 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS