7

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

genpfault
  • 51,148
  • 11
  • 85
  • 139
paranoidroid
  • 589
  • 6
  • 17
  • Are you simply drawing a texture or is something more involved going on? What does the shader look like? – Nicol Bolas Jun 27 '11 at 02:46
  • This is a texture over a sphere, you're seeing the horizon over the earth here. The shader for the Earth is simply texturing over a sphere, then there is the atmosphere shader which is rendering the blue glow. – paranoidroid Jun 27 '11 at 02:59
  • Can you show an image with MSAA and without the atmosphere shader? – Ben Voigt Jun 27 '11 at 03:04
  • With MSAA and without atmosphere the artifacts are still there http://cl.ly/2E2N343Y0W3l3m1Z3h0Y – paranoidroid Jun 27 '11 at 03:26
  • Sorry that was incorrect, that last image still had an atmosphere shader over the ground. Here it is w/o any atmosphere shader. http://cl.ly/0R0K1W0X2A1U0q151L29 The artifact is gone so it's from the shader. Why would enabling MSAA cause this for this shader? (It's a complex shader). Also is it possible to disable MSAA on just that shader pass? – paranoidroid Jun 27 '11 at 03:34

1 Answers1

10

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.

rotoglup
  • 5,223
  • 25
  • 37
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • You are awesome. Will look into it. – paranoidroid Jun 27 '11 at 05:51
  • It looks like OpenGL ES 2.0 doesn't support centroid sampling. Additionally I would have to split my ground texture function with my atmosphere function in the shader so I can disable just the atmosphere portion. That's pretty much my only option right? – paranoidroid Jun 27 '11 at 06:36
  • @mm1: Pretty much. If ES 2.0 doesn't have centroid sampling, that's the only option. However, you may want to check the extension lists, as there might be a centroid extension you can use. – Nicol Bolas Jun 27 '11 at 06:44
  • Well, I finally did all the work to split my ground shaders from ground atmosphere shaders. In the end it looks like iOS ignores glDisable(GL_MULTISAMPLE) as disabling them on the other shaders does nothing. So with that not working and no centroid sampling I guess I'm out of luck! – paranoidroid Jul 15 '11 at 08:46