$lod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(cleanup and update : see diff notes)
Line 1: Line 1:
'''<code>$lod</code>''' is a command that allows a model's [[reference mesh]] to be simplified as it becomes smaller on the screen, in order to improve performance. LOD does not affect [[collision mesh]]es, and is an acronym that stands for [[Level Of Detail]].
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.


See [[LOD Models]] for in-depth information on generating LOD models.
See [[LOD Models]] for in-depth information on generating LOD models and [[LOD system]] for a better overview.
<!--:{{note|LODs are not inherited.}} // inherited by what ?-->


{{tip|You can use [[HLMV]]'s 'Model' tab to preview LODs.}}
== Syntax ==


== Usage ==
$lod <[[int]]|threshhold> { <options> }
where
* <code><[[int]]|threshhold></code> is the LOD threshhold is based on an inverse of the screen space. The smaller the model is on-screen, the larger the LOD threshhold will become.


$lod <distance> { <options> }
{{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.}}


;<[[int]]|distance>
<!-- //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 ... //
:The distance, in metres, from the camera at which the command's options should be performed.
 
:{{note|LODs are not inherited.}}
{{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]]:}}
:{{tip| When distance from the model doubles, the apparent vertical and horizontal 'resolution' (screen pixels) of the model is halved. Therefore these standard 'double' distances provide a useful benchmark both for modelling and compiling [[LOD Models]]:}}
:{|
::{|
|-  
|-  
|'''Game units:''' ||32||64||128||256||512||1024||2048||4096||8192
|'''Game units:''' ||32||64||128||256||512||1024||2048||4096||8192
Line 19: Line 21:
|'''Meters:''' ||0.6 ||1.2 ||2.4 ||4.9 ||9.75 ||19.5 ||39.0 ||78.0 ||156.0
|'''Meters:''' ||0.6 ||1.2 ||2.4 ||4.9 ||9.75 ||19.5 ||39.0 ||78.0 ||156.0
|}
|}
-->


== Options ==
== Options ==

Revision as of 20:05, 1 May 2008

Each $lod QC command begins a block of commands describing how to perform LOD (Level of Detail) 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.

See LOD Models for in-depth information on generating LOD models and LOD system for a better overview.

Syntax

$lod <int|threshhold> { <options> }

where

  • <int|threshhold> is the LOD threshhold is based on an inverse of the screen space. The smaller the model is on-screen, the larger the LOD threshhold will become.
Tip.pngTip: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

replacemodel <original $body name> <replacement reference mesh SMD> [reverse]
Replaces one reference mesh with another of lower detail.
reverse will cause the new mesh to be reversed.
Todo: The point of which is...
removemodel <$body name>
Stops the specified $body from being rendered at all.
removemesh <material name>
Removes all meshes using the given material.
replacematerial <original material name> <replacement material name>
Replaces all instances of a particular material on a model. This is used to remove expensive shaders like Normal Maps or the eye shader.
nofacial
Disables facial animation.
bonetreecollapse <bone>
Deletes all children of the given bone, disabling movement on the client. The envelopes return to their reference position. Commonly used on fingers.
replacebone <original bone> <replacement bone>
The precursor of bonetreecollapse. Accepting a replacement bone makes it slightly less user-friendly, but allows all kinds of unusual bone optimisations that a simple collapse wouldn't achieve.

Example

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

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

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