QualitySettings.antiAliasing and per-camera anti-aliasing problems [Solved]

I’m having some trouble getting anti-aliasing settings to work. In my game I have a dropdown menu that a player can choose the anti-aliasing level from. It’s got the 4 levels available in the quality settings - disabled, 2x, 4x and 8x. In script on the dropdown settings I’ve got the following 4 lines:

QualitySettings.antiAliasing = 0;
QualitySettings.antiAliasing = 1;
QualitySettings.antiAliasing = 2;
QualitySettings.antiAliasing = 3;

When choosing the setting of 0 or 1 it disables anti-aliasing in the quality settings. When choosing 2 it sets it to 2x. When choosing 3 it also sets it to 2x. Why does quality setting 1 not set it to 2x? Shouldn’t 0 be “disabled”, 1 be “2x”, and so on?

The documentation says: “If unsupported by the hardware or rendering API, the greatest supported number of samples less than the indicated number is used.” Would this somehow be why I can’t get it to go above 2x?

Even further, all the cameras tell me this during runtime: “Unity MSAA is requested by the camera but not enabled in quality settings.” All of the cameras are set to use quality settings. By default all quality settings are forward rendering. Isn’t forward rendering what MSAA works with?

From what I can tell there is no possible way to use anti-aliasing in unity due to this. What am I doing wrong?

Personally I’m not getting jagged lines and have no reason to use anti-aliasing on my system, but I’m reasoning that not everyone has a system as good as mine so I need to give users the ability to change the anti-aliasing settings as they see fit.

QualitySettings.antiAliasing actually takes the number of samples (0, 2, 4, 8) not an enumeration of the values. This is why you get 2x when entering 3, as 3(unsupported) is less than 4(supported), just like you suspect.

1 Like

Oh now it makes sense. Thank you so much. That solved both the settings issue and the camera warning issue which was apparently coming from setting it to an unsupported number.