Hi Andrea, You can use gl_ModeViewProjectMatrix and gl_ProjectionMatrix with you are using GL2 or compatibility with this, or use the equivalent OSG builtins osg_*. To get the OSG to generate the osg_* uniforms for built-ins see the osgsimplegl3 example, in particular the gc->getState()->setUseModelViewAndProjectionUniforms(true); line.
Robert. On 22 February 2013 15:52, 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

