Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

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
If this question can be reworded to fit the rules in the help center, please edit the question.

    
If I understand you correctly you are using deferred shading with volume based lights? What exactly is failing? –  Mikael Högström Aug 15 '12 at 18:43
    
yes, its using deferred shading, but i want to use directional lights or spot lights. and i want to have shadows for all lights, but i dont know how? –  naprox Aug 15 '12 at 19:11
    
Is the problem adding more lights or is the problem implementing specifically spotlights and directional lights? –  Mikael Högström Aug 15 '12 at 21:02
    
not more lights, but spotlights and directional lights, but the main problem is to do shadow mapping for all or some of the lights in the scene. –  naprox Aug 15 '12 at 21:09
add comment

1 Answer 1

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 :)

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.