[osg-users] Problem updating uniforms

2008-12-02 Thread Engvall Åsa
Hi osg-users!

I have a shader attached to a subgraph. The shader uses a uniform which needs 
to be updated in every frame. The uniform is related to the modelviewmatrix, 
and should thus get a different value for every node in the subgraph. 

I have tried to use a osg::Uniform::Callback, but the callback is only called 
for the parent node in the subgraph. 
I think it would work if I declare a uniform for each node, and attach an 
updating callback to each uniform, but there must be a more clever way do to it?

Any help would be appreciated!
Regards, 

Åsa Engvall
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem updating uniforms

2008-12-02 Thread Robert Osfield
Hi Asa,

I was strongly recommend trying to use compute what you need from
variables already available to your in the shader, do a per drawable
binding of an uniform would awkward to implement and provide poor
performance.

Please note that you have gl_ModeViewMatrix and osg_ViewMatrix
available in shaders as well a range of other variables.

Robert.

On Tue, Dec 2, 2008 at 1:47 PM, Engvall Åsa [EMAIL PROTECTED] wrote:
 Hi osg-users!

 I have a shader attached to a subgraph. The shader uses a uniform which
 needs to be updated in every frame. The uniform is related to the
 modelviewmatrix, and should thus get a different value for every node in the
 subgraph.

 I have tried to use a osg::Uniform::Callback, but the callback is only
 called for the parent node in the subgraph.
 I think it would work if I declare a uniform for each node, and attach an
 updating callback to each uniform, but there must be a more clever way do to
 it?

 Any help would be appreciated!
 Regards,

 Åsa Engvall

 ___
 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


Re: [osg-users] Problem updating uniforms

2008-12-02 Thread Robert Osfield
Hi Asa,

Have a look at the osgParticle::PreciptionEffect as it caches the
previous frames modelview matrix to enable it to compute motion blurr
of the rain particles.  This is done just for the precipitation effect
drawables though.

Robert.

On Tue, Dec 2, 2008 at 2:08 PM, Engvall Åsa [EMAIL PROTECTED] wrote:
 I agree, but what I need in the shader is the modelViewMatrix from the 
 previous frame.
 (By the way, it's for creating motion blur.)
 What would be the best way to accomplish this?

 Asa


 -Ursprungligt meddelande-
 Från: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] För Robert Osfield
 Skickat: den 2 december 2008 14:51
 Till: OpenSceneGraph Users
 Ämne: Re: [osg-users] Problem updating uniforms

 Hi Asa,

 I was strongly recommend trying to use compute what you need from variables 
 already available to your in the shader, do a per drawable binding of an 
 uniform would awkward to implement and provide poor performance.

 Please note that you have gl_ModeViewMatrix and osg_ViewMatrix available in 
 shaders as well a range of other variables.

 Robert.

 On Tue, Dec 2, 2008 at 1:47 PM, Engvall Åsa [EMAIL PROTECTED] wrote:
 Hi osg-users!

 I have a shader attached to a subgraph. The shader uses a uniform
 which needs to be updated in every frame. The uniform is related to
 the modelviewmatrix, and should thus get a different value for every
 node in the subgraph.

 I have tried to use a osg::Uniform::Callback, but the callback is only
 called for the parent node in the subgraph.
 I think it would work if I declare a uniform for each node, and attach
 an updating callback to each uniform, but there must be a more clever
 way do to it?

 Any help would be appreciated!
 Regards,

 Åsa Engvall

 ___
 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


Re: [osg-users] Problem updating uniforms

2008-12-02 Thread Engvall Åsa
Thank you, I will do that! 
Asa

-Ursprungligt meddelande-
Från: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] För Robert Osfield
Skickat: den 2 december 2008 15:15
Till: OpenSceneGraph Users
Ämne: Re: [osg-users] Problem updating uniforms

Hi Asa,

Have a look at the osgParticle::PreciptionEffect as it caches the previous 
frames modelview matrix to enable it to compute motion blurr of the rain 
particles.  This is done just for the precipitation effect drawables though.

Robert.

On Tue, Dec 2, 2008 at 2:08 PM, Engvall Åsa [EMAIL PROTECTED] wrote:
 I agree, but what I need in the shader is the modelViewMatrix from the 
 previous frame.
 (By the way, it's for creating motion blur.) What would be the best 
 way to accomplish this?

 Asa


 -Ursprungligt meddelande-
 Från: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] För Robert Osfield
 Skickat: den 2 december 2008 14:51
 Till: OpenSceneGraph Users
 Ämne: Re: [osg-users] Problem updating uniforms

 Hi Asa,

 I was strongly recommend trying to use compute what you need from variables 
 already available to your in the shader, do a per drawable binding of an 
 uniform would awkward to implement and provide poor performance.

 Please note that you have gl_ModeViewMatrix and osg_ViewMatrix available in 
 shaders as well a range of other variables.

 Robert.

 On Tue, Dec 2, 2008 at 1:47 PM, Engvall Åsa [EMAIL PROTECTED] wrote:
 Hi osg-users!

 I have a shader attached to a subgraph. The shader uses a uniform 
 which needs to be updated in every frame. The uniform is related to 
 the modelviewmatrix, and should thus get a different value for every 
 node in the subgraph.

 I have tried to use a osg::Uniform::Callback, but the callback is 
 only called for the parent node in the subgraph.
 I think it would work if I declare a uniform for each node, and 
 attach an updating callback to each uniform, but there must be a more 
 clever way do to it?

 Any help would be appreciated!
 Regards,

 Åsa Engvall

 ___
 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