Hi,

I don't know whether this has been brought up before (I couldn't find any posts regarding this matter in the user forum), but when using the orthographic projection matrix's setProjectionMatrixAsOrtho(), the near/far plane z values supplied as arguments are not set as according to the OpenGL spec. Specifically, the third column of the projection matrix as applied by osg is:

0.0,
0.0,
-2.0/(zFar-zNear),
-(zFar+zNear)/(zFar-zNear)

with zFar and zNear being the actual Z values of the far and near plane - as opposed to the distance to the far and near plane mentioned in the spec, which in practice turns out to be the negated z value of the far and near plane.

If this has been a conscious choice, it seems highly confusing to me. For example, the vector (0,0,zNear,1) now transforms to (0,0,-(3zN+zF)/(zF-zN),1) in clip space, while the expected transformation would yield (0,0,-1,1). In practice, it gave me a few problems integrating an orthographic projection with depth to a partially rendered scene.

Of course, the workaround is easy, as one should just supply the negated zNear and zFar to setProjectionMatrixAsOrtho(), and in a certain way this is all just a matter of interpretation of the function arguments. In my opinion, supplying the actual z values for the near and far plane is the more intuitive choice, as this is what the names of the function arguments imply.

Best regards,
Kees van Kooten




_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to