Drawing Meshes with Antialiasing?


#1

I am drawing meshes fairly straightforwardly, but they are drawing without antialiasing.

I set up the window like this

    ofGLWindowSettings settings;
    settings.setGLVersion(3, 2);
    ofCreateWindow(settings);

I’m constructing and drawing my meshes like this

// create the mesh
ofVboMesh mesh;
mesh.enableColors();
mesh.clear();
// add a bunch of vertices
mesh.addVertex(vector1);
mesh.addVertex(vector2);
//etc.
mesh.addColor(color);
mesh.setMode(OF_PRIMITIVE_LINE_STRIP_ADJACENCY);
mesh.draw();

I’ve also tried drawing to an FBO, so I can force multisampling

allocated like this
_fbo.allocate(width, height, GL_RGBA, 4);

and then drawing like this

 _fbo.start();
 ofClear(25, 25, 30, 255);
 mesh.draw();
 _fbo.end();
_fbo.draw(0,0);

And this is still pixellated.

Am I doing anything obvious wrong?
What should I be doing to draw meshes with antialiasing?


#2

not sure your exact issue but can you try:

_fbo.start();
 ofClear(25, 25, 30, 255);
 mesh.draw();
ofClearAlpha();
 _fbo.end();

what you may be seeing is the alpha from the edges of shapes in the fbo that gets rendered again when you draw the fbo (ie, the alpha from the edge of the mesh adjust the alpha of the fbo pixel and when you draw the fbo that pixel is not 100% opaque)

hope that helps!


#3

Thanks for the suggestion - this doesn’t seem to fix it though. - 100% jagged pixels all the way.


#4

This sounds like a driver issue, what platform are you on? OS, graphics card…


#5

Thanks Arturo
Platform: Win 10
Graphics card: Nvidia Quadro K1100M and Intel HD Graphics 4600


#6

there’s an option in the nvidia properties in windows to choose the nvidia card to run an specific application can you try to find the example you are trying to run there and set it to run with nvidia rather than intel?

Also try updating the intel drivers


#7

Hi Arturo,
Thanks for your advice. I just tried this out

  • with updated intel drivers and intel card selected for the app: still aliased
  • with nvidia card selected for the app: antialiasing

I’m hoping to make this app publicly available - so I’m wondering if the line smoothing behaviour is consistent across most graphics cards (e.g. the NVIDIA result is what I should expect people to see and the intel 4600 is an oddity), or is there something I need to do if I want the software to present consistently?


#8

This usually works and is supported by most hardware, I would also check that you haven’t forced disabled multisampling antialiasing in the intel driver control panel


#9

thanks Arturo - that’s really helpful and good to know. I just tested it on another machine and it looks fine - so I guess I got unlucky with my main machine’s config. I’ll check out the intel control panel.

Dan