[osg-users] Check if sampler2D is valid in fragment shader

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Thu Dec 29 11:42:41 PST 2016

Am 29.12.2016 um 17:07 schrieb Rômulo Cerqueira:
> Hi Christian,
>> You could traverse the scene graph and check the state sets to see if they bind a texture to a texture unit.
>> Then depending on these findings, choose the correct shader code.
> I appreciated it. Can you give me some example?
Basically alot of scenegraph handling is built around the 
VisitorPattern. To use it, derive your visitor from the osg::NodeVisitor 
base class and override the appropriate apply-functions.
There are a lot of examples in the OSG code base and the examples.
In your case you might want to consider to use the osg::Node-apply 
function and simply check for a StateSet which contains the texture. In 
case you find a texture you might use the proposed pragmatic shader 
Simply set a "USE_TEXTURE"-define for the nodes with textures (via the 


> ...
> Thank you!
> Cheers,
> Rômulo
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=69799#69799
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list