Alphatexture: Difference between revisions
SirYodaJedi (talk | contribs) (Workaround, and another use case) |
SirYodaJedi (talk | contribs) (Force toc) |
||
Line 1: | Line 1: | ||
{{this is a|shader parameter|internal=1<!--is there a better way to do this?-->|name=%alphatexture|game=Garry's Mod}} | {{toc-right}}{{this is a|shader parameter|internal=1<!--is there a better way to do this?-->|name=%alphatexture|game=Garry's Mod}} | ||
Used on [[static prop]]s when the prop is flagged for [[texture shadows]] and compiling [[VRAD]] with {{code|-textureshadows}}. The alpha channel of the specified VTF will be used instead of {{ent|$basetexture}}, even if {{ent|$alphatest}} and {{ent|$translucent}} are absent. | Used on [[static prop]]s when the prop is flagged for [[texture shadows]] and compiling [[VRAD]] with {{code|-textureshadows}}. The alpha channel of the specified VTF will be used instead of {{ent|$basetexture}}, even if {{ent|$alphatest}} and {{ent|$translucent}} are absent. | ||
Revision as of 11:27, 9 April 2025
%alphatexture
is an internal material shader parameter available in Garry's Mod.
Used on static props when the prop is flagged for texture shadows and compiling VRAD with -textureshadows. The alpha channel of the specified VTF will be used instead of $basetexture, even if $alphatest and $translucent are absent.


Syntax
"VertexLitGeneric"
{
$basetexture "models/props_custom/myprop_base"
%alphatexture "models/props_custom/myprop_alpha"
}
Potential usecases
This parameter can be useful in certain niche instances:
- When $detailblendmode 4 is used, as the shadows would then make more sense to be cast from $detail
- When $additive is used, as no alpha channel will be present and neither $translucent nor $alphatest are used
- When a shader such as Refract is used, as no alpha channel will be present and neither $translucent nor $alphatest are used, and $basetexture won't be used as the diffuse
- If a shader such as Wireframe is used, as $basetexture will not be present
- When $alpha is used, as VRAD doesn't account for it
- For creating a sharp high-resolution texture shadow without bloating the map's filesize, as the shadow-casting texture does not need to be shipped with the map.
- Making the shadows for a given prop less dark by using an alpha texture with partial opacity, which can be useful if it uses $halflambert.
Workaround for other versions of VRAD
If mapping for a game that does not have an SDK that includes the source code to compile your own version of VRAD (ex:
), it is still possible to simulate the effect of %alphatexture by creating a separate $translucent material to use in VRAD only, and setting the alpha texture to that material's $basetexture. To avoid needing to swap VMTs every time the map is being compiled, the -insert_search_path parameter can be used with VRAD, which should take priority over the search paths declared in gameinfo.txt.