View Full Version : Object Tagging in color buffer
09-28-2009, 05:45 PM
I am reading the article on object Tagging in color buffer.
I didnt get what is stored in the 24 bit buffer??? color??If so if an object entirely consists of a same color,how can i select a particular fragment,If I want to edit it.
Thanks & Regards,
09-28-2009, 09:06 PM
That's not really the intention of this method, or the article you link to.
The idea is that an entire object, or individual surfaces in an object, are drawn in their own unique colour. (The "uniqueness" of the colour is limited by the colour buffer's resolution. So in theory you could use ranges on surfaces or many slightly different colours for individual faces - up to the limit of the current colour depth's resolution.) You then read back from the colour buffer after drawing is complete and the unique colour you get back for a specific pixel identifies the object (or surface).
Blending, depth buffering etc. all have an affect on the results you get from the colour buffer, and which object (if any) that you end up "picking". Blending (for example) would almost definitely break this method as it is described above. :)
It's summed up in the final paragraph:
One disadvantage of using the color buffer is that the color buffer can only hold a single identifier at each pixel. If depth buffering is used, then the pixel will hold the object name corresponding to a visible surface. If depth buffering is not used, then a pixel hold the name of the last surface drawn. The OpenGL selection mechanism can return a hit record for all objects that intersect a given region. The application is free to choose one of the intersecting objects using a separate policy, e.g. the object closest to the viewer, iterate through all of the objects one at a time, etc.
09-29-2009, 09:07 AM
This is a lot like Damian's Light Indexed Deferred Rendering (http://levelofdetail.wordpress.com/2008/01/24/light-indexed-deferred-rendering/). You might read over his write-up for more details on how rendering can work differently when you store "ID"s in the color buffer. The main difference between this and his technique is that light indices instead of object indices are stored.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.