Edge Anti-Aliasing

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Edge Anti-Aliasing

fmorat
Hello!

My 3d objects have some horrible edge aliasing. All the edges that are not vertical or horizontal look really bad. This causes the overall look of my 3D objects to look like crap. It doesn't appear that OpenGL is applying any anti-aliasing to the edges.

Anybody have any resources that could help me with a fix? My google-foo has failed me.

I'm calling
                     gl.glEnable(GL_MULTISAMPLE);

but it does not seem to be doing anything. Plus apparently it is already on by default. Does anybody know of any
other calls to OpenGL that I could make to fix the edge aliasing.

Unfortunately the book "Computer Graphics Programming in OpenGL with Java" 1st Edition,
does not have anything on the subject.

FYI: Texture aliasing is working fine. I enabled MIPMAPPING for that.

Any help is greatly appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Edge Anti-Aliasing

fmorat
Finally figure it out. After creating the GLCapabilities object as so:

            final GLCapabilities glcapabilities = new GLCapabilities(profile);

 I needed to make the two calls below:


            glcapabilities.setSampleBuffers(true);
            glcapabilities.setNumSamples(4);

After doing this my 3D objects now look quite nice. No more ugly aliasing!

Must also not forget to make the call below:
 
              gl.glEnable(GL_MULTISAMPLE);

Just mentioning it for anybody that may be having this same problem in the future.
Reply | Threaded
Open this post in threaded view
|

Re: Edge Anti-Aliasing

gouessej
Administrator
Hello

Actually, the Java documentation of this class explains how it works, especially in setSampleBuffers():
https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GLCapabilities.html#setSampleBuffers(boolean)
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Edge Anti-Aliasing

fmorat
Thanks! This helps.

As a side note, fun to find out that in this class I can enable stereo display!
Reply | Threaded
Open this post in threaded view
|

Re: Edge Anti-Aliasing

fmorat
In reply to this post by gouessej
Thanks for all the help! I finally managed to get a very simple version of my game up and running in my computer.

If you are curious, the link to my website is https://makinacraft.w3spaces.com

(hopefully I won't get banned for spamming...)

It is not much to look at yet, but it will get better with time.

Thanks Again!

Felipe M.
Reply | Threaded
Open this post in threaded view
|

Re: Edge Anti-Aliasing

gouessej
Administrator
It's ok, don't worry :) It's a nice beginning.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Edge Anti-Aliasing

Martin
Hi Felipe,

On my side I use this to enable antialiasing :

    if (quality.isSmoothPolygon()) {
      gl.glEnable(GL2.GL_POLYGON_SMOOTH);
      gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST);
    } else
      gl.glDisable(GL2.GL_POLYGON_SMOOTH);

    if (quality.isSmoothLine()) {
      gl.glEnable(GL.GL_LINE_SMOOTH);
      gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
    } else
      gl.glDisable(GL.GL_LINE_SMOOTH);

    if (quality.isSmoothPoint()) {
      gl.glEnable(GL2.GL_POINT_SMOOTH);
      gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL.GL_NICEST);
    } else
      gl.glDisable(GL2.GL_POINT_SMOOTH);