Hello Robert,

After going through several source code regarding shaders, i think  that
using seperate program for different type of shader is a better
choice.

In that case i am creating a vector<> of osg::Program initially, and
attaching the shaders corresponding to the programs.

Now with user input i am trying to enable a particular program . In OpenGL
there is a command named

glUseProgram(id);

To enable the program which we can link and validate later. It is like
toggling between different program object.


In OSG i think we have to toggle between StateSet.


Can you suggest any example with in OSG that does that state changes in an
interactive way?



Regards
Sajjad

---------- Forwarded message ----------
From: ami guru <dosto.wa...@gmail.com>
Date: Sun, Apr 26, 2009 at 7:30 AM
Subject: Fwd: [osg-users] shader implementation - newbie
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>


Hello Robert,

Thanks for the feedback.

I am trying to design the interface as follows:

if(userEvent == "Toon Shader")
{
   //adding the corresponding shader to  the program for the StateSet of the
model
}
else if(userEvent == "Gooch Shader")
{
   //adding the corresponding shader to  the program for the StateSet of the
model
}


Now If the user select the Toon Shader several times at several instances
the very same shader will be added several times.

I was thinking about loading all the shaders that i want to incorporate
within in my application during the class's constructor and make the
particular shader active during user selection .

Is there any way within OSG to activate a particular shader while
deactivating the rest of them?


I have one model in my scene that i want to apply different shader on it.



Regards
Sajjad







---------- Forwarded message ----------
From: Robert Osfield <robert.osfi...@gmail.com>
Date: Sat, Apr 25, 2009 at 10:43 AM
Subject: Re: [osg-users] shader implementation - newbie
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>


HI Sajjad,

osg::Program has have a list of shaders, think of shaders like .cpp's
that go together to make a C++ program.  You can have just the main or
a whole series of separate files.  The osg::Program is what tells the
OSG/OpenGL what shaders should linked together to make the final
program downloaded to the GPU.

Now if you want different compositions of shaders at different points
in your scene graphs then you'll need to link them together with
separate osg::Program, or use a single osg::Program and uniforms to
option select different paths in the shaders.

Robert.

On Sat, Apr 25, 2009 at 7:54 AM, ami guru <dosto.wa...@gmail.com> wrote:
> Hello forum,
>
> I am trying to implement some of  the shaders in a single OSG application.
> At  the same time i was going through the osgshaders example and if i have
> understood that correctly,
> i saw that the example has separate osg::program for different shaders
>
> I was wondering if it is possible to have one single program to manage all
> the shaders. I think osg::Program
> contains a vector of shaders.
>
> Is that possible to store different shaders by different name and load
that
> according to  the user selection;
> delete previous shader and load the currently selected one.
>
>
> Or separate osg::program for different shader example is best approach.
>
> I am considering different design issue here.
>
> Any opinion regarding that will be helpful.
>
>
> Thanks
> Sajjad
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to