- Home /
Anti Aliasing on Mobile
Hello,
I will soon be publishing a 2D game to the mobile stores. The core gameplay looks a little like this with 4x anti aliasing:
As you can see, it renders nicely... Without anti aliasing it, obviously, looks quite jagged.
I don't have the resources to test on many phones so I wanted to ask: What are the implications of using 4x anti aliasing on mobile platforms for a 2D game like this? Should performance be a major concern for a 2D game using 4x anti-aliasing? Which specific devices should I expect to have problems (and therefore test on)? Other drawn elements include a GUI created in 2D Toolkit.
Also, if a device doesn't support anti aliasing, but I have my setting at 4x: What will Unity do? Will it just drop down/disable anti aliasing? Or will it try to do the multisampling itself, causing an even bigger performance problem on those platforms? (I doubt it would, but I thought I'd ask)
My current draw statistics for this scene are:
Draw Calls: 4 Saved by batching: 66 Tris: 184 Verts 324 (This goes way up into the thousands when I add 2D toolkit items, especially those with spritefont rendering)
There are no textures on the core game, but lots throughout the GUI. The core game seen here is just a simple vertex/fragment shader that passes through the vertex color for each mesh.
Thanks!
Allen
EDIT: I did find this just now... It provides some insight: http://gamesfromwithin.com/trying-out-multisampling-on-ios
I've read in some places that it could decrease performance if the device doesn't support it (which apparently some devices don't), but I'm not sure if that's outdated or not as I haven't personally tested this.
Answer by allenwp · Apr 02, 2014 at 02:01 PM
Maybe I could monitor the framerate and set it through code using QualitySettings.antiAliasing. When the framerate drops consistently below 24fps, set antiAliasing to off.
using UnityEngine;
using System.Collections;
public class FramerateMonitor : MonoBehaviour
{
public int ConsecutiveIntervalsFailedThreshold = 4;
public float IntervalSeconds = 0.5f;
public int TargetFramesPerInterval = 12;
protected int frameCount = 0;
protected float timeElapsed = 0;
protected int failCount = 0;
protected bool hasFailed = false;
void Update()
{
if (!hasFailed)
{
frameCount++;
timeElapsed += Time.deltaTime;
if (timeElapsed >= IntervalSeconds)
{
timeElapsed = 0;
if (frameCount < TargetFramesPerInterval)
{
failCount++;
}
else
{
failCount = 0;
}
frameCount = 0;
if (failCount == ConsecutiveIntervalsFailedThreshold)
{
hasFailed = true;
QualitySettings.antiAliasing = 0;
}
}
}
}
}
Does this sound like a good idea to you guys?
Sadly, for mobile, we have the following issues when dynamically changing the AA;
On Android, the screen turn black. The game continue and is still responsive, simply we have no rendering anymore.
On iOS, Scaleform starts flickering madly.
Cool idea. If you have Unity Pro then you can turn something like the FXAA camera filter on and off. As mentioned AA quality settings in Unity seems to have issues like Android or iOS black screen, etc.
Answer by corriedotdev · Apr 01, 2014 at 04:34 PM
There are a few variables that could affect this. However a common one for 2D is that the sprites are set to bi linear when point should be used. Under the sprite in the inspector you can change this.
Hmmm... At first, what you said did sound correct -- that the anti-aliasing would do the same work as the texture filtering, so there's no need to have both.
...But in the case of Unity, I will be using multisampling, which only supersamples the depth and stencil buffers. This means I still need to have texture filtering as well to get nice looking textures.
Thanks for getting me thinking about this, though!
Answer by srmojuze · Aug 11, 2014 at 10:54 AM
I think you should make it possible in the GUI for the player to turn AA on or off. Some people may like nice AA like 4x, some may find it slows down the device.