## Recommended Posts

wh1sp3rik    248
Hello,

I am trying to figure out, how to render shadows from two depth maps.
Let's say, i have one depth map from Light View and one depth map from Camera View. I know a light position, direction, transformations.

firstly, i thought, i can get a position of pixel from light depth map, make ray, calc distance from light to that pixel and on camera depth, i can find pixel, which lay on this line. When distance is bigger to this camera depth point, it's in shadow. Problem is, i don't know if it will work and second, if yes, it will be slow, becuase O( n^2 ).

Do you have any ideas, how to make it right and fast ? Could you please give me some hints, ways, how to make it?

I attached a RenderMonkey project file, where i render two depth maps and third pass ready for calculation. if someone is really good in shadowing, could you have a look into and write simple example ?
Thank you very much for your help, hint, anything, what can help me

##### Share on other sites
Aqua Costa    3691
I do it this way:
-Use the camera view depth map to reconstruct pixel world position.
-Transform that world position to light view position.
-Compare the depth value calculated and the one store in light view depth map.

##### Share on other sites
jischneider    253
[quote name='TiagoCosta' timestamp='1313007611' post='4847300']
I do it this way:
-Use the camera view depth map to reconstruct pixel world position.
-Transform that world position to light view position.
-Compare the depth value calculated and the one store in light view depth map.
[/quote]

Good luck!!!

##### Share on other sites
wh1sp3rik    248
TiagoCosta: ah, yes .. i understand ! it's much simplier than i though

[url="http://www.gamedev.net/user/187495-jischneider/"][color="#284b72"]jischneider[/color][/url]: thank you, i tried it, unfortunately,i t's written in XNA Game studio 3.1 and i have 4.0 big changes, but i read the code and i have some questions ... which are solved now

##### Share on other sites
jischneider    253
[quote name='wh1sp3rik' timestamp='1313049457' post='4847543']
TiagoCosta: ah, yes .. i understand ! it's much simplier than i though

[url="http://www.gamedev.net/user/187495-jischneider/"][color="#284b72"]jischneider[/color][/url]: thank you, i tried it, unfortunately,i t's written in XNA Game studio 3.1 and i have 4.0 big changes, but i read the code and i have some questions ... which are solved now
[/quote]

XNA 3.1? I didn’t remind it, sorry.

I have a deferred shadow map working in XNA 4.0. Look at:[url="http://xnafinalengine.codeplex.com/"]http://xnafinalengine.codeplex.com/[/url]