Andrea,

You could pass in the inverse view matrix and then derive the model matrix:

   uniform mat4 osg_ViewMatrixInverse;
   ...
   mat4 modelMatrix = osg_ViewMatrixInverse * gl_ModelViewMatrix;

Just bear in mind that you will lose precision.


Glenn Waldron / @glennwaldron


On Fri, Feb 22, 2013 at 10:52 AM, Andrea Martini
<[email protected]>wrote:

> Hi to all,
> i'm trying to visualize the "depth field" effect in my osg application,
> using shader (vertex and fragment) from this link
> http://devmaster.net/posts/3021/shader-effects-depth-of-field
>
> The vertex program, requires as uniform the following :
>
> uniform mat4 ProjectionMatrix;
> uniform mat4 ViewMatrix;
> uniform mat4 ModelMatrix;
> uniform vec3 ModelScale;
>
> So, in my osg application, i suppose to pass :
>
> myProgram->addShader(mVertexShader.get());
> myProgram->addShader(mFragShader.get());
>
> mStateset = mMyModel3D->getOrCreateStateSet();
> mStateset->setTextureAttributeAndModes(new osg::Uniform(
> "ProjectionMatrix", myCamera->getProjectionMatrix() ));
>
> mStateset->setTextureAttributeAndModes( new osg::Uniform("ViewMatrix",
> myCamera->getViewMatrix() ));
>
>
>
> mStateset->setAttributeAndModes(mProgram.get());
>
> ...
>
> Does it correct?
>
> How can i pass also mat4 ModelMatrix and vec3 ModelScale?
>
> mStateset->addUniform( new osg::Uniform("ModelMatrix",??? ) );
>
> mStateset->addUniform( new osg::Uniform("ModelScale",
> myMatrixTransformObject->getMatrix().getScale() ) );  // ???
>
>
> Thank you!
>
> Cheers,
> Andrea
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=52819#52819
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to