Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Artifacts when enabling 4x MSAA anti-aliasing on iPad / iOS

I've enabled 4x MSAA on my iPad OpenGL ES 2.0 app using the example on Apple's website. On the simulator this works well and the image is nice and smooth however on the device there are colored artifacts on the edges where it should be antialiased. This exists on the iPad/iPad2 and iPhone4 but not in the simulator. I've attached a picture below of what the artifact looks like. Anyone know what this could be?

Example

like image 528
paranoidroid Avatar asked Jun 27 '11 02:06

paranoidroid


1 Answers

It looks very much like your shader is attacking, but you didn't post the shader so I can't be sure. See, when you turn on MSAA, it then becomes possible for the shader to get executed for samples that are inside the pixel area, but outside of the triangle area. Without MSAA, this pixel would not have caused a fragment shader execution at all, but now that you turned on MSAA, it must execute the fragment shader for that pixel if one of the samples is active.

The link I posted explains the issue in greater depth. It also gives you ways to avoid this issue, but I don't know if OpenGL ES 2.0 provides access to centroid sampling. If it does not, then you will have to disable multisampled rendering for those things that cause artifacts with glDisable(GL_MULTISAMPLE). You can re-enable it when you need multisampling active.

like image 105
Nicol Bolas Avatar answered Sep 26 '22 15:09

Nicol Bolas