$lightmap
$lightmap
is a material shader parameter available on the
VertexLitGeneric
shader in the following Source games or engine branches:
Source 2013 Multiplayer and
Garry's Mod. It defines a lightmap to be used to light the MDL model's material, instead of the per-vertex lighting used by prop_static or point lighting used by other models.
This parameter does not usually need to be added manually, as VRAD will generate model lightmaps automatically if generatelightmaps is enabled for the prop_static and -StaticPropLighting is enabled in VRAD. Nonetheless, it can still be added manually, such as for using a lightmap on a prop_dynamic, or if a prop_static has multiple materials (as VRAD can only generate lightmaps for the first material.


-dumppropmaps
option, which will create external TGA versions of the generated static prop lightmaps which can be converted to VTF and manually defined as a $lightmap.

VMT syntax
$lightmap <texture>
Limitations and caveats



$lightmap
in the VMT of the VertexLitGeneric material.


- Define a pre-baked[How?] RGBA16f
$lightmap
in the VMT of the VertexLitGeneric material. - Increase lightmap resolution (results may vary).



If $bumpmap or $phong is defined, the engine will not send the lightmap data to the shader.
For $bumpmap, a workaround for this is to use a differently named parameter. ( $NormalTexture ) to get the normal map and undefining $bumpmap.
However no static lighting data can be received by the shader, if the $bumpmap parameter is not set to anything. This refers to lights that are not named and are not inherently dynamic.
This may be prefered as the static light information is ALREADY prebaked in the lightmap, however it means you cannot receive direction information from the lights.
No light direction means no bumped lighting from the lightmap. Aka no specular highlights.
A fix for this would be modifying VRAD to spit out a lightmap that is *2 the size on the U axis and then storing an average light direction there or doing some other smart technique to 'memorize' light directions.