Or “This guy activated 2x Multi Sampling. You won’t believe what happened next!!”.
I’m trying to make some kind of “acceptable” grass simulation for Android. I have managed to get nice performance in my phone, but there’s still much work left to improve it. Today I wanted to check using a lower resolution with antialiasing enabled, but at some point I commented out the resolution change in code but left the 2x antialiasing in the quality settings, and I was baffled when that improved the performance in certain situations; it’s only an improvement of maybe 4 or 5 FPS when using landscape orientation (in portrait, or when using certain wind parameters, the performance is around the same or a hair slower on average), though also the speed is much more stable (the FPS don’t jump so much), and of course it looks nicer! Now I’m trying to understand why. This is what I’m thinking:
In its current (unfinished) form, each blade is “3D”; I mean, I’m not using textured billboards, but many meshes with 150 blades made with 3 triangles each one. Right now I’m just testing with a fixed camera almost looking to the horizon (see the attached capture), so there’re many blades in front of other blades. Since I cannot control the rendering order of each blade in a mesh (I know I could reorder them in the original file, but, and correct me if I’m wrong, since the GPUs usually use parallel rendering there’s no way of knowing or altering the order in which triangles or fragments will be drawn), I will have many pixels drawn more than once (once each time there’s a blade in front of an already drawn one for a particular fragment).
But what I’m wondering is if when I enable antialiasing my phone’s GPU performs some kind of early z-test or something similar before rendering each fragment as part of the AA algorithm. If that was the case, many or all the fragments would be rendered just once, and the speed gained could compensate the other computations needed for AA, even to the point of improving performance in some situations. Plus the FPS would probably be more stable, since the number of fragments rendered would be quite constant instead of somehow random.
Does that make sense and can be an explanation for the results I’ve got, or could there be something different going on? Can I assume I could get the same behaviour in different phones? (yeah, I know it’s a tough question, but anyway…).