Hi Daniel,

I'm afraid I don't have any ideas to what might be amiss.

In terms of clip plans/position state and how many clip planes you can have
active at any one time, I can provide some clarity.

For each osg::Camera that isn't set up as a nested render the OSG's
rendering backend sets up a RenderStage per Camera.  Each RenderStage has
it's own list of positional state (clip planes, eye linear texgen, lights)
that it applies with a single modelview matrix prior to the rendering the
main of the contents of the RenderStage.  This means each Camera can use
it's own GL_CLIP_PLANE0. GL_CLIP_PLANE1 etc without it's result interfering
with other Camera's RenderStage.

Robert.


On 18 September 2013 07:10, Daniel Schmid <[email protected]>wrote:

> Hi all
>
> Here comes my follow up. As you can see in the code snipped above, the
> clipping plane of the refraction  camera is looking in the opposite
> direction. Since the clipping is done on the graphics card, and the
> primitives are still in world coordinates, the refraction clipping plane
> has to be multiplied with the transposed camera matrix.
>
>
> Code:
>
> // this is what happens in cull:
>   osg::Matrixd l_ViewMatrix  = l_MainCamera->getViewMatrix();
>   osg::Matrixd l_ProjMatrix  = l_MainCamera->getProjectionMatrix();
>
>   osg::Vec4d l_PlaneNormalCoeff(0.0, 0.0, -1.0, -m_Height);
>
>   osg::Matrixd l_CameraMatrix = l_ViewMatrix * l_ProjMatrix;
>   osg::Matrixd l_InvCameraMatrix = osg::Matrixd::inverse(l_CameraMatrix);
>
>   double* l_MV = l_InvCameraMatrix.ptr();
>
>   osg::Matrixd l_InvCameraMatrixTransposed;
>   l_InvCameraMatrixTransposed.set(
>       l_MV[0], l_MV[4], l_MV[8], l_MV[12],
>       l_MV[1], l_MV[5], l_MV[9], l_MV[13],
>       l_MV[2], l_MV[5], l_MV[10], l_MV[14],
>       l_MV[3], l_MV[6], l_MV[11], l_MV[15]
>       );
>
>   l_PlaneNormalCoeff = l_InvCameraMatrixTransposed * l_PlaneNormalCoeff;
>
>   m_RefractionClipPlane->setClipPlane(l_PlaneNormalCoeff);
>
>
>
>
> The problem I encounter is the following. All the stuff doesn't have any
> effect. The fact of setting a new Clip Plane in the RefractionClipPlane
> object doens't do anything.
>
> So I end up having a clip plane for the reflection camera and a clip plane
> for the refraction camera with both show into opposite directions .
> According to the theory, this should work...
>
> I read something about Positional State attribute and that there are
> issues when setting multiple clipping planes. I don't get the point there,
> and maybe need some more insight (say explanation). I thought by having two
> distinct render cameras, they should be able to have their own clipping
> planes?
>
> Regards
> Daniel
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=56392#56392
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to