projecting a shadow texture

Started by
7 comments, last by Peti29 18 years, 1 month ago
hello, i want to simulate a very basic shadow. it should just project a round black texture on the ground. like for example in world of warcraft under each character. how would i do that in openGL? multitexturing? thanks!
Advertisement
You could basically have a quad textured with the shadow texture at the base of your character. You might want to use a polygon offset as well to prevent tearing,
the multitexturing would work too.


Jon
www.lefthandinteractive.net
Quote:Original post by jon723
You could basically have a quad textured with the shadow texture at the base of your character.

wouldnt that polygon be floating around when the terrain is uneven?
i want it to be projected to the ground.

Quote:You might want to use a polygon offset as well to prevent tearing


sorry, i dont understand, what do you mean by tearing?
What you want is called "projective texture mapping." It's basically performing a similar projection process on texture coordinates that you perform on vertices to project them to the screen. Here is a good paper on it.
Quote:Original post by Kalidor
What you want is called "projective texture mapping." It's basically performing a similar projection process on texture coordinates that you perform on vertices to project them to the screen. Here is a good paper on it.


Does he really? From what I read, thats not what he's after. He's after a shadow "blob", not projective texturing. What I suggest is something like the following, in lovely pseudo code:

Push character matrix onto matrix stack   Push this matrix onto the stack: "Translate along the y axis half the height of the character"      Draw a quad, with a round texture bound.   Pop Matrix   Draw CharacterPop Matrix


What this done, is draw a quad underneith the character. By pushing the characters matrix onto the matrix stack first, the shadow will appear to move with the character.

Hope this helps
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
Quote:Original post by acid2
...
What I suggest is something like the following, in lovely pseudo code:
...
That's the same suggestion jon723 gave and the OP already pointed out the problem with it. He/she also said "i want it to be projected to the ground" so it certainly sounds like projective texturing would be the technique to use.

EDIT: It's also possible to "project" that quad in your suggestion onto the ground by tesselating it and altering the vertices so that it follows the terrain vertices. However that's more work and then you also have to deal with depth biasing so that there's no z-fighting.
thank you all!

yes kalidor, you are right. i want the shadow blob to be projected on the ground. i will read that paper now, thanks.
ok, i pretty much went through that paper, but unfortunately i dont really understand the theory of this.
would anyone be so kind and explain projective texture mapping to me in a more simple manner?

thank you very much!
Since it's only a blob I don't think projection is that important. Just turn off z testing, use blending and put a textured quad under the character. The texture should be dark at the center and fade transparent towards the outside in circle shape. It'll look fine while it's "noon" and the shadows aren't long :).

This topic is closed to new replies.

Advertisement