$translucent: Difference between revisions
m (→Compatibility with other effects: Changed unnecessary underscores into spaces) |
Kestrelguy (talk | contribs) m (added language bar. also some formatting.) |
||
Line 1: | Line 1: | ||
{{lang|$translucent}} | |||
{{toc-right}} | {{toc-right}} | ||
Line 5: | Line 6: | ||
Any object that has a <code>$translucent</code> material does not affect [[VIS]], and can be seen through by NPCs from any angle. | Any object that has a <code>$translucent</code> material does not affect [[VIS]], and can be seen through by NPCs from any angle. | ||
{{note|Enabling translucency will completely disable shadows made by [[env_projectedtexture| | {{note|Enabling translucency will completely disable shadows made by [[env_projectedtexture|projected textures]] for the texture. Either separate the opaque and solid parts of the texture, or use {{ent|$alphatest}} instead.}} | ||
==VMT | ==VMT Syntax Example== | ||
$translucent <[[Boolean|bool]]> | $translucent <[[Boolean|bool]]> | ||
Line 16: | Line 17: | ||
} | } | ||
==Additional | ==Additional Parameters== | ||
{{MatParam|$additive|bool|Add the material's colour values to the existing image, instead of performing a multiplication. This means, among other things, that the material will always brighten the world. This is useful for effects like volumetric dust, light sprites, etc...}} | {{MatParam|$additive|bool|Add the material's colour values to the existing image, instead of performing a multiplication. This means, among other things, that the material will always brighten the world. This is useful for effects like volumetric dust, light sprites, etc...}} | ||
==Caveats== | ==Caveats== | ||
===Flickering and | ===Flickering and Reversed Depth=== | ||
Translucency can sometimes cause a material to flicker, or cause sorting issues with nearby surfaces. In both cases consider using '''<code>$alphatest</code>''' instead of <code>$translucent</code> when this happens. It drastically lowers quality, but will usually resolve the issue and is much faster to draw. It will also cast flashlight shadows, unlike translucents. | Translucency can sometimes cause a material to flicker, or cause sorting issues with nearby surfaces. In both cases consider using '''<code>$alphatest</code>''' instead of <code>$translucent</code> when this happens. It drastically lowers quality, but will usually resolve the issue and is much faster to draw. It will also cast flashlight shadows, unlike translucents. | ||
Line 27: | Line 28: | ||
Unlike <code>'''$translucent'''</code> which allows for varying degrees of opacity, alpha testing does | Unlike <code>'''$translucent'''</code>, which allows for varying degrees of opacity, alpha testing does not—portions of your texture are either 'on' or 'off'. <code>'''$alphatestreference'''</code>, a normal parameter, controls the filtering of the transparency masking (Using lower values like .01 will result in a more blurred edge while a value of .99 will be extremely sharp.) Since alpha-testing is cheaper than <code>$translucent</code>, this can be used to achieve a similar effect to materials using the <code>$translucent</code> parameter at reduced cost. Using <code>'''$allowAlphaToCoverage'''</code> will enable antialiasing of alpha-tested textures, giving them much softer edges. When <code>'''$allowAlphaToCoverage'''</code> is enabled, <code>'''$alphatestreference'''</code> is ignored and will not affect the texture's appearance, though it will still affect projected texture stenciling (e.g. the flashlight). | ||
{{note|The effect of <code>'''$allowAlphaToCoverage'''</code> will only be visible if the user has MSAA enabled.}} | {{note|The effect of <code>'''$allowAlphaToCoverage'''</code> will only be visible if the user has MSAA enabled.}} | ||
===Compatibility | ===Compatibility With Other Effects=== | ||
Certain shader parameters (such as {{ent|$envmap}}) disable translucency. If you are having trouble getting it to work, try commenting out other parts of the material. | Certain shader parameters (such as {{ent|$envmap}}) disable translucency. If you are having trouble getting it to work, try commenting out other parts of the material. | ||
{{note|{{Game name|csgo|name=Counter-Strike: Global Offensive}} and {{Game name|GMOD|name=Garry's Mod}} support $envmap with translucency.}} | {{note|{{Game name|csgo|name=Counter-Strike: Global Offensive}} and {{Game name|GMOD|name=Garry's Mod}} support <code>$envmap</code> with translucency.}} | ||
===Filtering | ===Filtering Borders=== | ||
[[Wikipedia:Texture filtering|Texture filtering]] will blend nearby pixels together even if some of of them are entirely transparent. This can create unwanted outlining effects if sudden drop-offs in alpha coincide with drop-offs in colour, which may well happen when the [[alpha channel]] reaches zero and you stop being able to see the pixels. | [[Wikipedia:Texture filtering|Texture filtering]] will blend nearby pixels together even if some of of them are entirely transparent. This can create unwanted outlining effects if sudden drop-offs in alpha coincide with drop-offs in colour, which may well happen when the [[alpha channel]] reaches zero and you stop being able to see the pixels. | ||
Line 50: | Line 51: | ||
==See also== | ==See also== | ||
* | *{{ent|$alpha}}, for texture-wide translucency | ||
* | *{{ent|$distancealpha}}, for vector-like alpha edges | ||
* | *{{ent|$vertexalpha}} | ||
* | *{{ent|$alphatest}}, for binary opacity. | ||
[[Category:List of Shader Parameters|T]] | [[Category:List of Shader Parameters|T]] |
Revision as of 19:41, 28 April 2022
Template:Shaderparam It specifies that the material should be partially see-through. The alpha channel of the $basetexture is used to decide translucency per-pixel.
Any object that has a $translucent
material does not affect VIS, and can be seen through by NPCs from any angle.

VMT Syntax Example
$translucent <bool>
LightmappedGeneric { $basetexture glass\window001a $translucent 1 }
Additional Parameters
Caveats
Flickering and Reversed Depth
Translucency can sometimes cause a material to flicker, or cause sorting issues with nearby surfaces. In both cases consider using $alphatest
instead of $translucent
when this happens. It drastically lowers quality, but will usually resolve the issue and is much faster to draw. It will also cast flashlight shadows, unlike translucents.
Unlike $translucent
, which allows for varying degrees of opacity, alpha testing does not—portions of your texture are either 'on' or 'off'. $alphatestreference
, a normal parameter, controls the filtering of the transparency masking (Using lower values like .01 will result in a more blurred edge while a value of .99 will be extremely sharp.) Since alpha-testing is cheaper than $translucent
, this can be used to achieve a similar effect to materials using the $translucent
parameter at reduced cost. Using $allowAlphaToCoverage
will enable antialiasing of alpha-tested textures, giving them much softer edges. When $allowAlphaToCoverage
is enabled, $alphatestreference
is ignored and will not affect the texture's appearance, though it will still affect projected texture stenciling (e.g. the flashlight).

$allowAlphaToCoverage
will only be visible if the user has MSAA enabled.Compatibility With Other Effects
Certain shader parameters (such as $envmap) disable translucency. If you are having trouble getting it to work, try commenting out other parts of the material.

$envmap
with translucency.Filtering Borders
Texture filtering will blend nearby pixels together even if some of of them are entirely transparent. This can create unwanted outlining effects if sudden drop-offs in alpha coincide with drop-offs in colour, which may well happen when the alpha channel reaches zero and you stop being able to see the pixels.
To resolve this issue, simply blend the colours of your image slightly beyond where the alpha channel drops off. This can be easily achieved by duplicating the translucent layer and smudging it into the relevant areas.
(For users of older versions of The GIMP, the program will automatically remove colour information for pixels with an alpha of zero whenever layers are combined. As a work-around for this, you could give those pixels an alpha value of one instead.
As of GIMP 2.8.14, pixels with an alpha value of 0 retain their color information when saved as a tga.
See also
- $alpha, for texture-wide translucency
- $distancealpha, for vector-like alpha edges
- $vertexalpha
- $alphatest, for binary opacity.