Jump to content
  • Advertisement
Sign in to follow this  
lamtab

Deferred Shadow Mapping

This topic is 3267 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

Hello!! I am trying to implement shadow maps using the deferred rendering technique and I cant get it to work. The problem is I cant get the shadow coords right. What I'm doing is the following: //d is the pixels depth which I get from depth buffer vec4 p = vec4(gl_TexCoord[0].st * 2.0 - 1.0, d* 2.0 - 1.0, 1.0); vec4 coords = cameraMVPinverse* p; coords.xyz /= coords.w; coords *= lightMVP; coords.xyz /= coords.w; coords = coords * 0.5 + 0.5; Searching the net I found some solutions which pretty much the same as mine. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Well a screenshot wont help you cause the depth comparison
always fails.
Using incorrect coordinates I get the wrong value from the shadowmap
and that value is always bigger than the coords.z value.
So the result is not affected in any way.

Share this post


Link to post
Share on other sites
Then at least the full shader code. The comparison always fails but I don't see it here. Don't exclude some parts of the code just because you think that they're not important. I've seen many bugs that hide in the most unexpected places. ;)

Share this post


Link to post
Share on other sites
float sd = texture2D(shadowMap ,coords.st).z;
float f= sd < coords.z - 0.005? sd: 1.0 ;

this is the comparison.
anyway i'm certain the coords are not right cause at some
point they are greater than 1.0.
I know that caused I check them with an if statement
and at certain angles of the camera If returns true

Share this post


Link to post
Share on other sites
best bet is to go back and verify all the steps, ie check your correclty reading the shadow map in the correct place by projecting a regular colour texture from the light view using the texture coord your calculating. Then you can verify the projection process is working and the light matrices etc are working correctly..

texture2D(shadowMap ,coords.st).z; what sort of texture / render target are you using here?


Share this post


Link to post
Share on other sites
Quote:
Original post by BlackSeeds
best bet is to go back and verify all the steps, ie check your correclty reading the shadow map in the correct place by projecting a regular colour texture from the light view using the texture coord your calculating. Then you can verify the projection process is working and the light matrices etc are working correctly..

texture2D(shadowMap ,coords.st).z; what sort of texture / render target are you using here?


It is the depth attachment of a framebuffer object i use to render from the light's point of view.
I will check again all steps as you said but I'm not very optimistic about it.
See I have implemented shadow maps before but know I wanna do it the deferred rendering way.

Share this post


Link to post
Share on other sites
Quote:
projecting a regular colour texture from the light view

Projecting the depth texture would be better - 2 tests with one run. (because the depth texture might not have anything in it) :)

Share this post


Link to post
Share on other sites
Quote:
Original post by snake5
Projecting the depth texture would be better - 2 tests with one run. (because the depth texture might not have anything in it) :)


I don't get what you are suggesting. If you are talking about the depth texture of the scene it is not a shadowmap cause it its not rendered from the light's point of view.

Share this post


Link to post
Share on other sites
Oh, sorry, I forgot that we're dealing with deferred rendering here. I thought the texture to which you draw from the light's point of view - the shadowmap.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!