Difference between revisions of "Translucency"

From DoomWiki.org

[unchecked revision][unchecked revision]
m (tinttab link)
m
Line 2: Line 2:
  
 
Doom, however, uses 8-bit color, and thus other methods must be used to calculate translucency color blending. The [[Boom]] [[source port]] implemented translucency using a precalculated lookup table. Each color is multiplied by the user's translucency percentage and then blended with all other colors in the palette in turn. The result of each computation is matched to the closest color in the palette and is stored in a way that allows a simple array index to be computed from the foreground and background colors while drawing graphics. While very fast as far as translucency routines are concerned, the results are not memory friendly: each "TRANMAP" held in memory consumes more than 65 Kilobytes of [[Wikipedia:Random access memory|RAM]].
 
Doom, however, uses 8-bit color, and thus other methods must be used to calculate translucency color blending. The [[Boom]] [[source port]] implemented translucency using a precalculated lookup table. Each color is multiplied by the user's translucency percentage and then blended with all other colors in the palette in turn. The result of each computation is matched to the closest color in the palette and is stored in a way that allows a simple array index to be computed from the foreground and background colors while drawing graphics. While very fast as far as translucency routines are concerned, the results are not memory friendly: each "TRANMAP" held in memory consumes more than 65 Kilobytes of [[Wikipedia:Random access memory|RAM]].
 +
 +
[[Image:Translucent.png|160px|A translucent [[Golem]] from [[Heretic]].]]
  
 
The [[DosDoom]] port uses a different method that uses less precision and only precalculates part of the blending operation. The rest of the operation is done on a custom packed color format in low-precision math with the aid of lookup tables. This allows a wide range of translucency levels at a fraction of the amount of memory that would be used by the Boom method for comparable results. This method has also found its way into the [[ZDoom]] and [[Eternity Engine]] source ports, where it is used to great effect for [[particles]]. The cost for this method is in speed, as it is quite a bit slower.  
 
The [[DosDoom]] port uses a different method that uses less precision and only precalculates part of the blending operation. The rest of the operation is done on a custom packed color format in low-precision math with the aid of lookup tables. This allows a wide range of translucency levels at a fraction of the amount of memory that would be used by the Boom method for comparable results. This method has also found its way into the [[ZDoom]] and [[Eternity Engine]] source ports, where it is used to great effect for [[particles]]. The cost for this method is in speed, as it is quite a bit slower.  

Revision as of 05:37, 18 September 2006

Translucency is a measure of an object's transparency. There are several methods of achieving translucency with computer graphics; the most popular is alpha blending. When using 32-bit color, only 24 bits are needed for the actual color data. The other 8 bits can be used as an alpha channel. As such, there are 256 possible translucency values. This can range from completely transparent to completely solid.

Doom, however, uses 8-bit color, and thus other methods must be used to calculate translucency color blending. The Boom source port implemented translucency using a precalculated lookup table. Each color is multiplied by the user's translucency percentage and then blended with all other colors in the palette in turn. The result of each computation is matched to the closest color in the palette and is stored in a way that allows a simple array index to be computed from the foreground and background colors while drawing graphics. While very fast as far as translucency routines are concerned, the results are not memory friendly: each "TRANMAP" held in memory consumes more than 65 Kilobytes of RAM.

A translucent Golem from Heretic.

The DosDoom port uses a different method that uses less precision and only precalculates part of the blending operation. The rest of the operation is done on a custom packed color format in low-precision math with the aid of lookup tables. This allows a wide range of translucency levels at a fraction of the amount of memory that would be used by the Boom method for comparable results. This method has also found its way into the ZDoom and Eternity Engine source ports, where it is used to great effect for particles. The cost for this method is in speed, as it is quite a bit slower.

Small adjustments to this latter method can yield other effects, such as additive translucency. Instead of adding together foreground * percentage and background * (100-percentage), the raw color values are added directly with equal weighting, capping each color component to the maximum of 255. This causes the foreground object to appear bright and hot, as if though it gives off its own light.

Raven Software's Heretic and Hexen also supported translucency using precalculated lookup tables similar in nature to those used by Boom. Most source ports do not support Raven's original method, however, and use their own pre-existing methods instead.