Hi Robert,
Have you got a chance to look into this?
Thank you.
----
Robin.
robertosfield wrote:
> Hi Robin,
>
>
> I'm a bit perplexed by the issue, as the uniform should be tracking the
> modelview matrix directly as osg::State does a substitution.
>
>
> Could you create a small code example that reproduces the problem?
>
>
> Robert.
>
>
> On 25 March 2015 at 01:28, Robin Wu < ()> wrote:
>
> > Hi all,
> >
> > Recently, I discovered a weird issue that the view/Proj matrix in the main
> > camera updated by the default cameramanipulator of osgViewer does not sync
> > with the one I got in the shader, e.g gl_ModelViewMatrix,
> > gl_ProjectionMatrix.
> >
> > The following two code snippets produce different results.
> > The first one is using the built in gl_ModelViewProjectionMatrix uniform
> > passed in during renderingTraversals()
> >
> > The second one is using the properties from _viewer->getCamera() as
> > uniforms, e.g mainCamera->getViewMatrix().
> >
> >
> > Code:
> >
> > void main()
> > {
> > gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> > }
> >
> >
> >
> >
> >
> > Code:
> >
> > uniform mat4 u_modelMatrix;
> > uniform mat4 u_viewMatrix;
> > uniform mat4 u_projMatrix;
> >
> > mat4 getModelToWorldMatrix()
> > {
> > return osg_ViewMatrixInverse * gl_ModelViewMatrix;
> > }
> >
> > void main()
> > {
> > gl_Position = u_projMatrix * u_viewMatrix * getModelToWorldMatrix() *
> > gl_Vertex;
> > }
> >
> >
> >
> >
> > When overlapping the rendering results of the two shaders into one buffer,
> > the second shader is approximately one frame slower than the first one,
> > making me doubt that the view/proj matrix managed by the main camera is not
> > synced with the one managed by the renderingTraversals().
> >
> > This out of sync problem is also pronounced in Wang Rui's effectcompositor.
> > In the ssao.xml demo, if you turn on the analysis mode, you'll see that in
> > the linearDepth buffer view, the depth is unstable (flickering) when you
> > zoom in and out quickly.
> >
> > The following is the code snippet from Rui's ssao.xml
> >
> > Code:
> >
> > void main(void)
> > {
> > vec4 vecInEye = gl_ModelViewMatrix * gl_Vertex;
> > depthValue = (-vecInEye.z - nearPlaneValue) / (farPlaneValue -
> > nearPlaneValue);
> > gl_Position = ftransform();
> > }
> >
> >
> >
> >
> > I suspect that the nearPlaneValue and farPlaneValue form the built-in
> > projection matrix's uniforms are somehow not synced with the corresponding
> > ones in gl_ProjectionMatrix ( from ftransfrom() );
> >
> > This problem bugs me for a long time. My current workaround is just using
> > the manually supplied uniforms from the main camera. But the extra
> > computation of the modelviewprojecionmatrix is definitely a waste in the
> > vertex shader.
> >
> > Any ideas?
> >
> > Thank you.
> >
> > ...
> >
> > Robin[/code]
> >
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=63199#63199
> > (http://forum.openscenegraph.org/viewtopic.php?p=63199#63199)
> >
> >
> >
> >
> >
> > _______________________________________________
> > osg-users mailing list
> > ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> >
>
>
> ------------------
> Post generated by Mail2Forum
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63220#63220
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org