Sign in to follow this  

Shadows for trasparent surfaces

This topic is 4199 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

What is the best way to project shadows off a surface like grass (which is a single plane with a alpha mapped texture) ? Can i do such a thing within a shader, and where should i look?

Share this post


Link to post
Share on other sites
I don't follow... Are you casting a shadow from something onto the grass? If so, look into stencil shadows, they're the simplest and are perfect for flat surfaces.

Share this post


Link to post
Share on other sites
not exactly, lets say we try another example. i have a tree, the trunk and the leaf planes (formed of a texture with many leaves painted onto it and a alpha channel to cull out the unused portions.) I could just set the tree in the land scape and stencil shadow it, but then the leaves shadows wont look right on the ground, they would just be a black squar. I want the leaf planes to emit a shadow onto the ground that is more natural (in other words where it looks like light passed through the leaves.

Share this post


Link to post
Share on other sites
In this case stencil shadows obviously won't work. Instead take a look at shadow mapping(google for more). There are a bunch of variations of shadow mapping out there, so just search around a bit and I'm sure you will find the one that suits you the most.(keywords: variance shadow maps, perspective shadow maps, light-space perspective shadow maps, classic shadow maps)

Share this post


Link to post
Share on other sites
Something you could try (This is just off the top of my head): Make a matrix that will project your object onto the y=0 (ground) plane, as you would for rendering a stencil shadow, and set the alpha for the leaves (Either as a vertex constant or using another texture [or hte same texture?]) to some value, then render the tree with additive blending. Then (intheory), the leaves should add their alpha together and result in a darker colour where more overlap. The trunk could have al alpha of 255, so it's completely opaque.

Again, that's just off the top of my head, I've no idea if that'd work...

Share this post


Link to post
Share on other sites
I think it actually can work, additionally If coded properly It could look decently as well. However, the major drawback of this approach is the fact that the shadows are planar, so it won't cast the shadow onto anything other that the plane itself and not self-shadowing as well.

Share this post


Link to post
Share on other sites
I've been attempting to add Stencil Shadows to trees for a bit now.

The latest method I tried was to create two seperate volumes - one for the solid objects (trunk and branches), and one for the leaf canopy (a volume in which all the leaves are in).

I was then going to create a shadow volume for the leaf canopy, and when darkening the area that is shadowed - I intended to use a texture of a mixture of shadowed and lit areas, like how the ground would look under a tree.

I didn't have the time to finish it, since I ran into a problem writting the edge detection code, but I think it would have provided good looks and ran pretty fast.

Just something to consider :)

Share this post


Link to post
Share on other sites

This topic is 4199 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this