Hi. I don't get the VP matrix = View * Projection matrices. Shouldn't it be vice versa? E.g., here: http://www.swiftless.com/tutorials/opengl4/3-opengl-4-matrices.html MVP is P * V * M, not vice versa. Thanks.
2013/10/17 Marcel Pursche <[email protected]> > Hi, > > it is a bit complex to explain in detail how the projection matrix > transforms depth values. In short: the depth is linearized to [0,1] with > the near and far plane and after this multiplied with a depth-dependent > factor, so that near values take up more space in the depth range than far > away values. This is necessary to use the limited precission of the depth > buffer for fragments that a closer to the viewer. > This is how a regular depth buffer would work. But in my implementation > with the color buffer the depth values are stored in [0,far] range. To get > this values I simply multiply each vertex with the modelViewMatrix and use > the negative z component: > > Code: > > float depth = -(gl_modelViewMatrix * gl_Vertex).z; > > > > > If you want to get the same depth value in your second pass you need to > calculate the following: > > Code: > > float depth = -(shadowViewMatrix * p_worldspace).z; > > > > So you need to pass the shadowProjectionMatrix and the shadowViewMatrix to > the shader. > To sum things up this is how you calculate your texture coordinate and > your depth to test against: > > Code: > > vec2 shadowTexCoord = (shadowViewProjectionMatrix * p_worldspace).st; > float fragmentDepth = -(shadowViewMatrix * p_worldspace).z; > > > > > Your shadowViewProjectionMatrix should consist of: > > Code: > > osg::Matrixd shadowViewProjectionMatrix = shadowViewMatrix * > shadowProjectionMatrix * osg::Matrixd::translate(1.0, 1.0, 1.0) * > osg::Matrixd::scale(0.5, 0.5, 0.5); > > > > > Thank you! > > Cheers, > Marcel > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=56828#56828 > > > > > > _______________________________________________ > 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

