I am trying to add shadows to my 2D xna game. Currently I have created a "shadow" using the texture of the caster with a transparent gray color, rotated, and stretched using a matrix. This, though, does not look like a real shadow, obviously. What I'm pretty sure I have to do is individually move the vertices of the matrix somehow in order to create a parallelogram so that the top and bottom sides are always parallel to the ground.
So, here are my questions:
1) Is this the correct way to cast shadows in a 2D game?
2) If so, how do I make a parallelogram out of the matrix? I've tried a vertex shader but that didn't go very well. I've also seen some people talk about using bones and using DynamicVertexBuffer, but I have no clue how to use them and can't find a tutorial on them.
3) If it isn't the correct way of casting shadows, then how should I do it? I don't want shadows like in Catalin's method, I want them to look like the shadow caster.
EDIT: I also just learned that the transformation I think I need to do is skew the matrix. XNA unfortunately does not include methods to do that, though.
EDIT 2: Here's a picture of the type of affine transformation I want to do (skewing):
I have sort of solved the problem and in-case anyone else wants to know how to skew horizontally here is how:
Matrix skew = Matrix.Identity; skew.M12 = (float)Math.Tan(Math.PI / 4); // replace Math.PI / 4 with the radian amount you want
I need to skew vertically (which I can do by rotating and rotating back, but is there a more efficient way?), though and would still like to know if this is the correct way of going about creating shadows in a 2D game, though
EDIT 3: Here's what I have done in my game, and this is how the shadows should look. I've used a bunch of math and transforming to achieve the matrix for the shadow. Hopefully I've done it the right way