🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Picking with core profile 3.3

Started by
8 comments, last by taby 3 years, 10 months ago

Hi All

The typical recommendation is to use “unique color” for each primitive (vertex, face, object, I've all cases). Unfortunately such colors are not suitable for my needs:

  • there is a case when a vertex must be selected no matter how it's obsured
  • often meshes are “too dense”. e.g. a pixel covers 2 or more primitives

Same time I've a case “select visible (not obsured) only". e.g. I can't just use “brute force” on CPU.

Any advice?

Thx

Advertisement

Have you considered ray-bb intersection on the cpu, ordered by distance to eye? That would satisfy the "visible" constraint, and still allow you to pick obscured vertices (event though I think this at least partly contradicts the previous constraint)

You'll be free from the raster space, but picking within the boundary is of course an added challenge…

SuperVGA said:
Have you considered ray-bb intersection on the cpu, ordered by distance to eye?

Yes, I use this optimization for objects, but it doesn't help for vertices/faces.

A bit side/common question: with 3.3 there is NO any other way to “return” any data from a shader except of (rendered) *texture. Is it correct?

Tommato said:

SuperVGA said:
Have you considered ray-bb intersection on the cpu, ordered by distance to eye?

Yes, I use this optimization for objects, but it doesn't help for vertices/faces.

A bit side/common question: with 3.3 there is NO any other way to “return” any data from a shader except of (rendered) *texture. Is it correct?

You could intersect faces and vertices (spheres) on the cpu too…

AFAIK, the pipeline can only return textures regardless of version, so to my knowledge, you are correct…

Hi All

Finally all my picking is working. I use glBegin(End)TransformFeedback in conjunction with geometry shader(s). I do all picking tests (such as ray-triangle intersect) in the geometry shader, and, if ok, write a primitive index into feedback buffer. Also if need to pick only visible primitives, then I use “occlusion” API that checks “one by one” but simple.

However I'm a bit confused because I've never heard/read about implementations like mine. I guessed the OpenGL is a very popular technology and there are a lot of tutorials and examples for everything. But not in this case, why? Maybe I re-invented the wheel? (it's known long ago and already forgotten). Or this way has a hidden traps/bottlenecks that I'm not aware of? Note the “picking” task is very popular, every interactive editor needs it.

Thx

Tommato, are you serious when you say that you can get OpenGL to return the primitives it creates in the geometry shader? Can you please provide some code to show how this is done? I would be forever in your debt.

My sample code, where I try and fail to get the primitives, is at:

https://github.com/sjhalayka/opengl_gs_transform_feedback​

My app's geometry shader runs Marching Cubes:

https://github.com/sjhalayka/julia4d3/blob/master/Release/points.gs.glsl

Also, I have some code to get the pick ray from a camera, and some code to determine a ray-triangle intersection. Need it?

P.S. This is for my open source application Julia 4D 3 – https://github.com/sjhalayka/julia4d3

Tommato, are you serious when you say that you can get OpenGL to return the primitives it creates in the geometry shader? Can you please provide some code to show how this is done ?

Here is my geometry shader for picking triangles & quads https://dropmefiles.com/0ONux. (if there is a better way to attach file(s) here - please let me know). About с++ part (transform feedback API) - I can't “extract” it from my prj, essentially what I did is: d/load OpenGL samples pack 4.0 https://www.g-truc.net/project-0026.html​ and used/copied “gl-320-transform-feedback” example. Yes, it works, the out buffer is filled with “intesected” primitives. Note: avoid to use “return” in geom shader, here it ruins the buffer (can be “my card probs”)

The best place to store code, IMHO, is GitHub. Sign up, create a new repository – don't forget to initialize the repository by clicking the “create a readme file” option.

Thanks so much for the link. I've already tried to go through that code, without luck. I will try again ? Thanks!

This topic is closed to new replies.

Advertisement