$lod
(Redirected from $shadowlod)
Jump to navigation
Jump to search
![English (en) English (en)](/w/images/3/37/Flag-en.png)
![Translate (Translate) Translate (Translate)](/w/images/a/a8/Flag-Translate.png)
$lod
is a QC command available in all Source games.
It is also available in Half-Life (PS2). It is a QC command describing how to reduce the level of detail when rendering the model at a given size. It handles the removal or replacement of expensive parts of the model so it can be rendered more efficiently. There can be up to 8 levels.
![Tip.png](/w/images/thumb/4/45/Tip.png/9px-Tip.png)
Limitations
![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
![Note.png](/w/images/thumb/c/cc/Note.png/10px-Note.png)
replacematerial
instead.![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
![Counter-Strike: Global Offensive](/w/images/thumb/8/85/Csgo_icon.png/16px-Csgo_icon.png)
![Counter-Strike: Global Offensive](/w/images/thumb/8/85/Csgo_icon.png/16px-Csgo_icon.png)
![](/w/images/thumb/2/2e/Confirm.png/10px-Confirm.png)
![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
In other words, Adding sharp edges to fix a smoothing issue on a LOD will cause that edge to not show up.
![](/w/images/thumb/2/2e/Confirm.png/10px-Confirm.png)
![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
$replacemodel
. Those models add to the total polycount. If your model has very high polycount and you add a LOD just to collapse bones, it will double the overall polycount.Therefore it might be best to either not have any LOD at all, or using a highly decimated version of the model.
Syntax
$lod <threshold>
{
<options>
}
$shadowlod // Used to generate cheap render-to-texture shadows (not shadow maps)
{
<options>
}
threshold
- Defines when the LOD takes effect. Its value is (100 / screen pixels per unit) [1], which means that distance at which the transition happens depends on the size of the user's monitor and their FOV, not simply the model's distance from the camera. Someone with a truly massive screen may never see an LOD!
- The threshold formula makes it difficult to determine what values to use, however. The best way of working things out is to load your model into HLMV, switch to the Model tab, enable Auto LOD, and use
to zoom in and out.
![Note.png](/w/images/thumb/c/cc/Note.png/10px-Note.png)
Options
![Note.png](/w/images/thumb/c/cc/Note.png/10px-Note.png)
replacemodel <Reference smd> <LOD smd> [reverse]
- Replaces the given reference SMD (can by anything from
$body
,$bodygroup
or$model
) with an LOD version. Reverse
is used to correct reversed normals on the LOD, which can be caused by SMD export problems.Bug:LOD meshes for Bodygroups defined outside the
.qc
file (i.e. via$include file.qci
) or inside of $pushd/$popd blocks will not be correctly assigned.
Contents of.qci
files must be merged into the main.qc
file to work. Any usage of$pushd
or$popd
must be replaced with full relative paths, using..\
and forward-slashes to work. [todo tested in ?]removemodel <Reference smd>
- The specified SMD will not be rendered at all at this level of detail.
Bug:Causes compiles to fail with an EXCEPTION_ACCESS_VIOLATION error in studiomdl builds later than 2006.
Instead, use "replacemodel" to swap the specified model for one that is a single tiny triangle hidden inside the mesh. Invisible textures can be used hide it better, should the little triangle ever be seen.[todo tested in ?]Workaround:See $no_draw.
replacematerial <Reference material> <LOD material>
- Replaces all instances of the reference material with another. Useful for removing expensive processes like $bumpmap and disabling the Eye shader. Paths are relative to
$cdmaterials
.Bug:If you use
replacemodel
to replace the mesh, and then setreplacematerial
's 2nd argument to one of the materials found in the LOD mesh, it will cause the entire mesh to be removed. [todo tested in ?] removemesh <Reference material>
- Removes all triangles attached to the named material. Unlike in
replacematerial
, paths are relative to the root materials folder.Bug:If a material's VMT is not present in the game's folder, studiomdl sees a material named "__error" instead; the compiler does not detect VMTs from mounted GCFs/games. [todo tested in ?]
nofacial
- Disables facial animation.
bonetreecollapse <Reference bone>
- Causes children of the specified bone to be removed. Their attached vertices return to the reference position. This is commonly used on fingers. Remember that it only applies to clients!
Note:This don't affect the bones with their parents that have an attachment.
This means that if you collapse bonetree from ValveBiped.Bip01_R_UpperArm but ValveBiped.Bip01_R_Hand has an attachment, such bones as ValveBiped.Bip01_R_Hand and ValveBiped.Bip01_R_Forearm will not be deleted. replacebone <Reference bone> <LOD bone>
- The precursor of
bonetreecollapse
. Replacing bones is much more complex, but allows all kinds of unusual bone optimisations that a simple collapse wouldn't achieve. use_shadowlod_materials
- Todo: Describe (Perhaps $shadowlod models without this use a simple opaque textureless material?); sets
STUDIOHDR_FLAGS_USE_SHADOWLOD_MATERIALS
flag, which is explained like so inpublic/studio.h
:This flag is set when we should use the actual materials on the shadow LOD instead of overriding them with the default one (necessary for translucent shadows)
Example
$lod 12
{
replacemodel "Police_reference" "lod1_Police_reference"
replacemodel "Manhack_reference" "lod1_Manhack_reference"
}
$lod 18
{
replacemodel "Police_reference" "lod2_Police_reference"
replacemodel "Manhack_reference" "lod2_Manhack_reference"
bonetreecollapse "ValveBiped.Bip01_R_Hand"
bonetreecollapse "ValveBiped.Bip01_L_Hand"
}
$lod 42
{
replacemodel "Police_reference" "lod3_Police_reference"
replacemodel "Manhack_reference" "lod3_Manhack_reference"
bonetreecollapse "ValveBiped.Bip01_R_Hand"
bonetreecollapse "ValveBiped.Bip01_L_Hand"
}