Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
Likely it just came along with the pixel art style. –  Byte56 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. –  Byte56 Jan 22 '13 at 0:45

2 Answers 2

up vote 8 down vote accepted

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.

share|improve this answer
    
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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.