Transparent Stencil Shadows
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
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement