Hi Sajjad,

This is almost certainly more complicated than you need.  As I said I
not have to time to nurse maid you through learning about shaders.
The OSG has a number of places where it use shaders in its
implementation, and number of examples as well.

Robert.

On Tue, Apr 28, 2009 at 8:32 AM, ami guru <dosto.wa...@gmail.com> wrote:
> Hello Robert,
>
> After going through  the archives i have found that it has already discussed
> the issue that is not present yet within the API.
>
> Something like SwitchStateSet.
>
> But you did have pave a way to get that done. I am not sure if anyone has
> done that and updated the repository.Your recommendation is as follows:
>
> ************************************************************************************'
>
> Re: [osg-users] Rendering the scene multiple times with different shaders.
>
> Robert Osfield
> Thu, 22 May 2008 08:10:39 -0700
>
> Hi Stephane,
>
> On Thu, May 22, 2008 at 4:02 PM, Stephane Lamoliatte
> <[EMAIL PROTECTED]> wrote:
>> Robert, don't you think this feature could be done by some kind of custom
>> osgFX::Effect node ?
>
>
> You could probably write a custom node that overrides the cull
> callback and post processes/rebuild the StateGraph it's generated.  I
> don't think this is an example of a osgFX::Effect though, such as
> class might belong in osgFX though.
>
>
> It might still be most efficient to tailor CullVisitor to do the
> remapping of the StateSet, such as by tweaking the pushStateSet
> method, that currently looks like:
>
>         inline void pushStateSet(const osg::StateSet* ss)
>
>         {
>             _currentStateGraph = _currentStateGraph->find_or_insert(ss);
>             if (_numberOfEncloseOverrideRenderBinDetails==0 &&
> ss->useRenderBinDetails() && !ss->getBinName().empty())
>
>             {
>                 _currentRenderBin =
> _currentRenderBin->find_or_insert(ss->getBinNumber(),ss->getBinName());
>             }
>             if
> (ss->getRenderBinMode()==osg::StateSet::OVERRIDE_RENDERBIN_DETAILS)
>
>             {
>                 ++_numberOfEncloseOverrideRenderBinDetails;
>             }
>         }
>
> One could possible add a check against an internal map of StateSet
> inside this function.  The only draw back to adding this into
>
> CullVisitor is that it'd add an extra bool check to see if one needed
> to do the look up.  i.e.
>
>
>         inline void pushStateSet(const osg::StateSet* ss)
>         {
>             if (_doStateSetSubstituion)
>
>             {
>                  StateSetMap::iterator itr =
> _statesetSubsitutionMap.find(ss);
>                  if (itr!=  _statesetSubsitutionMap.end()) ss =
> itr->second.get();
>             }
>             _currentStateGraph = _currentStateGraph->find_or_insert(ss);
>
>             if (_numberOfEncloseOverrideRenderBinDetails==0 &&
> ss->useRenderBinDetails() && !ss->getBinName().empty())
>             {
>                 _currentRenderBin =
> _currentRenderBin->find_or_insert(ss->getBinNumber(),ss->getBinName());
>
>             }
>             if
> (ss->getRenderBinMode()==osg::StateSet::OVERRIDE_RENDERBIN_DETAILS)
>             {
>                 ++_numberOfEncloseOverrideRenderBinDetails;
>             }
>         }
>
>
> The custom node would then populate the push and pop
> _statesetSubsitutionMap settings in its cull traversal.
>
> Feel free to experiment with such an implementation and it works out
> send it in to osg-submissions for consideration as
>
> part of the core OSG.
>
> Robert.
>
>
>
> ***********************************************************************************''
>
> If i have understood that correctly you have suggested to to tailor the
> CullVisitor which means to make a subclass of CullVisitor like
> MyCullVisitor and override the functions that you have specified. Now i want
> to get that implemented. And i need your suggestion on the items i have to
> cover more to understand and implement the scenario.
>
> First of all is there any example in OSG that implemented the CullVisitor
> concept. When i have have impelemented it how do i use that from the my
> createSceneGraph() function when i have the very same model that will be
> loaded with different shaders with user interaction.
>
>
> Regards
> Sajjad
>
> ---------- Forwarded message ----------
> From: Robert Osfield <robert.osfi...@gmail.com>
> Date: Mon, Apr 27, 2009 at 9:57 AM
> Subject: Re: [osg-users] Fwd: shader implementation - newbie
> To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
>
>
> Hi Sajjad,
>
> A lot has been written about shaders and OSG over the years, so rather
> than me waste time going over old ground please could you search the
> archives.
>
> Robert.
>
> On Mon, Apr 27, 2009 at 2:47 AM, ami guru <dosto.wa...@gmail.com> wrote:
>> 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
>>
>>
> _______________________________________________
> 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