Anti-aliasing

From Valve Developer Community
(Redirected from MSAA)
Jump to: navigation, search
English (en)Translate (Translate)
Comparison of no anti-aliasing and 8x MSAA. Click to enlarge

Anti-aliasing (AA) is a graphics technique extensively employed in Valve video games, such as those in the Half-Life series, as well as in other software applications developed by Valve, including Steam Steam and Source Filmmaker Source Filmmaker, etc. This technique is utilized to enhance the visual quality and reduce the jagged edges, or jaggies, that can appear in computer-generated imagery.

Computer monitors are essentially a large grid of squares that can be set to any color or brightness. As such, it is impossible to draw a perfectly straight line, because no matter how many squares there are, it will never be able to make a perfectly smooth diagonal. This creates a stair-step pattern that gets increasingly noticeable the lower the resolution is, which is often referred to in the video game world as "Aliasing". Wikipedia icon Spatial anti-aliasing, often referred to simply as anti-aliasing, is designed to combat the problems of aliasing. In simple terms, anti-aliasing is designed to smooth out that stair-step pattern in images and make them look less pixelated, while not changing the resolution of the final image.

While anti-aliasing is available on PC, it was often not supported on consoles until the release of Portal 2 (which uses MLAA on PlayStation 3), as traditional methods like MSAA are very expensive, compared to post-processing methods like FXAA/TAA/MLAA used in later games. In all Source 2007 games and above on Xbox 360, it uses software AA, which is not as effective as newer post-processing methods.

Overview

Traditional methods

SSAA

Wikipedia icon SuperSampling Anti-Aliasing, also known as Full Scene Anti-Aliasing (FSAA) in some games and often interchangeable with the term downscaling.

  • Technically when implemented correctly, these do differ in that downscaling applies to an entire frame buffer – 2D and 3D Elements, while SSAA/MSAA are techniques only applied internally to 3D elements. In some implementations this can result in a lesser performance impact and better compatibility.

Compared to MSAA, SSAA/FSAA produces the same result as MSAA, but completely reduced stair-step pattern in alpha textures. Additionally, ReShade depth buffer detection works with SSAA. However, despite it's very high-quality results, SSAA is very expensive when it comes to performance compared to MSAA, and SSAA is not available as an option in Source by default, but can be enabled below:

On NVIDIA graphics cards, it's implemented as OGSSAA (Ordered Grid Supersample Anti-Aliasing), and can only be enabled through third-party applications such as Pcgw icon.png Nvidia Profile Inspector, using the following modes: 2x1, 1x2, 2x2, 3x3, 4x4. OGSSAA also only supports Direct3D.

Icon-Important.pngImportant:If you are building cubemaps, enabling SSAA (or OGSSAA/downscaling) will cause cubemaps (especially HDR cubemaps) to be built very slowly (even on powerful GPUs). Make sure SSAA (or OGSSAA) is disabled before building cubemaps. Other AA methods such as MSAA are not affected by this.

Downscaling

Downscaling or downsampling is a brute-force method for AA, which applies SSAA to both 2D (such as HUD and UI) and 3D elements by running the game at a higher resolution. It can be enabled on graphics card control panel as NVIDIA DSR or AMD VSR. Unlike SSAA, downscaling will produce blurrier results and does not get rid of the shimmering effect on transparent textures/objects.

Another downside to downscaling is that many older games' UI (such as VGUI used in Half-Life 2) will become smaller at higher resolutions.

MSAA

Wikipedia icon MultiSample Anti-Aliasing (MSAA) was the gaming industry standard of anti-aliasing (prior to the TAA gradually replacing MSAA in mid-late 2010s as games transitioned from forward rendering to deferred rendering), and as such is the only anti-aliasing available (alongside CSAA on NVIDIA cards prior to Maxwell) in all Source Source games before Counter-Strike: Global Offensive Counter-Strike: Global Offensive, and later available in GoldSrc GoldSrc in 2013, with only MSAA 4x being available, which is enabled by default. In GoldSrc GoldSrc, the anti-aliasing can be disabled by starting with the -nomsaa launch option. Essentially, if a polygon is crossing a multisample point, or subpixel, it detects how many of its neighboring points are also being intersected, then takes the color of that polygon and adds it over the existing image to create a slightly smother line. This creates a smoother line, but does not completely remove the stair-step pattern (especially on alpha textures that don't use alpha to coverage) without combining FXAA/SMAA/other post-FX AA methods with MSAA, plus games that use deferred rendering and MSAA may not work properly and can cause various other issues. This is usually sufficient for most users, however.

All GoldSrc, Source and Source 2 games contain 3 different settings of MSAA, which include:

  • 2x
  • 4x - Default level in post-SteamPipe GoldSrc GoldSrc (can be enhanced in GPU control panels)
  • 8x - Very expensive on older/low-end hardware. Introduced in Source 2006. You can enable 8x MSAA in Source 2004 by using the mat_antialias 8 console command, or force it through driver settings.[1]

What this does is add more subpixels to a specified location and increases the accuracy of the multisampling, at the cost of performance. Some alternative anti-aliasing methods such as the post-processing one will be less demanding compared to MSAA or other methods.

Warning.pngWarning:If MSAA is enabled, ReShade depth buffer detection will stop working, which means that you are unable to use some AA methods, for example (such as some versions of TAA), or even shaders such as SSAO in general.
Note.pngNote:Previous version of engine branch, Source 2004 Source 2004, has an option for MSAA 6x. This setting of MSAA does not work on modern graphics cards or newer drivers, and was replaced by MSAA 8x.
Note.pngNote:alpha to coverage requires MSAA, as it is a multisampling method. Alternatively, SSAA can be used instead to reduce jagged edges on alpha textures and objects.

CSAA[Obsolete-notext.png Deprecated] Nvidia

Coverage Sampling Anti-Aliasing (CSAA) was an NVIDIA-exclusive method of anti-aliasing, introduced with the GeForce 8 Series. It aims to further reduce the additional stress that MSAA puts on the system, with NVIDIA claiming that a CSAA-rendered image will rival 8x-16x MSAA while only putting a load on the system comparable to 4x MSAA. It does this by reducing the number of settings each sample determines (by creating a new sample for coverage) while increasing the overall number of samples.

However, by the release of Maxwell-based GPUs such as GTX 750 Ti, GTX 800M/900 series in 2014, and newer NVIDIA graphics card (or drivers released around Feb 2014 onwards which affects GeForce 400 series card and above) drops support for CSAA completely, and Multi-Frame Anti-Aliasing (MFAA) completely succeeded it, with limitations such as disabling D3D11 Driver Command Lists, killing multi-threaded rendering in DX11 Source games (and thus performance when CPU-limited), and FPS lower than 40 will cause smearing and blurring when in motion (similar to TAA).

Source Source natively support CSAA since Source 2007 Source 2007. Support for CSAA was broken on some newer NVIDIA GPUs starting with GeForce 400 series (or Maxwell and newer NVIDIA cards) with new driver update, or Source 2013 Source 2013 update.[2]

There are 3 different settings of CSAA, which include:

  • 8x (MSAA 4x performance)
  • 16x (MSAA 4x performance)
  • 16xQ (MSAA 8x performance)
Note.pngNote:CSAA 8xQ is MSAA 8x.

Post-processing methods

Software AA

(in all games since Source 2007) All Source engine games since Source 2007 introduced software AA, which blurs the jagged edges (similar to FXAA or other post-processing AA). It currently only works on Source 2007 games (tested on Black Mesa 2012/mod version). Software AA is also supported (and used) in Xbox 360 port of Source engine games.

Icon-Bug.pngBug:Software AA is currently broken in all Source 2009, Source 2013 games. It is also broken (or non-functional) in Left 4 Dead engine branch[3] and above.
This bug does not apply to console port, however (confirmed on Postal III cancelled Xbox 360 port which run on Source 2009).  (tested in: Half-Life 2, Portal, Left 4 Dead engine branch, Portal 2 engine branch, Source SDK Base 2013.)

FXAA

Wikipedia icon Fast Approximate Anti-Aliasing (FXAA) is a post-processing anti-aliasing with a low performance cost. The main advantage of this technique over regular anti-aliasing is that it doesn't require a lot of computing power, and is also capable of smoothing out alpha-blended textures (aka transparent textures). Its main drawback is that it blurs the final image, so textures will look less sharp, and plus, they don't recover the missing pixel (or alpha to coverage) without using FXAA with MSAA simultaneously (or by downscaling). Regular Source Source (prior to CS:GO engine branch CS:GO engine branch, or in third-party engine branch such as Xengine Xengine) doesn't have support for it but as FXAA is a post-processing effect, it can easily be implemented like with the Source shader editor or with ReShade.

Icon-Important.pngImportant:Using ReShade for multiplayer games and connecting to a VAC-secured server is not recommended.
Additionally, using ReShade on Counter-Strike: Global Offensive and Counter-Strike 2 requires the -allow_third_party_software and -insecure command-line options, which would prevent you from connecting to any VAC-secured server.

MLAA

Wikipedia icon Morphological Anti-Aliasing (MLAA) is a post-processing anti-aliasing typically available on AMD cards, but it can be used with any other graphics card. It's similar to NVIDIA's FXAA but has a higher performance cost, but is less demanding compared to MSAA. It's used in PlayStation 3 PlayStation 3 version of Portal 2.

Confirm:What about Counter-Strike: Global Offensive Counter-Strike: Global Offensive on PS3?

SMAA

Subpixel Morphological Anti-Aliasing (SMAA) works similarly to FXAA or MLAA (which is what SMAA was based off), but results in much better image quality than both FXAA and MLAA, while also taking little performance impact. There are currently no GoldSrc, Source or Source 2 games using this AA method, but users can add SMAA by using ReShade or Source Shader Editor.

Temporal methods

TAA/TSSAA

Wikipedia icon Temporal Anti Aliasing (TAA) is an anti-aliasing technique that reduces shimmering or flickering effects by smoothing the frame when in motion. There are multiple implementations of TAA, but the most common one is TSSAA (Temporal Super-Sampling Anti-Aliasing) which combines information from past frames (usually 8 frames) and the current frame, while also slightly jittering to smooth the current frame. Each pixel is sampled once per frame but in each frame the sample is at a different location within the pixel. Pixels sampled in past frames are blended with pixels sampled in the current frame to produce an anti-aliased image. While being cheaper to calculate than MSAA, and produces image similar to super sampling anti-aliasing (SSAA) or downscaling, its main drawback is that it can cause ghosting and blurriness to the image, especially when in motion, noticeable with lower framerate or resolution, depending on the implementation (Example here). Some of the drawbacks can be mitigated by adding a sharpening filter.

As of mid 2010s, it's the current gaming industry standard of anti-aliasing (alongside FXAA for weaker hardware) with many modern games (except many VR and mobile games) started to use TAA as most modern games transitioned from forward rendering to deferred rendering, which allows many lights to be rendered without a significant performance hit.

Apex Legends Apex Legends as well as Titanfall 2 Titanfall 2 are the only Source games that uses TSSAA, while Titanfall uses TXAA which requires MSAA to function. Portal with RTX and all other RTX Remix games also use TSSAA anti-aliasing, through DLSS (or DLAA). One upcoming Source 2 game made by Valve, Deadlock, supports TAA through AMD FSR2. Both DLSS, XeSS and FSR 2.0 (and later) not only apply TAA anti-aliasing (using AI/Tensor Cores), but also improve performance by rendering the image at lower resolutions then scaling to higher resolutions.

TXAA

TXAA is an older form of TAA that creates a smoother, clearer image than any other anti-aliasing solution by combining MSAA with Nvidia Nvidia-designed temporal filters. TXAA can result in much sharper image quality compared to TAA, depending on the implementation in some games. TXAA is supported with Nvidia GeForce GTX 600 series or higher, and requires MSAA to be enabled in order to use.

CMAA

Wikipedia icon Conservative Morphological Anti- Aliasing (CMAA) is an image-based post-processing technique originally developed by Filip Strugar at Intel. CMAA uses 4 main steps to reduce aliasing:

  • Color break detection
  • Locally dominant edge detection
  • Simple shape handling
  • Symmetrical long edge shape handling.

CMAA, while having slight performance impact compared to FXAA, but still has less performance impact than SMAA, CMAA manages high quality anti-aliasing while preserving text and without over blurring the geometry.

CMAA is currently only implemented in Counter-Strike 2 Counter-Strike 2.

Note.pngNote:When Counter-Strike: Global Offensive Counter-Strike: Global Offensive got ported to Source 2 Source 2 (and renamed to Counter-Strike 2 Counter-Strike 2), (FXAA) support was removed and (CMAA) was implemented in its place, with the ability to use it alongside MSAA removed.

Media

Tip.pngTip:Click on one of the images below, after it's fully loaded, click on it again to view it in full resolution.

GoldSrc

FXAA (through ReShade)
SMAA (through ReShade)
4x MSAA (default)
No MSAA

Source

No anti-aliasing
2x MSAA
4x MSAA
8x MSAA
FXAA through the Source shader editor

Software AA

No anti-aliasing
Software AA - Strength 1 (mat_software_aa_strength 1)
Software AA - Strength 4 (mat_software_aa_strength 4)

Black Mesa

No anti-aliasing (Click to enlarge)
2x MSAA (Click to enlarge)
4x MSAA (Click to enlarge)
8x MSAA (Click to enlarge)
FXAA through ReShade (Click to enlarge)
FXAA through ReShade, in conjunction with 8x MSAA.
This produces a very good result without downscaling/SSAA which reduces performance, but at the cost of making the image blurrier, unless a sharpening filter is also used. It's also the default AA settings in CS:GO when launching for the first time.
SMAA through ReShade (Click to enlarge)
SMAA through ReShade, in conjunction with 8x MSAA. (Click to enlarge)
Similar to FXAA with 8x MSAA, except less blurrier image.
SSAA 4x4 (Click to enlarge)
Best possible result, with the jagged edges on the towers completely gone, at the cost of performance.
16xS (SSAA 2x2 & MSAA 4X) (Click to enlarge)
Similar to SSAA 4x4, although less demanding.

Titanfall 2

No anti-aliasing (Click to enlarge)
2x MSAA (Click to enlarge)
4x MSAA (Click to enlarge)
8x MSAA (Click to enlarge)
TAA/TSSAA (Click to enlarge)

Source 2

Todo: Add screenshots.

Support

GoldSrc GoldSrc

Game FXAA MSAA TAA
Half-Life Half-Life
Half-Life: Opposing Force Half-Life: Opposing Force
Half-Life: Blue Shift Half-Life: Blue Shift
Counter-Strike Counter-Strike
Day of Defeat Day of Defeat
Ricochet Ricochet
Team Fortress Classic Team Fortress Classic
Deathmatch Classic Deathmatch Classic
Counter-Strike: Condition Zero Counter-Strike: Condition Zero
Condition Zero Deleted Scenes Condition Zero Deleted Scenes
No Yes (since 2013 engine update, 4X only) No
James Bond 007: Nightfire James Bond 007: Nightfire No Yes
(up to 8X)
No

Source Source

Game FXAA MSAA CSAA (NVIDIA) EQAA (AMD) MLAA TAA Software AA
(in all games since Source 2007)
Source 2004 Source 2004
Source 2006 Source 2006
No Yes No No No No N/A
Source 2007 Source 2007 No Yes Older NVIDIA GPUs/drivers only Unknown No No Always enabled Xbox 360
Disabled by default (PC)
Source 2009 Source 2009/Source Multiplayer Source Multiplayer
Source 2013 Source 2013
Alien Swarm engine branch Alien Swarm engine branch
Alien Swarm: Reactive Drop Alien Swarm: Reactive Drop
Left 4 Dead engine branch Left 4 Dead engine branch
No Yes Older NVIDIA GPUs/drivers only Unknown No No Always enabled Xbox 360
Broken/Non-functional (PC)
Black Mesa Black Mesa Yes Removed (post-Xen update)
Available on previous versions (2012 mod/pre-Xen)
No No No No Non-functional
CS:GO engine branch CS:GO engine branch Yes Yes No No Unknown on PS3 No Non-functional
Dota 2 Dota 2 (pre-Reborn) Yes Can be enabled through console,
but breaks deferred renderer
No No N/A No Possibly non-functional
Portal 2 engine branch Portal 2 engine branch
Portal 2: Desolation Portal 2: Desolation[confirm]
No Yes No No Yes (PlayStation 3 only) No Non-functional
Strata Source Strata Source Yes Yes No No No No Possibly non-functional
Titanfall Titanfall No Yes Older NVIDIA GPUs/drivers only Yes No Yes (TXAA) No
Titanfall 2 Titanfall 2 No Yes Unknown, possibly might work (see above) Yes No Yes (TSSAA) No
Apex Legends Apex Legends No No No No No Yes (TSSAA) No
Portal with RTX Portal with RTX (and other RTX Remix games) No No No No No Yes (DLSS/DLAA) No

Source 2 Source 2

Game FXAA MSAA TAA CMAA
Deadlock Deadlock Yes No Yes (FSR2) No
Counter-Strike 2 Counter-Strike 2 No Yes No Yes
Half-Life: Alyx Half-Life: Alyx No Always enabled (MSAA 4X) No No
S&box S&box No Yes No No
Dota 2 Dota 2 Yes No No No

Performance impact

Note.pngNote:All performance test below were done on an NVIDIA GeForce RTX 3060, running with uncapped FPS (Source games are capped at 300 by default), highest possible graphical settings, VSync disabled.

Below is the performance impact of each AA method. Most modern mid-range and high-end GPUs are capable of 8x MSAA with no performance loss, and over 60-100 FPS in Source games, as they are capped at 300 FPS by default.

Game None FXAA SMAA MSAA SSAA TAA[4]
Half-Life 2: Lost Coast Half-Life 2: Lost Coast (benchmark) 569.23 Avg FPS 549.88 Avg FPS
(Negligible)
533.28 Avg FPS
(Very Low)
547.00 Avg FPS (2x)
(Low - Moderate)
520.89 Avg FPS (4x)
(Moderate)
475.34 Avg FPS (8x)
(Moderate - High)
409.26 Avg FPS (2x2)
(Very High)
329.32 Avg FPS (2x2 + MSAA 4X/SGSSAA)
(Very High)
147.74 Avg FPS (4x4)
(Very High)
TSSAA: Similar to SMAA or FXAA
TXAA: Similar as MSAA

Console commands

Source

MSAA / CSAA

Source 2013 Source 2013 games and older Source engine games have these console commands dedicated to anti-aliasing:

mat_antialias (0-8)
Goes from 0x to 8x MSAA.
Note.pngNote:This commands only accepts positive values, negative ones will do nothing. Also, if you're using Source 2006 Source 2006 or newer, or using newer GPUs with later drivers, 6x MSAA is not supported, so it will also do nothing!
This command also does nothing in Black Mesa (since Xen update) as MSAA has been removed. MSAA is still available on previous versions of Black Mesa.
On Source 2004 Source 2004 (which only supports up to 6x officially), 8x MSAA can be enabled by using this command, but once you quit the game, it will reset to 4x MSAA.
mat_aaquality (0-4)
It was used to set CSAA antia-liasing settings.
Warning.pngWarning:Ever since the release of Nvidia Nvidia's GTX 900 series cards (as well as GTX 750, 750Ti and other Maxwell-based cards) and newer, or with new drivers updates for GeForce 400 series card and later, support for CSAA has been removed! Therefore, this command does nothing!

Software AA

Note.pngNote:All Source engine games (since Source 2007) have software AA. It currently only works on Source 2007 games (Black Mesa 2012 version tested).

Software AA is also supported (and used) in Xbox 360 port of Source engine games.

Icon-Bug.pngBug:Software AA is currently broken in all Source 2013 games. It's also broken (or non-functional) in Left 4 Dead engine branch[3] and above.  (tested in: Half-Life 2, Portal, Left 4 Dead engine branch, Portal 2 engine branch, Source SDK Base 2013.)
mat_software_aa_blur_one_pixel_lines (0-1)
How much software AA should blur one-pixel thick lines: (0.0 - none), (1.0 - lots)
Default: 0.5
mat_software_aa_debug (0-3)
Software AA debug mode: (0 - off), (1 - show number of 'unlike' samples: 0->black, 1->red, 2->green, 3->blue), (2 - show anti-alias blend strength), (3 - show averaged 'unlike' colour)
Default: 0
mat_software_aa_edge_threshold (value)
Software AA - adjusts the sensitivity of the software AA shader's edge detection (default 1.0 - a lower value will soften more edges, a higher value will soften fewer)
Default: 1.0
mat_software_aa_quality (0-1)
Software AA quality mode: (0 - 5-tap filter), (1 - 9-tap filter)
Default: 0
mat_software_aa_strength (0-4)
Software AA - perform a software anti-aliasing post-process (an alternative/supplement to MSAA). This value sets the strength of the effect: (0.0 - off), (1.0 - full)
Note.pngNote:This can be set up to "4", but will cause dithering to be more visible around the edges.

Default: 0.0 (PC), 1.0 (Xbox 360)
mat_software_aa_strength_vgui (0-1)
Same as mat_software_aa_strength, but forced to this value when called by the post vgui AA pass.
Default: 1.0 (PC), 2.0 (Xbox 360)
mat_software_aa_tap_offset (value)
Software AA - adjusts the displacement of the taps used by the software AA shader (default 1.0 - a lower value will make the image sharper, higher will make it blurrier)
Default: 1.0

Source 2

Counter-Strike 2 Counter-Strike 2 only:

r_csgo_cmaa_enable (0-1)
Enable CMAA2.
r_csgo_cmaa_extra_sharp (0-1)
Enable sharpening when CMAA2 enabled.
Note.pngNote:Doesn't seems to have any noticeable differences.
r_csgo_cmaa_quality (0-3)
Adjust CMAA2 quality from Off, Low, Medium, and High.

See also

External links

References

References
1. User:leonidakarlach - (June 4, 2024). MSAA 8X can be enabled in Source 2004 using mat_antialias 8. And there was a difference. But once you quit the game, it will reset to MSAA 4X.
3. User:leonidakarlach - (October 18, 2024). In Left 4 Dead (and L4D2), all commands related to Software AA are hidden, but using SourceMod will allow you to access the commands.
4.
Note.pngNote:There are multiple variants of TAA. The most common one being used in many modern games (including Apex Legends and Titanfall engine branch games), which is TSSAA (also known as TMAA), which is also referred as TAA in general, supersamples the previous 8 frames, jittering them and combines into the current one to create smoother (but blurrier) image, it has performance impact similar to FXAA or SMAA. TXAA (Nvidia exclusive), on the other hand, combines MSAA with temporal filters which will have very similar performance impact as MSAA. TAAU and TSR, commonly found on Unreal Engine but also used in other games with different engine, aswell as upscaling solution (FSR2, FSR3, XeSS, DLSS), improves the game performance by running the game at lower resolution, then apply a temporal filter (TSSAA) to anti-alias the image, and sharpener (FSR or CAS) to make the image appeared sharper. Some other games also used a variant of FXAA or SMAA combined with temporal filter (FXAA 1TX, SMAA T2X, and so on.).