[osg-users] Inherit parts of shader program

Robert Osfield robert.osfield at gmail.com
Fri Sep 2 22:21:44 PDT 2016


HI Ravi,

The OSG doesn't have an inheritance scheme like this within
osg::Program for osg::Shader in exactly the way you are wanting but
there are several features that allow you to do something similar.

The most straight forward answer to use mulitple osg:Program as ou are
already doing but share the osg::Shader that you wish to between the
osg::Program.

The next way would be to use a isngle osg::Program that links in all
the osg::Shader that you might want and then use the #pragma(tic)
shader compsition support in OSG-3.4 onwards to select which parts you
want active for each subgraph by assign the appropriate #define
settings on the each subgraph StateSet's.  Have a look a the
osgshadercompsition example to see it in practice.

Robert.


On 2 September 2016 at 23:03, Ravi Mathur <ravidavi at utexas.edu> wrote:
> Hi all,
>
> I have a Geode that contains multiple Drawables. I set a Program containing a vertex Shader on the Geode's StateSet. This was done because all contained drawables should use the same vertex shader. Everything works great.
>
> Now, I want to set a fragment shader on just one of the contained drawables, but keep using the vertex shader from the main geode. So I created a new Program, added the custom fragment Shader, and added the Program to the drawable's StateSet. But now that drawable doesn't use the parent geode's vertex shader! It just uses the OpenGL fixed-pipeline vertex shader.
>
> Is there a way to inherit just the vertex shader from a Geode to one of its contained Drawables that has its own fragment shader? I feel like I'm approaching this incorrectly, hopefully someone can slap me into shape. :)
>
> Thanks!
> Ravi
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68507#68507
>
>
>
>
>
> _______________________________________________
> 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