Results 1 to 8 of 8

Thread: Color Picking Method for selecting primitives..

  1. #1
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Color Picking Method for selecting primitives..

    Hello,

    I am using color picking method to select a primitive in my application.. At present it is picking only single object.. I just wanted to clarify few doubts..

    It is working fine when i click on a single object.. I mean if there are two objects lying on the same pixel.. And if i click that pixel, then i get only one object.. How can i get both the objects, using this method..?? Is it possible..??

    THanks in advance

  2. #2
    Member Contributor
    Join Date
    Jul 2009
    Location
    Buenos Aires
    Posts
    67

    Re: Color Picking Method for selecting primitives..

    Well, the first thing I think of is that you can draw and pick for each object separately

  3. #3
    Senior Member Regular Contributor imported_pjcozzi's Avatar
    Join Date
    Jun 2004
    Location
    Philadelphia, PA
    Posts
    196

    Re: Color Picking Method for selecting primitives..

    You are only getting the top most object, which won the depth test. A straightforward way to get all objects under the pixel is to remove the object that was picked, then render the scene again. Continue this process until no objects are left (e.g. you get the clear color). Alternatively, you can render each object individually and do the sort on the CPU, which I've done here.

    If you are interested, shrink the view frustum to fit around the pixel(s) and perform culling to provide a significant performance gain.

    Regards,
    Patrick

  4. #4
    Senior Member Regular Contributor LangFox's Avatar
    Join Date
    Oct 2001
    Location
    Shen Zhen, Guangdong, China
    Posts
    102

    Re: Color Picking Method for selecting primitives..

    or using the idea inside Inferred Lighting, which could restore 4 object layers for each pixel.
    Best Regards,
    LangFox


    http://hi.baidu.com/lang_fox

  5. #5
    Senior Member Regular Contributor Heiko's Avatar
    Join Date
    Aug 2008
    Location
    the Netherlands
    Posts
    170

    Re: Color Picking Method for selecting primitives..

    Quote Originally Posted by pjcozzi
    You are only getting the top most object, which won the depth test. A straightforward way to get all objects under the pixel is to remove the object that was picked, then render the scene again. Continue this process until no objects are left (e.g. you get the clear color). Alternatively, you can render each object individually and do the sort on the CPU, which I've done here.

    If you are interested, shrink the view frustum to fit around the pixel(s) and perform culling to provide a significant performance gain.

    Regards,
    Patrick
    Just read your article and read the comments on how to use one pixel for each object. I was wondering whether it might be possible to use the geometry shader to draw each pickable object that falls within the frustum to a different layer in a 3d texture / array of textures.

    I'll probably gonna implement your technique and maybe I'll have a go at the possible improvement I came up with.

  6. #6
    Senior Member Regular Contributor imported_pjcozzi's Avatar
    Join Date
    Jun 2004
    Location
    Philadelphia, PA
    Posts
    196

    Re: Color Picking Method for selecting primitives..

    Quote Originally Posted by Heiko
    I was wondering whether it might be possible to use the geometry shader to draw each pickable object that falls within the frustum to a different layer in a 3d texture / array of textures.
    Interesting idea. How large would you make the depth of the 3d texture (or equivalently the length of the array)? How would you know which texture to write to?

    Quote Originally Posted by Heiko
    I'll probably gonna implement your technique and maybe I'll have a go at the possible improvement I came up with.
    Cool. Please let me know how it goes.

    Take care,
    Patrick

  7. #7
    Senior Member Regular Contributor Heiko's Avatar
    Join Date
    Aug 2008
    Location
    the Netherlands
    Posts
    170

    Re: Color Picking Method for selecting primitives..

    Quote Originally Posted by pjcozzi
    Quote Originally Posted by Heiko
    I was wondering whether it might be possible to use the geometry shader to draw each pickable object that falls within the frustum to a different layer in a 3d texture / array of textures.
    Interesting idea. How large would you make the depth of the 3d texture (or equivalently the length of the array)? How would you know which texture to write to?

    Quote Originally Posted by Heiko
    I'll probably gonna implement your technique and maybe I'll have a go at the possible improvement I came up with.
    Cool. Please let me know how it goes.

    Take care,
    Patrick
    I was thinking about handing over a uniform integer value for each object that is possibly picked. This integer tells the geometry shader in which layer to draw. After reading back the texture the same integer will be used to read out the right pixel for the right object.

    I've never tried writing to different layers in the geometry shader though, but I was told that it is possible a while ago. So I have to look into it what is and what isn't possible.

  8. #8
    Senior Member Regular Contributor imported_pjcozzi's Avatar
    Join Date
    Jun 2004
    Location
    Philadelphia, PA
    Posts
    196

    Re: Color Picking Method for selecting primitives..

    Quote Originally Posted by Heiko
    I was thinking about handing over a uniform integer value for each object that is possibly picked. This integer tells the geometry shader in which layer to draw.
    Keep in mind that the maximum number of objects needs to be reasonable. What is the biggest dimension for textures on recent hardware? 8K? Perhaps, you know an upper bound and you can just allocate a texture array once. Otherwise, consider using two passes: In the first pass shrink the view frustum to fit around the pixel(s) and perform culling to determine your potentially visible objects. Then allocate a texture array based on the number of potentially visible objects, which is likely to be much less than the number of total objects. Now render the potentially visible objects.

    Quote Originally Posted by Heiko
    I've never tried writing to different layers in the geometry shader though, but I was told that it is possible a while ago. So I have to look into it what is and what isn't possible.
    I'm not sure either. I'm looking forward to hearing your results. I'm curious to hear if the extra complexity is worthwhile, especially if you need to do the multipass approach I mention above.

    Regards,
    Patrick

Similar Threads

  1. Replies: 3
    Last Post: 04-19-2014, 09:47 PM
  2. Color Picking for selecting objects
    By m.sirin in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-20-2010, 07:53 AM
  3. Selecting/Picking and Non-Opaque Objects
    By Zed Gimbal in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-20-2009, 09:02 PM
  4. selecting the selection Method...
    By Kumar K in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-22-2007, 09:47 PM
  5. picking or selecting a triangle of a mesh?
    By lyd in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 11-03-2004, 02:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean