Handling textures when generating a shadow

Hi all,

I hope this is advanced enough…

I have the following problem:

I generate shadows in my application with projected textures.

For generating the shadowtexture, I do a render to texture (I will call this shadowtexture from now on, not to be confused with the shadowtexture for depthshadows!).

When rendering this texture I use the following material. The syntax is a bit strange because I do not use OpenGL directly, but I use OpenSceneGraph. But the material is exactly what would happen in “real” openGL:


This works fine as long as the shadower doesn´t have any textures itself.

If the shadower has textures, however, they “shine through” in the shadowtexture:

Example Picture

If I switch off texturing for rendering the shadowtexture this problem goes away, but if I have polygons with partially transparent textures, this looks wrong.

So what I would need is a “trick” to turn the textures to black&white while leaving the alpha intact (or setting it 1 whereever it is nonzero).

I tried to use GLTexEnv, but I didn´t manage to do the trick.

I hope I made myself clear and I hope that someone can help me.

I need an explanation rather than code, because I will have to “translate” this to OpenSceneGraph.

Thanks in advance and best regards,


What if you keep the alpha, but set RGB to PREVIOUS for TU 0 (meaning PRIMARY_COLOR) and play around with the color?


I guess you talk about the



Good idea,

I will try this!




I think I got this right.

The texture still shines through, though less than before. Hm.

If I dont use the ambient component of the state, then the problem is gone.

But then the shadow is pitch black.

Thanks for the help, but the problem is still unsolved!

Is there someone here around who does shadow-projection and can show me the state settings for generating the shadowtexture?