Ok, lets have some theoretical example, shall we...

Suppose the scene is composed of:
- 3 views.
- 2 parameters which are view dependent, named Param1 and Param2.
- 3 objects with different shader for each.

Now, we must have some assumption:
- You have access to the shaders code, and you are willing to manipulate
it, but not in runtime or by the scene structure.
- All the different shaders are referring to the view depended
parameters Param1 and Param2, and that's what makes them View dependent.

Now lets build the scene-graph:

Root----|----View1------------|
        |                     |  
        |----View2--------|   |
        |                 |   |
        |----View3-----|  |   |
                       Scene Root----|------Object1 with shader1
                                     |------Object2 with shader2
                                     |------Object3 with shader3

Now in order to achieve what you want, you only need to add the uniforms
for Param1 and Param2 for all the views and set them with different
values.
All the other uniform values for the shaders should be set in the
StateSet of the objects.

When OSG renders the scene, the uniform values are inherited and
therefore the View dependent parameters will be different for each view,
while the shader code for each object, and the uniforms for the shader
other then the view dependent parameters will be the same in each view.

Did I understand your problem correctly?
Does the solution make sense to you?

Good luck,
 Guy. 


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, April 09, 2008 10:01 AM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] Dilemma with the usage of object Shaders in
differend views ...

> Hmm... Don't you have access to the shaders code?
Yes i've access to the shader code.
> Hmm... Don't you have access to the shaders code?
Yes i've access to the shader code.

> If you do have, then change it and add the uniforms for the View
setting
> parameters to all of them. If not how do you know that they need view
> depended parameters? :)
I'm not sure what you mean, perhaps i must clearify what i will done.
I'm 
writing a engine, where i could specifiy shaders via a special XML
config.
This conifg is loaded and bound dynamically to the object. So far no
problem.

Now it should be possible to use the composite Viewer, where i define
differend
point's of views to the same scene i.e. to create split screens. Now
i've to
use different camera view parameters on the same shader where a single
uniform
is defined. It's not quite usefull to create a new shader only for this
split
screen... The setting of the view dependend values must be done by the
engine
dynamically without manipulations for the shader, the shader shouldn't
have any
dependency to the engine ...

Normally the engine should use a single view. However it should be
possible 
i.e. for effect demos to create different views ...

Best regards,
Christian




----- Original Message -----
From: [EMAIL PROTECTED]
To: osg-users@lists.openscenegraph.org
Date: 09.04.2008 10:29:23
Subject: Re: [osg-users] Dilemma with the usage of object Shaders in
differend views ...


> Hmm... Don't you have access to the shaders code?
> 
> If you do have, then change it and add the uniforms for the View
setting
> parameters to all of them. If not how do you know that they need view
> depended parameters? :)
> 
> Guy. 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> [EMAIL PROTECTED]
> Sent: Wednesday, April 09, 2008 9:18 AM
> To: osg-users@lists.openscenegraph.org
> Subject: Re: [osg-users] Dilemma with the usage of object Shaders in
> differend views ...
> 
> Hello Guy,
> 
> >If you set different shader for each object, I would like some
> >clarification about your original question.
> 
> Yes this is that what i would have, sorry for my confused description.
> 
> >Do you want different shader per object but with some common features
> >that are different for each view??
> 
> Normally the features should not different for each view, but they
could
> be 
> differend between the objects. However you may have the option to
> deactivate
> or reset post processing effects, but this is not the problem, while
> these
> shaders are only exists in the view context and not shared between the
> views.
> 
> Only the object shaders are the problem, they are view independend
bound
> to
> the scene graph object StateSets, but they use view dependend values,
> while
> the scene graph is shared between the views ... By this reason the
> object based
> effects are exactly the same in differend views, while the
> representation
> is influenced by the view values ...
> 
> >If so, keep the shader as they were (differently setted) on the
objects
> >in the single view. 
> Ok, i'm agree.
> 
> >Add to all the shaders uniforms for the "View"
> >properties, and set the uniforms values differently at each View
node.
> Ok, but now i am back to the dilemma. How i could archieve this? If i
> set i.e.
> different uniforms for the cameras, how does the shader knows, which
> should be
> used?
> 
> The shader shouldn't have any application dependend logic, it's a
> container,
> feed with generic params to execute the code without any dependency to
> the
> application.
> 
> Best regards,
> Christian
> 
> 
> -----Original Message-----
> From: osg-users-bounces at lists.openscenegraph.org
> [mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of
> Christian Heine
> Sent: Tuesday, April 08, 2008 5:39 PM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Dilemma with the usage of object Shaders in
> differend views ...
> 
> Well, the shader doesn't "know" of the stateset of the object
(textures
> attached) if you don't set it explicitly. Otherwise, the shader can be
> inherited and at ObjectX you can add a uniform for the sampler.
> 
> You are right that all the objects will be rendered with the same
> shader.
> 
> If you set different shader for each object, I would like some
> clarification about your original question.
> Do you want different shader per object but with some common features
> that are different for each view??
> If so, keep the shader as they were (differently setted) on the
objects
> in the single view. Add to all the shaders uniforms for the "View"
> properties, and set the uniforms values differently at each View node.
> 
> Hope it helps,
>  Guy.
> 
> -----Original Message-----
> From: osg-users-bounces at lists.openscenegraph.org
> [mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of
> Christian Heine
> Sent: Tuesday, April 08, 2008 5:39 PM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Dilemma with the usage of object Shaders in
> differend views ...
> 
> Hello Guy,
> 
> >I think attaching a shader to each view instead of to object X would
be
> >fine.
> 
> I'm not sure if this may be the right thing. Correct me if I'm wrong
but
> 
> this causes
> in some other issues:
> 
> 1. I lost the reference to the specifiv object states like Textures, 
> Geometries etc. How
> does the shader should access this values by differend objects?
> 
> 2. If i bind it to the view, each object is rendered with this shader.

> So i shouldn't have
> the ability to separate shaders and effects between objects ...
> 
> >If you want to use the callback I think you should create a pre-draw
> >callback to the object, which I'm not sure possible. The update
> >callbacks won't help you since it run on all the scene before the
> >rendering and then only the last setting of the shader will be set,
and
> >it also might affect performance. So I still think attaching shaders
to
> >the views would do what you want.
> 
> Ok, this is an argument i've to agree. But if If i overload the render

> method of the
> composite viewer i could implement "callbacks" (better update
sequences)
> 
> for each
> object before calling the parent rendering method, so this should be 
> possible. But i
> am not sure about possible perfomance lacks ...
> 
> Best regards,
> Chrsitian
> 
> 
> 
> Guy wrote:
> > Hello,
> >  I think attaching a shader to each view instead of to object X
would
> be
> > fine.
> >  If you want to use the callback I think you should create a
pre-draw
> > callback to the object, which I'm not sure possible. The update
> > callbacks won't help you since it run on all the scene before the
> > rendering and then only the last setting of the shader will be set,
> and
> > it also might affect performance. So I still think attaching shaders
> to
> > the views would do what you want.
> >
> > Guy.
> >
> > -----Original Message-----
> > From: osg-users-bounces at lists.openscenegraph.org
> > [mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of
> > hellhound at binary-revolution.org
> > Sent: Tuesday, April 08, 2008 10:55 AM
> > To: osg-users at lists.openscenegraph.org
> > Subject: [osg-users] Dilemma with the usage of object Shaders in
> > differend views ...
> >
> > Hi folks,
> >
> > actually i am working on object shading with OSG (i.e. Dot3). All
> works
> > fine
> > with single views. Now i am using the osgViewer::Composite viewer
and
> > getting
> > some dielemma with the usage of object based shaders in differend
> views
> > based
> > on the same scene graph.
> >
> > I.e.: I've a single scene node with an object X where i bind the
> shaders
> > (at 
> > the object StateSet) for execution. In a single view no problem. If
i
> > use this scene in 
> > multiple views (i.e. A, B) i've the dilemma, that i've to use
diffrend
> > shader params
> > on the same shader instance. In each rendering pass the params of
the
> > camera
> > are differend from the point of view of the views, if the views are
> > rendered. But
> > the shader has no knowledge about this, it uses only a single
uniform
> to
> > hook bind
> > param ...
> >
> > I've thought about the following sollutions:
> >
> > 1. Using for each view a single shader instance at the same object
> > StateSet.
> > Is this usefull? If the scene is complex i could get a huge count of
> > shaders
> > which have to be executed. Additionally i'm not sure, if the binding
> of
> > the "unused"
> > shaders produces render artifacts or perfomance issues...
> >
> > 2. Using a callback mechanism which switches this values at the
shader
> > before 
> >    rendering
> >
> > How i could achieve this aim in best way? Has anyone a better
> solution? 
> >
> > Best regards,
> > Christian 
> >
> >
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> >
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> > g
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> >
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
> >
> >   
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
> 




_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to