$lod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎Syntax: minor cleanup)
No edit summary
Line 1: Line 1:
Begins a block of commands to describe how to perform LOD ('''L'''evel '''o'''f '''D'''etail) on the model. The ''distance'' parameter represents that this particular set of LOD commands should be run when the camera is farther away from the model. The commands allow you to replace various materials, textures, etc. The commands you can include in the lod block are shown below.
'''<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]].


{{tip|The LOD metric is based on an inverse of the screen space. The smaller the model is on-screen, the larger the LOD metric will become. You can use the LOD functions in the Model tab of [[HLMV]] to determine the proper metrics for a model.}}
With <code>$lod</code>, you can:


* See [[LOD Models]] for in-depth information on generating LOD models.
*Reduce the number of bones
*Replace materials
*Hide meshes entirely (if you have more than one <code>[[$body]]</code> or <code>[[$model]]</code>)
*Disable [[facial animation]]


== Syntax ==
See [[LOD Models]] for in-depth information on generating LOD models.
$lod <distance1> { <lod commands here> }
$lod <distance2> { <lod commands here> }


* Each [[$lod]] [[QC command]] begins a block of [[LOD|Level of Detail]] commands to perform when rendering the Model beyond the given '''<distance>''' from the Viewer.  
{{tip|You can use [[HLMV]]'s 'Model' tab to preview LODs.}}


* The '''<distance>''' for each $lod threshold is calibrated in ''meters''; 1 meter is approximately 53.333 map units (see [[Dimensions]]).
== Usage ==


{{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]]:}}
$lod <distance> { <options> }
 
;<[[int]]|distance>
:The distance, in metres, from the camera at which the command's options should be performed.
:{{todo|Are LODs inherited?}}
:{{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
|-
|-
|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
|}
|}


== $lod options ==
== Options ==
 
<div id="replacemodel"></div>
;<code>replacemodel (model name) (replacement model) [reverse]</code>
 
* Causes the <reference_model_name> to be replaced with the <replacement_model_name>.
* The <replacement_model_name> should be a lower polygon-count version of the <reference_model_name>.
* If '''reverse''' is specified, the normals of the replacement model are reversed.
* If the replacement model name is 'blank', then the source model is not rendered at all.
 
<div id="removemodel"></div>
;<code>removemodel (model name)</code>
* Causes the model to not be rendered at this LOD.
 
<div id="replacematerial"></div>
;<code>replacematerial (original material name) (replacement material name)</code>
* Replaces all instances of a particular material on a model with the replacement material.
* This can be used to remove expensive shaders like [[Normal Maps]] or the eye shader.
 
<div id="removemesh"></div>
;<code>removemesh (material name)</code>
* Removes all the triangles attached to the named material at this LOD.


<div id="nofacial"></div>
;<code>replacemodel <original [[$body]] name> <replacement reference mesh SMD> [reverse]</code>
:Replaces one [[reference mesh]] with another of lower detail.
:<code>reverse</code> will cause the new mesh to be reversed. {{todo|The point of which is...}}
;<code>removemodel <$body name></code>
:Stops the specified $body from being rendered at all.
;<code>removemesh <material name></code>
:Removes all meshes using the given material.
;<code>replacematerial <original material name> <replacement material name></code>
:Replaces all instances of a particular material on a model. This is used to remove expensive shaders like [[Normal Maps]] or the eye shader.
;<code>nofacial</code>
;<code>nofacial</code>
* Causes facial animation to be deactivated for this LOD.
:Disables [[facial animation]].
;<code>bonetreecollapse <bone></code>
:'Welds' all children of the given bone together, disabling animation on the client. The [[envelope]]s return to their reference position. Commonly used on fingers.
;<code>replacebone <original bone> <replacement bone></code>
:The precursor of <code>bonetreecollapse</code>. 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.


<div id="replacebone"></div>
== Example ==
;<code>replacebone (original bone) (replacement bone)</code>
* Causes a bone to be used in place of the original bone in the reference model.
* This can be useful for collapsing all of the bones in the hand together. Instead of using the ‘finger’ bone, the finger could just be tied to the 'hand' bone. See also <code>bonetreecollapse</code>.


<div id="bonetreecollapse"></div>
$lod 12
;<code>bonetreecollapse (bone name)</code>
{
* Causes all child bones of the specified bone to use the specified bone instead of whatever they currently are attached to. It's a simpler way to use <code>replacebone</code> in the case where you want to collapse a large number of bones; hands especially can use this feature.
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
}


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

Revision as of 13:28, 1 May 2008

$lod 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 meshes, and is an acronym that stands for Level Of Detail.

With $lod, you can:

See LOD Models for in-depth information on generating LOD models.

Tip.pngTip:You can use HLMV's 'Model' tab to preview LODs.

Usage

$lod <distance> { <options> }
<int|distance>
The distance, in metres, from the camera at which the command's options should be performed.
Todo: Are LODs inherited?
Tip.pngTip: 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
Meters: 0.6 1.2 2.4 4.9 9.75 19.5 39.0 78.0 156.0

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>
'Welds' all children of the given bone together, disabling animation 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
}