[osg-users] Several clipping planes

Claudio Benghi claudio.benghi at gmail.com
Wed Feb 10 01:11:18 PST 2021

Thanks Robert,

apologies for the long delay, It's taking me a lot of studying to 
understand shaders uniforms and attributes, 
so I'm responding to your question as I go on reading and testing.

> Is the clipping always going to base on a horizontal plane?  

Unfortunately no. While this will be the case in 90% of the models, I need 
to have a more flexible API,
so I'm thinking to have uniforms to store reference planes (which will 
rarely or never change) and some method
(uniform or attribute) to pass the clipping distance for the relevant 

Are there benefits in moving the objects that need clipping under a 
different group? They will always be a minority of the model geometry.


On Thursday, 4 February 2021 at 13:40:27 UTC+1 robert.... at gmail.com wrote:

> Hi Claudio,
> Welcome to the OSG community. For your first post you sure are diving into 
> an advanced topic :-)
> Conventionally one would do clipping using gl_ClipPlane, this is set by 
> osg::ClipPlane state attribute and osg::ClipNode to place one or more 
> ClipPlane in a final position in space,  I think OpenGL implementations 
> provide at least 6 clip planes, but It's while since I've head my head deep 
> in OpenGL as I'm mostly working with Vulkan these days.  There is a hard 
> limit though that is driver/hardware dependent.  This type of clipping gets 
> applied during the traseration step just prior to the fragment shader.  It 
> can be used with fixed function and shader pipelines.
> From your description it sounds like something custom will be best, which 
> in essence would be to use a fragment shader test to discard/fade out 
> fragments based on some combination of uniform or vertex attribute settings.
> Is the clipping always going to base on a horizontal plane?  If so then 
> you just need to encode the height to clip at for each object via a uniform 
> or more efficiently with a vertex attribute bound with BIND_OVERALL.  
> Uniforms have a higher overhead than vertex attributes in OSG/OpenGL so 
> general best used for rarely changing values, with values that change with 
> high frequency i.e. different for each object using vertex attributes will 
> be more efficient.
> Cheers,
> Robert.

You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/18d25f40-3a7f-4c24-9115-b140d5fe490dn%40googlegroups.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20210210/3bb3edd9/attachment.html>

More information about the osg-users mailing list