Hola, Let me ask it another way.
I'm in a fragment shader. I have the vec4 gl_FragCoord. I do: Code: vec3 windowcoord = vec3(gl_FragCoord.xy, 1.0); vec3 clipcoord = viewportMatrixInverse * windowcoord; vec4 eyecoord = gl_ProjectionMatrixInverse * vec4(clipcoord, 1.0); eyecoord = eyecoord / eyecoord.w; eyecoord.xyz = eyecoord.xyz * (gl_FragCoord.z / eyecoord.z); vec4 worldspace = gl_ModelViewMatrixInverse * eyecoord; worldspace = worldspace / worldspace.w; gl_FragColor = vec4(worldspace.x, worldspace.y, worldspace.z, 1.0); i.e. I try to retrieve the worldspace coordinates of the fragment and I map its color on these coordinates. The viewportMatrixInverse is built as the inverse of the classical viewport transformation ( here (http://old.uvr.gist.ac.kr/wlee/web/techReports/ar/Camera%20Models.html?bcsi-ac-BD206F1A835A2F32=18BDC07B000002031eDZGe6ZXsApRSxuIFLPU3rflUQUCwAAAwIAAAOrDQEQDgAANwAAAN/PCQA=)). I still use this ref_ptr < osgGA::MatrixManipulator > cammanipulator = new osgGA::TrackballManipulator(); What happens is when I move the object/camera, the colors change for any given point of the model (which shouldn't). I tried the same using viewer.getCamera()->getInverseViewMatrix() for the model view and the same for the projection matrix. I even tried with cammanipulator->getMatrix() to get the inversed modelview. I always had that changing colors problem. Thus my questions are: 1) Are the gl_ModelViewMatrix and gl_ProjectionMatrix usables and updated or not? (Is the viewer linked to the OpenGL modelview?) 2) Do we move the viewer or the scene ? Thank you! Cheers, Maxime ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14756#14756 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

