View Full Version : selecting the selection Method...
02-20-2007, 08:44 PM
I always have a doubt when i start implementing selection in OpenGL. Earlier i used selection buffer pushing names for couple of projects and now i heared that ray-casting is the better solution than that. As i am still in the process of learning GL extensively I have got following questions( may look silly.....).
1) Do SelectionBuffer/Feedback use ray casting internally.
2) Is ray-casting process faster and effecient than using selection buffer and pickMatrix.
3) Is there any dependency in selecting this process depending upon the volume of rendered objects.
4) All top level applications like cosmo3D (c**** test) uses which method of OpenGL...?
02-20-2007, 10:39 PM
1. No, OpenGL picking only returns the names of the primitives that fall inside the viewing volume, no ray casting, although if you do think about a 1x1 clip volume it may be some kind of a blown ray.
2. Yes, its very efficient if done using some spatial hierarchy like AABB trees, bins etc.. it could be very fast < 1ms.
3. OpenGL picking: no, you define a new view and OpenGL discard everything not in that view. Ray casting: no, you just cull out objects not in the ray direction.
I would suggest going the ray for selection:faster, more fun, does not depends on a feature of a specific API, OpenGL selection may be removed in future versions!!!
Hope it helps
02-20-2007, 11:35 PM
Thanks for your reply, however was bit suprised to see what you said about "May remove the selection methods in future GL versions"...WHY?,WHATS WRONG?..
And one more additon to what i asked for, I guess there is no restictions for the number of names you can push/load for rendering objects for selection buffer method is that true...??
02-20-2007, 11:55 PM
There is a number restriction, plus, the selection mode runs entirely in software. Sadly, OpenGL still has many features that were useful twenty years ago for workstations but make no sense now. All selection runs in software, so it is a performance killer. I also suggest that you use ray casting, or maybe the occlusion queries (you could limit the drawing area with scissor test and check which object has most fragments in that area).
02-21-2007, 04:56 AM
I wouldn't suggest using GL's selection at this point. As Zengar said, software raycasting for one ray can be very fast if you do it right and have a good bounding hierarchy. Occlusion queries can give a big boost if you only want the object ID (or you can always ray cast just the occlusion "hits" in SW).
A third way, which has worked well for me and is very fast on modern HW, is rendering with color tags : Keep a version of your scene around with positions and colors only. The colors are unique per triangle (all flat shaded, no alpha, no texture, no MS, but some VP is okay) such that you can convert the final framebuffer color(s) back to an ID which indicates the triangle(s). I often use 16 bits of object ID + 16 bits of triangle ID, or you can use it as an int index into a lookup table. Render into a 1x1 pixel buffer (or scissor) and then do a simple readpixels. Given the triangle, you can get the position, normal, etc.. quickly in software. This method is fast enough that I often don't even cull the scene before drawing. Just blast it.
02-21-2007, 05:52 AM
In defense of selection, I think it still has its (limited) place, and it's certainly not going anywhere. True, it's not fast enough for tracing hundreds of bullets in a FPS, but that's not what it was designed for; it was created to make scene object selection possible, and it does so without much modification to your rendering pipeline and scene graph (if set up correctly). It's plenty fast for the occasional editor mouse click--remember that the pick matrix constricts the viewed scene to essentially a beam through the environment, so even the crudest of hierarchical frustum culling will eliminate most of the world right off the bat (you should only be rendering what could potentially intersect this beam/frustum). What makes this method potentially very slow is blindly plowing through the scene with no culling of any kind (that's a killer, and not recommended in any case).
I think what's nice about selection is its simplicity of use and ease of integration into existing renderers.
Line segment tracing and color ID are also very good methods. I think ultimately the choice depends on your particulars.
02-22-2007, 08:47 PM
Thank you every one..
Originally posted by caveman:
I think ultimately the choice depends on your particulars. some where i feel this as a difficult choice to make out what applies for what particulars.
However for my current scenario where i have to implement selection inside huge chunk of code base which has been already written in olden GL sytle.I would rather prefer to go with simple SelectionBuffer mechanism rather than re-designing the rendering as sceneGraph or anyother grouping sturcture similar, and raycast it for picking.
As a final conclusion what i came to know is that "if any one who wants to have selection for the rendered objects in OpenGL,they need to have some sought of grouping structure for the objects that are getting rendered. This makes easier for implementing powerful methods like raycasting."
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.