PDA

View Full Version : Problem about clipping mesh with gl_ClipDistance



OodiuoO
04-14-2016, 02:55 AM
Hi All,
I would like to clip a mesh with gl_ClipDistance, but I wonder if the points which in the triangle and on the clip plane can be generated and feedback.As we know a triangle intersects with a plane can generate two points on the edges in most cases, if OpenGL can generate the points and form a new triangle which can be feedbacked?

GClements
04-14-2016, 04:39 AM
Clipping isn't necessarily performed by creating new vertices and tessellating the clipped primitive into triangles. An implementation is free to perform clipping as part of rasterisation. Consequently, there's no way to get the implementation to send the vertices back to the client; transform-feedback returns the unclipped geometry.

The legacy feedback mode (glRenderMode(GL_FEEDBACK)) is supposed to return the geometry after clipping, culling, glPolygonMode() and tessellation into triangles. But I have no idea whether it works correctly (or at all) on modern hardware.

OodiuoO
04-14-2016, 06:14 AM
Clipping isn't necessarily performed by creating new vertices and tessellating the clipped primitive into triangles. An implementation is free to perform clipping as part of rasterisation. Consequently, there's no way to get the implementation to send the vertices back to the client; transform-feedback returns the unclipped geometry.

The legacy feedback mode (glRenderMode(GL_FEEDBACK)) is supposed to return the geometry after clipping, culling, glPolygonMode() and tessellation into triangles. But I have no idea whether it works correctly (or at all) on modern hardware.

Thanks for reply! There are two more questions:

The first one is if I would like to cut a triangle mesh into two seperated meshes with fine seam, is it better to implement the computation outside the pipeline and then submit data to it for rendering? Thus I can export the seperated data to file at the same time.

The second is if the legacy feedback mode is not recommanded in modern programming?

GClements
04-14-2016, 11:28 AM
if I would like to cut a triangle mesh into two seperated meshes with fine seam, is it better to implement the computation outside the pipeline and then submit data to it for rendering? Thus I can export the seperated data to file at the same time.
If the computation is something which only needs to be done once, you wouldn't want to do it every frame. Whether to do it on the CPU or GPU depends upon whether it's the sort of thing the GPU is good and if so whether the gain in performance is worth the effort.


The second is if the legacy feedback mode is not recommanded in modern programming?
Legacy anything isn't recommended in modern programming. Apart from anything else, it makes it harder to port the code. E.g. OpenGL ES 2/3 doesn't have any of the legacy features, while MacOS X doesn't support the compatibility profile (if you want to use legacy features you're limited to OpenGL 2.1; if you request OpenGL 3 or later, the legacy features aren't available).

OodiuoO
04-14-2016, 10:48 PM
If the computation is something which only needs to be done once, you wouldn't want to do it every frame. Whether to do it on the CPU or GPU depends upon whether it's the sort of thing the GPU is good and if so whether the gain in performance is worth the effort.


Legacy anything isn't recommended in modern programming. Apart from anything else, it makes it harder to port the code. E.g. OpenGL ES 2/3 doesn't have any of the legacy features, while MacOS X doesn't support the compatibility profile (if you want to use legacy features you're limited to OpenGL 2.1; if you request OpenGL 3 or later, the legacy features aren't available).

OK! I have the general idea to do my task, thanks again!