Jump to content
  • Advertisement
Sign in to follow this  
ehmdjii

OpenGL projecting a shadow texture

This topic is 4670 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 Character
Pop 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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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 :).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!