Login  Register

Re: picking

Posted by ul on Dec 26, 2013; 8:04am
URL: https://forum.jogamp.org/picking-tp4031052p4031061.html

Thanks,

Yes, the grapewine has it that OpenGL and Direct3D are feature equivalent, but the devil's in the details. I was wondering if anyone experienced in working with OpenGL shaders see any immediate problems with my approach. For example is there something similar to a Geometry shader which allows me to get hold of triangulated data? And can I output (pick) data back to the application from that shader?

I know it's simple to intersect a ray with a triangle and that's why I'm doing exactly that :). But as I said in my previous reply, most of the triangles are created on the GPU. I'm using Hull shaders to triangulate easily parametrizable shapes such as spheres and cones. These triangles are not available to the "software" running on the CPU.

This contributes to the efficiency of this approach. When you draw say a sphere you essentially just pass a position and a radius to the GPU, not lots of triangles. It's very easy on the bandwidth. And furthermore you don't duplicate effort. You don't need an extra "software" copy on the CPU of functionality you've distributed to the GPU. Once you've embraced shaders you need to get rid of fixed-pipeline thinking. The shaders are part of the "software".

Just an example. To draw 1.4 million spheres (using adaptive triangulation so spheres appear round regardless of distance to the observer) takes 0.1 seconds on my computer. That's fast enought to pan, scroll and zoom them smoothly. To pick any sphere takes 0.025 seconds.