[osg-users] how to set the model view projection matrix for my own vertex shader

2014-09-02 Thread Gianluca Natale
Hi all.
First of all, sorry if mine is a silly question, I'm quite new to using shaders 
in OSG.

My scenario is this:
I have a vertex shader that gets as uniform in-variable the model view 
projection matrix, MVP_matrix is the name of that variable in my shader.
The shader is written in GL4.3, so I cannot rely upon the deprecated built-in 
variable gl_ModelViewProjection matrix.
Now, I have to attach such shader in a program that is set in a state set used 
to render my geometry (that state set is attached to the geode that contains my 
drawable, where the geometry is defined).
So, I would like that OSG automatically passes the model view projection matrix 
to my shader during rendering traversal.
I've seen in some OSG code that there is a predefined in-variable called 
osg_ModelViewProjectionMatrix that I think is filled by OSG during rendering 
traversal with the current model view projection matrix. Is that correct?
So, should I rely upon it in my shader, basically replacing my MVP_matrix 
with osg_ModelViewProjectionMatrix?

Further question: unfortunately the shader I have to use is shared among other 
applications in my company, and not all of them use OSG for rendering (some use 
pure OpenGL) :(
So it's likely that I cannot modify it (otherwise I should ask all developers 
to change the name of the in-variable they pass directly to the shader to 
osg_ModelViewProjectionMatrix).
Hence the question: if I'm forced to use MVP_matrix, is there a way I can 
tell OSG to set automatically the value of osg_ModelViewProjectionMatrix to 
MVP_matrix at run-time, i.e. during rendering traversal?

Thanks,
Gianluca

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


Re: [osg-users] how to set the model view projection matrix for my own vertex shader

2014-09-02 Thread Robert Osfield
Hi Gianluca,

osg_ModelViewProjectionMatrix is the OSG's equivilant to
gl_ModelViewProjectMatrix, and there is a mechanism in osg::State that can
replace gl_ModelViewMatrixProjectMatrix usage in shaders with the osg_
equivalent at runtime.  There isn't however a general customizable support
for setting and substituting your own uniforms in this role.

In your own application I'd suggest when you set up your osg::Shader with
the shader source you replace the MVP_matrix usage with gl_ or osg_
equivalent.

Robert.


On 2 September 2014 10:59, Gianluca Natale nat...@europe.altair.com wrote:

  Hi all.

 First of all, sorry if mine is a silly question, I'm quite new to using
 shaders in OSG.



 My scenario is this:

 I have a vertex shader that gets as uniform in-variable the model view
 projection matrix, MVP_matrix is the name of that variable in my shader.

 The shader is written in GL4.3, so I cannot rely upon the deprecated
 built-in variable gl_ModelViewProjection matrix.

 Now, I have to attach such shader in a program that is set in a state set
 used to render my geometry (that state set is attached to the geode that
 contains my drawable, where the geometry is defined).

 So, I would like that OSG automatically passes the model view projection
 matrix to my shader during rendering traversal.

 I've seen in some OSG code that there is a predefined in-variable called
 osg_ModelViewProjectionMatrix that I think is filled by OSG during
 rendering traversal with the current model view projection matrix. Is that
 correct?

 So, should I rely upon it in my shader, basically replacing my
 MVP_matrix with osg_ModelViewProjectionMatrix?



 Further question: unfortunately the shader I have to use is shared among
 other applications in my company, and not all of them use OSG for rendering
 (some use pure OpenGL) L

 So it's likely that I cannot modify it (otherwise I should ask all
 developers to change the name of the in-variable they pass directly to the
 shader to osg_ModelViewProjectionMatrix).

 Hence the question: if I'm forced to use MVP_matrix, is there a way I
 can tell OSG to set automatically the value of
 osg_ModelViewProjectionMatrix to MVP_matrix at run-time, i.e. during
 rendering traversal?



 Thanks,

 Gianluca



 ___
 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