27
\$\begingroup\$

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 :

enter image description here

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) ?

I have searched on the web but cannot found anything about this technique.

\$\endgroup\$
5
  • \$\begingroup\$ Likely it just came along with the pixel art style. \$\endgroup\$
    – House
    Commented Jan 22, 2013 at 0:37
  • \$\begingroup\$ @Byte56 Pixel art style? GTA IV? Huh? \$\endgroup\$ Commented Jan 22, 2013 at 0:41
  • \$\begingroup\$ @NathanReed Heh, not in GTA IV. OP mentions seeing it recently in games. \$\endgroup\$
    – House
    Commented Jan 22, 2013 at 0:45
  • 1
    \$\begingroup\$ I find the technique more pleasant than alpha blending when fading 3D-objects that are getting too close to the near plane. \$\endgroup\$
    – Andreas
    Commented Apr 11, 2016 at 8:01
  • \$\begingroup\$ Blending requires rendering from back to front for correct results. Discard dithering by alpha does not (it just uses the z buffer), and this is a big advantage. When combined with MSAA and blurring methods now employed in all games very pleasant results may be obtained. \$\endgroup\$
    – Tronic
    Commented Jul 24, 2021 at 11:24

2 Answers 2

30
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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 \$\endgroup\$
    – tigrou
    Commented Jan 22, 2013 at 8:46
0
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$
    – Tara
    Commented Aug 2, 2018 at 3:10
  • \$\begingroup\$ 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. \$\endgroup\$
    – Tara
    Commented Aug 2, 2018 at 3:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .