Jump to content
  • Advertisement
Sign in to follow this  
AtmaWeapon

Depth Buffer Shadow Mapping

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

Ok, so I implemented shadow mapping using some really dumb tricks just as a proof of concept. It looks cool. Now I want to do it the RIGHT way and I'm running into trouble. Basic Algo 1st Pass: Render Depth Buffer to off screen texture 2nd Pass: Take the 1st pass and using a pixel shader compare the value of the depth buffer to x. What is x?! In theory it's suppose to be the distance from that point to the light source. Buf depth texture gives you a value from 0 to 1. So what am I suppose to be comparing the depth buffer texture to? My Previous (Hack ans slash) method 1st Pass: Use a shader to return the distance from light to object scaled by a constant I provide. This is from the light's perspective. 2nd Pass: Use that texture and scale it by that constant.

Share this post


Link to post
Share on other sites
Advertisement
You could let the GPU check if the pixel is in shadow, and just take that value. The code is on my webpage.

That x is 1/distance, probably scaled with near and farplane.

You can do the compare, you just have to divide by w somewhere along the way. :) Sorry, I don't remeber it right now, but if you use google, you might find it. ;]

Good luck!

Share this post


Link to post
Share on other sites
Quote:
Buf depth texture gives you a value from 0 to 1. So what am I suppose to be comparing the depth buffer texture to?

both are depth vals in the range 0..1

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!