# Why are some games using some dithering pattern instead of traditional alpha for transparency?

Recently, I have seen some 3D games (eg: GTA IV) to use some kind of ordered dithering to simulate transparency / alpha.

The polygons are not transparent as usual, but instead render a dithering texture that gradually switch from left to right to simulate transparency :

The effect is not unpleasant but rather surprising to see at first (vs traditional alpha blending)

Except for the visual aesthetic effect it produce, is there any reason some games do this (better performance, saving bandwidth or any else i do not think about) ?

• Likely it just came along with the pixel art style. – MichaelHouse Jan 22 '13 at 0:37
• @Byte56 Pixel art style? GTA IV? Huh? – Nathan Reed Jan 22 '13 at 0:41
• @NathanReed Heh, not in GTA IV. OP mentions seeing it recently in games. – MichaelHouse Jan 22 '13 at 0:45
• I find the technique more pleasant than alpha blending when fading 3D-objects that are getting too close to the near plane. – Andreas Apr 11 '16 at 8:01

This is a fairly common approach to transparency in games that use deferred shading. Proper transparency doesn't work well at all with deferred shading, since only one surface's data (depth, normal vector, color, etc.) can be stored at each pixel, and proper transparency involves multiple surfaces overlapping at a pixel, each requiring independent lighting.

There are a few ways game engines can deal with this:

• Use forward shading (possibly with a reduced lighting model) for transparent surfaces, and deferred shading for the opaque surfaces. The transparent surfaces have to be drawn in a separate pass with back-to-front sorting.
• Use dithering, more commonly known as stippling or screen-door transparency, which works with deferred shading since it gives just one surface per pixel. This works particularly well for LOD transitions, since they usually finish in a fixed amount of time, limiting how long the stippling is visible. It doesn't work very well for, say, glass windows on a building.
• It's also possible to use stippling but then apply a post-process blur that recombines the stippled pixels, giving an approximation of proper transparency. Volition does this in Saints Row the Third (and perhaps some of their other games too), under the name of "inferred lighting". This can look quite nice, but the post-process blur is expensive.
• And of course, there are all the order-independent transparency methods out there, although I don't know of any game that uses them. They are just for tech demos so far.

One can also use a combination of these approaches, e.g. forward shading for glass windows and stippling for LOD transitions.

It's also worth noting that some games use stippling for soft shadows. This is a performance tradeoff; nicer shadows require more texture samples in the pixel shader, which takes longer, but you can get okay-looking results by using fewer samples and offsetting their positions randomly. The random offset produces the stippling effect.

• i didn't know about deferred shading technique (explained here: en.wikipedia.org/wiki/Deferred_shading). They also talk about possible alpha issues. Make sense now. Thanks for the answer – tigrou Jan 22 '13 at 8:46

It’s a simple performance trade-off. Alpha blending requires reading from the current colour buffer, whereas this kind of dithering is write-only (or discard-only, of course).

It is possible to mix this technique with multisampling, which is then called alpha to coverage.

• What kind of "performance trade-off" are you talking about? Early-Z gets turned off if you use a discard in your shader. Blending is done on the hardware and is fast. – Tara Aug 2 '18 at 3:10
• Actually I just tested it in my engine on a proper scene at a high resolution: Enabling vs disabling blending for ALL geometry resulted in no performance difference whatsoever. Nathan Reed's answer is correct, as dithering is usually used in deferred rendering. – Tara Aug 2 '18 at 3:19