$lod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(→‎Syntax: threshold formula)
Line 15: Line 15:


<source lang=php>
<source lang=php>
$lod <threshhold>
$lod <threshold>
{
{
<options>
<options>
Line 26: Line 26:
</source>
</source>


The <code>threshhold</code> value is based on an inverse of the screen space. The smaller the model is on-screen, the larger the LOD threshhold will become. A practical way to achieve a good set of LOD threshholds for your [[LOD Models]] is to use the [[HLMV]] Model tab to find numbers where the LOD transitions with a low amount of visual popping.
; <code>threshold</code>
<!-- //note : Jeff is currently digging out some info on how this "threshold" figure relates to Model-Viewer distance ... apparently it's nothing to do with meters, so I've changed the "metric" to "threshhold" for now ... please leave alone until we have more definitive info ... //
: Defines when the LOD takes effect. Its value is (100 / screen pixels per unit) [http://www.interlopers.net/forum/viewtopic.php?f=25&t=29954], 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 {{key|RMB}} to zoom in and out.
{{tip| When distance from the model doubles, the apparent vertical and horizontal 'resolution' (screen pixels) of the model is halved. Therefore the standard 'double' distances provide a useful benchmark both for modelling and compiling [[LOD Models]]:}}
:{| class=standard-table
|-
|'''Game units:''' ||32||64||128||256||512||1024||2048||4096||8192
|-
|'''Meters:''' ||0.6 ||1.2 ||2.4 ||4.9 ||9.75 ||19.5 ||39.0 ||78.0 ||156.0
|}
-->


=== Options ===
=== Options ===

Revision as of 08:28, 10 August 2011

The $lod QC command describes how to reduce the level of detail when rendering the model at a given distance. 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.pngTip:You don't need to worry about weightmapping LOD models. Studiomdl will transfer from the reference mesh.
Note.pngNote:You cannot introduce new materials in an LOD SMD. Use replacematerial instead.

See also

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 RMB to zoom in and out.

Options

Note.pngNote:LOD blocks do not inherit from previous blocks. They always modify the reference mesh.
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.
removemodel <Reference smd>
The specified SMD will not be rendered at all at this level of detail.
Icon-Bug.pngBug:Causes compiles to fail in Alien Swarm and the Episode 1 compiler.  [todo tested in ?]
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.
removemesh <Reference material>
Removes all triangles attached to the named material. Unlike in replacematerial, paths are relative to the root materials folder.
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!
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.

Example

$lod 12
{
	replacemodel "Police_reference.smd" "lod1_Police_reference.smd"
	replacemodel "Manhack_reference.smd" "lod1_Manhack_reference.smd"
}

$lod 18
{
	replacemodel "Police_reference.smd" "lod2_Police_reference.smd"
	replacemodel "Manhack_reference.smd" "lod2_Manhack_reference.smd"
	bonetreecollapse "ValveBiped.Bip01_R_Hand"
	bonetreecollapse "ValveBiped.Bip01_L_Hand"
}

$lod 42
{
	replacemodel "Police_reference.smd" "lod3_Police_reference.smd"
	replacemodel "Manhack_reference.smd" "lod3_Manhack_reference.smd"
	bonetreecollapse "ValveBiped.Bip01_R_Hand"
	bonetreecollapse "ValveBiped.Bip01_L_Hand"
}