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.

I've followed a tutorial that uses the XNA 4 SkinnedEffect for my animation on that model . How can i also make a shadow for my SkinnedEffect model ?

Thanks !

share|improve this question
    
Can you edit pixel shader of that effect? –  Notabene Mar 9 '11 at 11:46
add comment

1 Answer

up vote 5 down vote accepted

Shadows can be a thorny subject. There are many ways to create shadows in games, broadly split in to 3 techniques: Stencil shadows Texture space shadow maps/light maps Shadow buffers

Stencil shadows give hard, sharp shadow edges and use the stencil buffer and geometry extruded from every triangle (or the silhouette edges, if you can find it quick enough) of a mesh. http://www.gamedev.net/page/resources/_//183/403/the-theory-of-stencil-shadow-volumes-r1873 here's a good page describing the technique in more detail.

Texture space shadow maps or light maps are typically created off-line and stored as a static texture. Generally speaking, these are not dynamic although there are some interesting techniques that can generate light maps in real-time.

Finally, real-time shadow buffers are the most commonly used techniques. These methods all render the scene again in an off-screen buffer from the light's point of view, storing depth values instead of colours. This is called the 'shadow buffer'.

When rendering the scene from the camera's point of view, every pixel is reverse transformed (in your shader code) into the shadow buffer's space and checked to see if the depth of the pixel being written is deeper than the depth stored in the shadow buffer. So far, so good. It gets more complicated when you realise that there isn't enough resolution in the shadow buffer to give good shadows in most cases. There are many techniques to try and increase the effective resolution of your shadow buffer. These are either view space distortion techniques (Perspective, Light space perspective, Trapezoidal) or multi-shadow buffer techniques such as cascaded shadow maps http://msdn.microsoft.com/en-us/library/ee416307%28v=vs.85%29.aspx

From bitter, bitter experience, I would avoid distortion techniques -they just don't work for all situations and introduce nasty biasing problems when sampling from the shadow map. You will spend months trying to sort out the fiddly edge cases whilst your boss (if you have one) becomes ever less patient. Use cascaded or split buffer shadow maps where the view frustum is split into smaller chunks which have their own shadow map. Then use simple bounding volumes to zoom in on shadow casters and receivers. This is the technique that 90% of games I see use.

Good luck, the devil is in the details but there's lots of help out there. Hopefully this will give you the pointers you need.

share|improve this answer
    
This is true. But you did not answer the question. He is asking for the skinned effect in the xna where is propably problem that you don't have access to pixel shader so you cannot do depth render –  Notabene Mar 9 '11 at 12:58
    
Sorry, I can only comment what on what I know. I have never had any need to do XNA programming I've assumed that you can create HLSL shaders in there. I know Direct3D and I know about shadows. –  Luther Mar 9 '11 at 13:04
    
Yeah. Also welcome to GDSE :). Your answer is nice, but it is better to double check if you are answering correctly. XNA is build over directx (so hlsl is its shading language), but there are also some fixed-pipeline-like objects/shaders and i'm 99% sure that skinned effect is one of them. –  Notabene Mar 9 '11 at 13:08
    
Ah, I assumed right: <xnaessentials.com/tutorials/hlsl-basics.aspx>;. If you can't change the skinned effect to add shadow map support, I'd write a new one that you can change. –  Luther Mar 9 '11 at 13:09
    
i would write one but i followed a tutorial to add my skinned model ( that comes with an animation ) and in this predefined SkinnedEffect ( that was introduced in the tutorial ) i have a function SetBoneTransforms that takes as an argument a matrix [] that represent my skin transforms . if i'd define my custom effect, i wouldn't know what to do with this setBoneTransforms ( I am new to skinned models and am not quite good at it ) –  Badescu Alexandru Mar 9 '11 at 13:27
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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