$lod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Options: cleanup)
(more cleaning)
Line 1: Line 1:
Each [[$lod]] [[QC command]] begins a block of commands describing how to perform [[LOD system|LOD ('''L'''evel '''o'''f '''D'''etail)]] on the model. Each block specifies a single ''threshold'' parameter which represents a distance between the Model and the Viewer. When the Model is rendered beyond this distance that block of LOD commands are executed. The commands allow the [[LOD system]] to remove or replace various "expensive" parts of the Model so it can be rendered more efficiently.
{{toc-right}}


{{tip|You don't need to worry about [[weightmap]]ping LOD models. [[Studiomdl]] can determine a vertex's weight by examining the closest vertex on the [[reference mesh]].}}
The [[$lod]] [[QC command]] describes how to reduce the [[LOD system|level of detail]] on 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. It only takes effect on the client.


{{note|You cannot introduce new [[material]]s on an LOD model.}}
{{tip|You don't need to worry about [[weightmap]]ping LOD models. [[Studiomdl]] will transfer the reference mesh's.}}


* See [[LOD Models]] for in-depth information on generating LOD models
{{note|You cannot introduce new [[material]]s in an LOD SMD. Use <code>replacematerial</code> instead.}}
* See [[LOD system]] for a better overview.
 
* See also [[$shadowlod]] for cheaper [[Dynamic Shadows]].
== See also ==
 
* [[LOD Models]]
* [[LOD system]]


== Syntax ==
== Syntax ==


$lod <[[int]]|threshhold> { <options> }
<source lang=php>
where
$lod <threshhold>
* <code><[[int]]|threshhold></code> : The LOD threshhold number is based on an inverse of the screen space. The smaller the model is on-screen, the larger the LOD threshhold will become.  
{
{{tip|The 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.}}
<options>
}
 
$shadowlod // Used to generate cheap render-to-texture shadows (not shadow maps)
{
<options>
}
</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. {{tip|The 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.
<!-- //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 ... //
<!-- //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 ... //


Line 25: Line 37:
|}
|}
-->
-->
* <code><options></code> : See below.
 
== Options ==
=== Options ===


{{note|LOD blocks do not inherit from previous blocks. They always modify the reference mesh.}}
{{note|LOD blocks do not inherit from previous blocks. They always modify the reference mesh.}}


;<code>replacemodel <Reference smd> <LOD smd> [reverse]</code>
; <code>replacemodel <Reference smd> <LOD smd> [reverse]</code>
: Replaces the given reference SMD (can by anything from <code>[[$body]]</code>, <code>[[$bodygroup]]</code> or <code>[[$model]]</code>) with an LOD version.
: Replaces the given reference SMD (can by anything from <code>[[$body]]</code>, <code>[[$bodygroup]]</code> or <code>[[$model]]</code>) with an LOD version.
:* <code>Reverse</code> is used to correct reversed normals on the LOD, which can be caused by SMD export problems. <!-- see also [[Talk:$body]]-->
: <code>Reverse</code> is used to correct reversed normals on the LOD, which can be caused by SMD export problems. <!-- see also [[Talk:$body]]-->
;<code>removemodel <Reference smd></code>
; <code>removemodel <Reference smd></code>
: The specified SMD will not be rendered at all at this level of detail.
: The specified SMD will not be rendered at all at this level of detail. {{bug|Causes compiles to fail in [[Alien Swarm]].}}
;<code>replacematerial <Reference material> <LOD material></code>
; <code>replacematerial <Reference material> <LOD material></code>
: Replaces all instances of the Reference [[Material]] with another. Useful for removing expensive techniques like [[$bumpmap]] and disabling the [[Eye]] shader. Paths are relative to <code>[[$cdmaterials]]</code>.
: 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 <code>[[$cdmaterials]]</code>.
;<code>removemesh <Reference material></code>
; <code>removemesh <Reference material></code>
: Removes all triangles attached to the named material. Unlike in <code>replacematerial</code>, paths are relative to the root materials folder.
: Removes all triangles attached to the named material. Unlike in <code>replacematerial</code>, paths are relative to the root materials folder.
;<code>nofacial</code>
; <code>nofacial</code>
:Disables [[facial animation]].
: Disables [[facial animation]].
;<code>bonetreecollapse <Reference bone></code>
; <code>bonetreecollapse <Reference bone></code>
: 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!
: 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!
;<code>replacebone <Reference bone> <LOD bone></code>
;<code>replacebone <Reference bone> <LOD bone></code>
Line 48: Line 60:
== Example ==
== Example ==


$lod 12
<source lang=php>
{
$lod 12
replacemodel Police_reference "lod1_Police_reference.smd"
{
replacemodel Manhack_reference "lod1_Manhack_reference.smd"
replacemodel "Police_reference.smd" "lod1_Police_reference.smd"
}
replacemodel "Manhack_reference.smd" "lod1_Manhack_reference.smd"
}
$lod 18
 
{
$lod 18
replacemodel Police_reference "lod2_Police_reference.smd"
{
replacemodel Manhack_reference "lod2_Manhack_reference.smd"
replacemodel "Police_reference.smd" "lod2_Police_reference.smd"
bonetreecollapse ValveBiped.Bip01_R_Hand
replacemodel "Manhack_reference.smd" "lod2_Manhack_reference.smd"
bonetreecollapse ValveBiped.Bip01_L_Hand
bonetreecollapse "ValveBiped.Bip01_R_Hand"
}
bonetreecollapse "ValveBiped.Bip01_L_Hand"
}
$lod 42
 
{
$lod 42
replacemodel Police_reference "lod3_Police_reference.smd"
{
replacemodel Manhack_reference "lod3_Manhack_reference.smd"
replacemodel "Police_reference.smd" "lod3_Police_reference.smd"
bonetreecollapse ValveBiped.Bip01_R_Hand
replacemodel "Manhack_reference.smd" "lod3_Manhack_reference.smd"
bonetreecollapse ValveBiped.Bip01_L_Hand
bonetreecollapse "ValveBiped.Bip01_R_Hand"
}
bonetreecollapse "ValveBiped.Bip01_L_Hand"
}
</source>


[[Category:QC Commands|lod]]
[[Category:QC Commands|lod]]

Revision as of 08:16, 18 July 2011

The $lod QC command describes how to reduce the level of detail on 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. It only takes effect on the client.

Tip.pngTip:You don't need to worry about weightmapping LOD models. Studiomdl will transfer the reference mesh's.
Note.pngNote:You cannot introduce new materials in an LOD SMD. Use replacematerial instead.

See also

Syntax

$lod <threshhold>
{
	<options>
}

$shadowlod // Used to generate cheap render-to-texture shadows (not shadow maps)
{
	<options>
}

The threshhold value is based on an inverse of the screen space. The smaller the model is on-screen, the larger the LOD threshhold will become. {{tip|The 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.

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.  [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"
}