Hi,

I have some code that uses osg::ClipPlane to clip a hierarchy of meshes. All I 
do is create some plane equations relative to the root node's transform and set 
the planes as attributes that affect the entire tree.

This works pretty well. When I look at the output in gDEBugger, I can see that 
the clip equations are invoked after glLoadMatrix is called on the root 
transform. glEnable is called on the clip planes before any of the geometry in 
the hierarchy is drawn.

Currently, I need to port this functionality to a vertex shader for a project. 
Clipping in a shader is pretty straightforward, but I'm getting a little 
tripped up on what transformation space the clip planes should be in and how to 
transfer that to the vertex shader.

According to the glClipPlane docs, the plane equations are transformed to view 
space. In my shader, I'm passing the plane equations in as uniforms. For this 
to work on all vertices, I need to ensure that the clip plane equations have 
been transformed by the inverse transpose of the model view matrix. The only 
way that I can think of doing that is creating a uniform update callback which 
always updates the plane equations based on the camera's current model view 
matrix.

This seems a little clunky to me, but I wasn't sure how else to do it. Is there 
a simpler way that I'm overlooking? This fixed function pipeline model was 
convenient since it did a lot of this work for me, but it seems like I have to 
do on my own if I go the programmable pipeline route. Is this a correct 
assessment?

Thanks! And sorry if this is a bit long-winded.

-Dave

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=44278#44278





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

Reply via email to