[osg-users] OSG uniforms in GLSL shaders

Kim Bale kcbale at googlemail.com
Sun Nov 1 02:35:34 PST 2009

Hi Himar,

Just include

uniform mat4 osg_ViewMatrixInverse;

at the top of your shader. osg_ViewMatrixInverse is automatically
initialised by the scenegraph and used as a sort of global uniform so
I would think that its a problem with your shader code rather than the
uniform itself.

You can see an example of it in use in the default shader in the
OceanScene class (in osgOcean) where it's used to extract the the
model matrix from gl_ModelViewMatrix.

i.e. vec4 worldVertex = (osg_ViewMatrixInverse*gl_ModelViewMatrix) * gl_Vertex;



2009/11/1 Himar Carmona <himarcarmona at gmail.com>:
> Hi,
>    how can i use the uniform osg_ViewMatrixInverse in my shaders? My shader
> compiles fine, but it seems i have the view inverse matrix wrong. I'm not
> sure if OSG is initializing this uniform for me at runtime. In fact, i don't
> know exactly what i have to take into account to use it. Can anyone give me
> some hints regarding its (recommended) use?
> Thanks and best regards,
> Himar.
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list