$distancealpha: Difference between revisions
TomEdwards (talk | contribs) mNo edit summary |
m (Added one note.) |
||
Line 1: | Line 1: | ||
{{stub}} | {{stub}} | ||
Another new OB feature: distance alpha. [http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf See this PDF] for a high-level explanation of what all this stuff does. The article doesn't mention it's most useful application, oddly: foliage. | Another new OB feature: distance alpha. [http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf See this PDF] for a high-level explanation of what all this stuff does. The article doesn't mention it's most useful application, oddly: foliage. (Actually, it does. But only once, and it's quite easy to miss.) | ||
;Advantages | ;Advantages |
Revision as of 09:32, 19 November 2008
Another new OB feature: distance alpha. See this PDF for a high-level explanation of what all this stuff does. The article doesn't mention it's most useful application, oddly: foliage. (Actually, it does. But only once, and it's quite easy to miss.)
- Advantages
- Takes advantage of 3D texture filtering technology to be as fast (or almost as fast as) vector graphics, without the need for Valve to create an entirely new vector rendering path prone to bugs
- Can be used on raster images - faster than adaptive AA.
- Disadvantages
- Distance alpha effects look extremely pixellated from grazing angles in some situations (might be related to brush application).

Texture creation
Distance alpha source textures are created at a very high resolution. Valve use 4096x4096 images, but the SDK's build of VTEX will crash if you pass it anything over 2048x2048. The image should otherwise be completely normal, except that the alpha channel should avoid gradients (as they will be created by the shader and during the texture's compile).
To compile the texture you must use VTEX; third party tools don't support distance alpha yet. Your .txt file should look something like this:
// Enable distance alpha compiling alphatodistance 1 // Scale the image down to 1/nth its original size. '8' takes 2048 down to 256 reduce 8 // Size of 'spread' zone between alpha values of 0 and 1. This is the area the shader works with. // Bear in mind that higher numbers exponentially increase texture compile time! distancespread 4 // To prevent artefacting: nomip 1 nolod 1 nocompress 1
Material creation (class_spy_outline)

This material is displayed by Team Fortress 2 when a spy player gains or loses a disguise. Despite the fact that it fills the entire screen at any resolution, its texture (right) is only 256 pixels square.
It can scale to high resolutions thanks to the Valve's new method of alpha testing, wherein threshold alpha values are used to construct smooth lines on the video card regardless of resolution.
UnlitGeneric { $basetexture hud\class_spy_outline $translucent 1 $distancealpha 1 $softedges 1 $edgesoftnessstart .5 $edgesoftnessend .46 $scaleedgesoftnessbasedonscreenres 1 $glow 1 $glowcolor "[0 0 0]" $glowalpha .4 $glowstart .1 $glowend .5 //$glowx .98 //$glowy .98 $vertexcolor 1 $vertexalpha 1 $no_fullbright 1 $ignorez 1 }
Note in the above material how $edgesoftnessstart
has the same value as $glowend
. The glow effect is used for parts of the material above 50% opacity, while soft edges are created for parts below.