So I've been following the tutorials from the book Sean James's "3D Graphics with XNA Game Studio 4.0", and have been doing fine until i reached the shadow mapping part. in this book it creates point lights with a Sphere model. my first Q is how to draw a directional Light with this frame work? secondly it can do shadow mapping just for one light, how can i do shadow mapping for all or parts of the lights in the game? i just want to know how to modify this codes to do the above tasks. I've followed tutorials on MSDN and some other sites and didn't got the answer. please help me, its so urgent.
closed as off-topic by Josh Petrie♦ Apr 8 at 15:54
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Josh Petrie
For a directional light that is global you don't really have to make the volumetric test, you can just assume that all pixels are eligible for lighting. If it is local somehow then you can just use a volume of your choice.
For a spotlight you can use a cone. To make it a bit softer in appearance you can have the light get a little weaker the further away from the center vector of the light they are. You can make it dissipate to zero before reaching the edge of the cone.
You can see an example of such spotlights in this clip.
It's been a while since I did this but IIRC you will need to create a shadow map for each of the lights. When you do your final pixel shader you will add the lights from all of these together for each pixel.
You ARE going to have a lot of bugs and trouble when working with shaders. A very good way to handle this is to have a possibility to draw all your different buffers separately. That Way you can draw your normal map and see if that is causing trouble, then check you shadow buffers etc. Just looking at a totally screwed up rendered frame will most often not help you much :)