$lod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(tips)
(→‎Options: cleanup)
Line 28: Line 28:
== Options ==
== Options ==


{{note|Each LOD block does not inherit commands from the previous block; they always modify the ''original'' (effectively "$lod 0") mesh, skin or bone, never the previous ''lod_model'' or anything like that.}}
{{note|LOD blocks do not inherit from previous blocks. They always modify the reference mesh.}}


*;<code>replacemodel <original_mesh>.smd <lod_mesh>.smd [reverse]</code>
;<code>replacemodel <Reference smd> <LOD smd> [reverse]</code>
: Causes the ''lod_mesh'' to be rendered instead of the ''original_mesh''.
: Replaces the given reference SMD (can by anything from <code>[[$body]]</code>, <code>[[$bodygroup]]</code> or <code>[[$model]]</code>) with an LOD version.
: The '''original_mesh''' can be any named SMD used by $body, $bodygroup or $model.
:* <code>Reverse</code> is used to correct reversed normals on the LOD, which can be caused by SMD export problems. <!-- see also [[Talk:$body]]-->
: The '''lod_mesh''' should be a lower polygon-count version of the ''reference_model''. If no ''lod_model'' is specified the ''reference_model'' is not rendered at all.
;<code>removemodel <Reference smd></code>
: The '''reverse''' command is used only to correct reversed normals on the ''lod_model'', caused by SMD export problems. <!-- see also [[Talk:$body]]-->
: The specified SMD will not be rendered at all at this level of detail.
 
;<code>replacematerial <Reference material> <LOD material></code>
*;<code>removemodel <original_mesh>.smd</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>.
: The specified Mesh or Sub-mesh ''will not be rendered'' at this LOD.
;<code>removemesh <Reference material></code>
<!-- :Stops the specified $body from being rendered at all. // no that's not the same thing -->
: 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>replacematerial <original_material>.vmt <lod_material>.vmt</code>
:Disables [[facial animation]].
: Replaces ''all'' instances of the ''original_material'' with the ''lod_material''.
;<code>bonetreecollapse <Reference bone></code>
: Useful for removing expensive shaders like [[Normal Maps]] or the Eye Shader from LOD Skins.
: 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!
: {{confirm|The Skin's $basetexture, etc will be [[mipmap]]ped automatically - you don't need to do it manually.}}
;<code>replacebone <Reference bone> <LOD bone></code>
: {{confirm|If lod1_mesh.smd was [[UV map]]ped to an lod1_skin.bmp, the lod1_skin.vmt will automatically be rendered on the lod1_mesh and doesn't need to be specified with "replacematerial" ?}}
:The precursor of <code>bonetreecollapse</code>. Replacing bones is much more complex, but allows all kinds of unusual bone optimisations that a simple collapse wouldn't achieve.<!-- go on ... give us another clue!-->
 
*;<code>removemesh <original_material>.vmt</code>
: Removes all the triangles attached to the named material at this LOD.
<!-- :Removes all meshes using the given material. // no that's not the same thing -->
 
*;<code>nofacial</code>
:Disables [[facial animation]] at this LOD.
 
*;<code>bonetreecollapse <original_bonename></code>
: Causes all child bones of the specified bone to use the specified bone instead of whatever they currently are attached to.
:Deletes all children of the given bone, disabling movement on the client. The [[envelope]]s return to their reference position. Commonly used on fingers.
 
*;<code>replacebone <original_bonename> <lod_bonename></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.<!-- go on ... give us another clue!-->


== Example ==
== Example ==

Revision as of 07:53, 18 July 2011

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.

Tip.pngTip:You don't need to worry about weightmapping LOD models. Studiomdl can determine a vertex's weight by examining the closest vertex on the reference mesh.
Note.pngNote:You cannot introduce new materials on an LOD model.

Syntax

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

where

  • <int|threshhold> : 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.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> : See below.

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.
replacematerial <Reference material> <LOD material>
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 $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 "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
}