Depth Buffer Shadow Mapping

Started by
1 comment, last by zedzeek 18 years, 3 months ago
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.
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!
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

This topic is closed to new replies.

Advertisement