Sign in to follow this  
Lyve

Transparent Stencil Shadows

Recommended Posts

Lyve    116
Hello users, I'm simulating clouds and I've got a huge list of sprites that also use alpha in their textures. I want to cast the shadow that these clouds are generating. The shadow should be as darker as much as more sprites are intersected by a light ray. Does anyone have an idea how to do that in a fast way with opengl? thanks in advance! Regards, Lyve

Share this post


Link to post
Share on other sites
vincoof    514
There are many algorithms for cloud simulation and shadow casting.
And TBH I don't know of any "good" solution to your problem. This strongly depends on your application. For instance you will not manage the problem the same way in a first-person shooter and in a flight simulator.

Share this post


Link to post
Share on other sites
Lutz    462
You could do projective texture mapping: For every vertex on the ground, project the vertex along the line vertex-light onto every the cloud billboard and adjust the vertex color according to the cloud color/alpha. I guess with some tricks this can be done quite efficiently.

Even more easy: You first map all billboards onto a flat plane (the shadow map). The shadow map should be darker where the (projected) clouds are dense. Use some clever blending function for this. Then, you draw the ground objects with projective texture mapping where each vertex position is mapped onto the shadow map you've drawn before. This mapped vertex position is used as texture coordinate in the shadow map. You can use the texture matrix to perform projective texture mapping. The color value in the shadow map is used as light value for the current vertex. AFAIK this is called shadow map technique.

EDIT: This only works if you only want to cast shadow on the ground. The ground can be hilly but must not be higher than the cloud layer.

Share this post


Link to post
Share on other sites

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