Hi, all How i can apply shadow texture for object's native state? I don't want modify osg's sources (native shaders). I implement shader for multitexture terrain + grass and other objects, and i want get shadow map and bind it to my shaders. Now i implement like this:
Code: class TestDrawCallback: public osg::Drawable::DrawCallback { public: TestDrawCallback() { isFirst = true; } virtual void drawImplementation(osg::RenderInfo& renderInfo,const osg::Drawable* drawable) const { osg::State* state = renderInfo.getState(); const osg::StateSet* stateset = state->getStateSetStack().back(); osg::StateSet* ownStateSet = const_cast<osg::StateSet*>(drawable->getStateSet()); osg::Texture2D* tex = const_cast<osg::Texture2D*>(dynamic_cast<const osg::Texture2D*>(stateset->getTextureAttribute(1, osg::StateAttribute::TEXTURE))); if(tex) { if(isFirst) { ownStateSet->setTextureAttributeAndModes(2, tex, osg::StateAttribute::ON); isFirst = false; } state->pushStateSet(ownStateSet); state->applyTextureAttribute(2, tex); drawable->drawImplementation(renderInfo); state->popStateSet(); }else { drawable->drawImplementation(renderInfo); } } private: mutable bool isFirst; }; I tested this texture map as base texture. The object which I rendered was white, that is, texture is not passed on or something like that. I Thank you! e Cheers, Sedov[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47881#47881 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org