$lightmap
$lightmap
is a material shader parameter available in 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-based vertex 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 and skin).
- VRAD has a
-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. - For already-compiled maps, the lightmaps are stored as PPL files. These can be converted to VTF using Ficool2's proptexelvtf.exe (direct download).
$lightmap
is used to manually define lightmaps for a prop_static
, it may be necessary to disable vertex lighting for the prop (disablevertexlighting
) to prevent VRAD from wasting time calculating lighting for the prop and generating a VHV file that will ultimately go unused and waste space.
VMT syntax
$lightmap <texture>
Limitations and caveats
VRAD cannot create lightmaps for UVs outside of the 0-1 UV space.
Additionally, shadows may appear on UV seams; this is more noticeable on lower-resolution lightmaps.
$lightmap
in the VMT of the VertexLitGeneric material (can be obtained using -dumppropmaps
in VRAD).
- Define a pre-baked RGBA16161616f
$lightmap
in the VMT of the VertexLitGeneric material. A custom-coded compiler would be required to this accurately. - Increase lightmap resolution (results may vary).
- Move light source further away from the lit surface.
$bumpmap
parameter is defined for a material, a custom shader cannot simply use both as there are a dozen technicalities that have to be overcome.
If This in-engine check also exists for $phong, however getting around the issue is more tricky. The default value of the integer parameter will be 0 even if not set in the vmt. Thus making $phong always be defined in a way. |
See also
Modulate
- A shader that can be used to fake lightmaps or vertex coloring in all Source engine branches. It can bypass some of the limitations of$lightmap
, but requires additional setup to look convincing.