Alphatexture: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(mapbase 7.4 isn't out yet, and the compiled builds of the tools are a bit behind, so not marking it as "in mapbase" yet)
Line 3: Line 3:


{{tip|As this parameter is only used by VRAD, the VTF mentioned does not need to be shipped with the map if it is unused elsewhere.}}
{{tip|As this parameter is only used by VRAD, the VTF mentioned does not need to be shipped with the map if it is unused elsewhere.}}
{{codenote|See [https://github.com/ValveSoftware/source-sdk-2013/pull/1150 this GitHub PR] for how to add this to a custom VRAD.}}
{{codenote|See [https://github.com/ValveSoftware/source-sdk-2013/pull/1150 this GitHub PR] for how to add this to a custom VRAD.<br>The source code for {{Mapbase|2}} 7.4 includes this implementation.}}


== Syntax ==
== Syntax ==

Revision as of 10:53, 1 June 2025

%alphatexture is an internal material shader parameter available in Garry's Mod 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.

Tip.pngTip:As this parameter is only used by VRAD, the VTF mentioned does not need to be shipped with the map if it is unused elsewhere.
Cpp.pngCode:See this GitHub PR for how to add this to a custom VRAD.
The source code for Mapbase Mapbase 7.4 includes this implementation.

Syntax

"VertexLitGeneric"
{
    $basetexture "models/props_custom/myprop_base"
    %alphatexture "models/props_custom/myprop_alpha"
}

Potential usecases

%alphatexture is most useful for materials that are translucent enough for light to pass through, but are opaque to the human eye. Common materials that would exhibit this behavior are:

  • Foliage such as leaves and grass
  • Curtains, awnings, and umbrellas
  • Paper

This parameter can be useful in certain other niche instances:

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: Left 4 Dead 2 Portal 2), 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.