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:
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,1.0f));
material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,1.0f));
material->setEmission(osg::Material::FRONT_AND_BACK,ambientLightColor);
material->setShininess(osg::Material::FRONT_AND_BACK,0.0f);
stateset->setAttribute(material,osg::StateAttribute::OVERRIDE);
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:
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,
Andreas