This post was updated on .
Hi and thank you for taking time to read this.
I'm using unique color selection for my objects and it works perfectly, until I enabled caps.setSampleBuffers(true); It seems like enabling antialiasing blends the colors I draw to the back buffer so that some clicks returns more objects than the one clicked. I really like the nice antialiasing i get for free enabling the samplebuffers in GLCapabilities, is there a way to disable antialiasing when drawing to the backbuffer and then re-enabling it when drawing the scene? |
Administrator
|
Hi
As far as I know, maybe you can change the number of samples at runtime but you can't disable antialiasing once it is set by using GLCapabilities. Moreover, the use of build-in OpenGL picking is highly discouraged and the color picking doesn't work on any machine that emulates some colors of its palette (which often occurs on laptops). I advise you to use software picking (easy to implement if you only treat triangles) or to implement the picking into shaders (doing that efficiently isn't trivial).
Julien Gouesse | Personal blog | Website
|
This post was updated on .
Hi, thank you for your answer :)
I used to have the build-in picking, (GL_SELECT) but I ran into some issues so I changed it to unique color selection. This seemed like a good approach and was fairly easy to implement. This method works for all of our needs, except when I enable AA. Could you recommend any reading for the 'software picking'? I only have triangles, points and lines in my scene. Is there a good alternative to setting AA in GLCapabilities? would be nice to have some controll over it. My OpengL books does not cover this in a good way. |
Administrator
|
OpenGL picking relies on deprecated methods and/or methods known to be particularly slow in general (glReadPixels) or when used with shaders. I already used build-in picking in the past, it's nice until you use lighting and shaders which prevent it from working reliably on some drivers :s
Ardor3D has a build-in support of software picking, you can look at its source code to understand how it works. Basically, this just throws a ray into a triangle if other preliminary tests haven't considered that it has no chance to succeed. We talked a lot about picking recently, you'll find some information here: http://forum.jogamp.org/picking-td4031052.html
Julien Gouesse | Personal blog | Website
|
Administrator
|
In reply to this post by d0lph1n
On 02/05/2014 01:45 PM, d0lph1n [via jogamp] wrote:
> Hi and thank you for taking time to read this. > > Using unique color selection for my objects and it works perfectly up until I > enable caps.setSampleBuffers(true); > It seems like enabling antialiasing blends the colors I draw to the back > buffer so that some clicks returns more objects than the one clicked. > > I really like the nice antialiasing i get for free enabling the samplebuffers > in GLCapabilities, is there a way to disable antialiasing when drawing to the > backbuffer and then re-enabling it when drawing the scene? > - 2013-12 <http://forum.jogamp.org/picking-tp4031052p4031169.html> - 2012-02 <http://forum.jogamp.org/Mouse-selection-td3787468.html#a3788488> ~Sven signature.asc (894 bytes) Download Attachment |
Thank you both for the answers.
selection mode - tried unique color - tried ray casting - next up and hopefully the last picking strategy I ever implement :P Now where did I put my linear algebra book... |
Administrator
|
On 02/06/2014 01:02 PM, d0lph1n [via jogamp] wrote:
> Thank you both for the answers. > > selection mode - tried > unique color - tried > ray casting - next up and hopefully the last picking strategy I ever implement > :P Now where did I put my linear algebra book... There are links contained which itself contain sample implementations. Maybe you can do this utilizing our PMVMatrix and it's [Un]Project methods. If you have something done - it would be great if you can provide a demo/unit-test under our JogAmp license (BSD-2clause) thx. ~Sven signature.asc (894 bytes) Download Attachment |
In reply to this post by d0lph1n
I've gotten color picking to work using FSAA. I disable the following before creating the color picking render pass. I don't know if they are all necessary, but it works. I haven't run into problems with colors not mapping correctly and I'm not sure if this is even a problem when rendering to textures. Color picking works great for my framework since I render specific layers (and actors) only when necessary. This means I can keep a color picking image around that gets tested thousands of times in a second from moving the mouse. Another thing to keep in mind is if you are rendering in orthographic you must use integer vector points during the color picking rendering pass.
gl.glDisable(GL.GL_MULTISAMPLE); gl.glDisable(GL2ES1.GL_POINT_SMOOTH); gl.glDisable(GL.GL_LINE_SMOOTH); gl.glDisable(GL2GL3.GL_POLYGON_SMOOTH); gl.glDisable(GL.GL_BLEND); gl.glDisable(GL.GL_DITHER); gl.glDisable(GL2ES1.GL_FOG); gl.glDisable(GLLightingFunc.GL_LIGHTING); gl.glDisable(GL2GL3.GL_TEXTURE_1D); gl.glDisable(GL.GL_TEXTURE_2D); gl.glDisable(GL2ES2.GL_TEXTURE_3D); gl.glShadeModel(GLLightingFunc.GL_FLAT); |
Your fix works :)
I think maybe I'll give the user the ability to srwitch between the different modes since i have been using the better part of last week implementing ray selection and testing it. I have tried your solution before but I think i missed a line or two. Thank you so much for clearing this up for me :) I've seen many threads around the net where people are wondering about the same thing and now they have a place to find the answer :) Thanks again. |
Free forum by Nabble | Edit this page |