$lod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Options: hypothesis about lod_model.smd default skins ...)
m (→‎Options: hope its a little clearer)
Line 24: Line 24:
== Options ==
== Options ==


{{note|Each LOD block does not inherit commands from the previous block; they always modify the reference model.}}
{{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.}}


*;<code>replacemodel <reference_model> <lod_model>.smd [reverse]</code>
*;<code>replacemodel <original_mesh>.smd <lod_mesh>.smd [reverse]</code>
: Causes the ''lod_model'' to be rendered instead of the ''reference_model''.
: Causes the ''lod_mesh'' to be rendered instead of the ''original_mesh''.
: The '''reference_model''' can be any (named or SMD) model used by $body, $bodygroup or $model. Note: the ''reference_model'' is always just that; never the previous ''lod_model'' or anything like that.
: The '''original_mesh''' can be any named SMD used by $body, $bodygroup or $model.  
: The '''lod_model''' 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.
: 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.
: The '''reverse''' command is used only to correct reversed normals on the ''lod_model'', caused by SMD export problems. <!-- see also [[Talk:$body]]-->
: The '''reverse''' command is used only to correct reversed normals on the ''lod_model'', caused by SMD export problems. <!-- see also [[Talk:$body]]-->


*;<code>removemodel <model_name></code>
*;<code>removemodel <original_mesh>.smd</code>
: The specified Mesh or Sub-mesh ''will not be rendered'' at this LOD.
: The specified Mesh or Sub-mesh ''will not be rendered'' at this LOD.
<!-- :Stops the specified $body from being rendered at all. // no that's not the same thing -->
<!-- :Stops the specified $body from being rendered at all. // no that's not the same thing -->


*;<code>replacematerial <reference_material> <lod_material></code>
*;<code>replacematerial <original_material>.vmt <lod_material>.vmt</code>
: Replaces ''all'' instances of the ''reference_material'' with the ''lod_material''.
: Replaces ''all'' instances of the ''original_material'' with the ''lod_material''.
: Useful for removing expensive shaders like [[Normal Maps]] or the Eye Shader from LOD Skins.
: Useful for removing expensive shaders like [[Normal Maps]] or the Eye Shader from LOD Skins.
: {{confirm|The Skin's $basetexture, etc will be [[mipmap]]ped automatically - you don't need to do it manually.}}
: {{confirm|The Skin's $basetexture, etc will be [[mipmap]]ped automatically - you don't need to do it manually.}}
: {{confirm|If lod1_model.smd was [[UV map]]ped to an lod1_skin.bmp, the lod1_skin.vmt will automatically be rendered on lod1_model and doesn't need to be specified with "replacematerial" ?}}
: {{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" ?}}


*;<code>removemesh <material_name></code>
*;<code>removemesh <original_material>.vmt</code>
: Removes all the triangles attached to the named material at this LOD.
: 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 -->
<!-- :Removes all meshes using the given material. // no that's not the same thing -->
Line 49: Line 49:
:Disables [[facial animation]] at this LOD.
:Disables [[facial animation]] at this LOD.


*;<code>bonetreecollapse <bone></code>
*;<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.
: 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.
: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 bone> <replacement bone></code>
*;<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!-->
: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!-->



Revision as of 20:55, 2 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.

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: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.
  • replacemodel <original_mesh>.smd <lod_mesh>.smd [reverse]
Causes the lod_mesh to be rendered instead of the original_mesh.
The original_mesh can be any named SMD used by $body, $bodygroup or $model.
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.
The reverse command is used only to correct reversed normals on the lod_model, caused by SMD export problems.
  • removemodel <original_mesh>.smd
The specified Mesh or Sub-mesh will not be rendered at this LOD.
  • replacematerial <original_material>.vmt <lod_material>.vmt
Replaces all instances of the original_material with the lod_material.
Useful for removing expensive shaders like Normal Maps or the Eye Shader from LOD Skins.
Confirm:The Skin's $basetexture, etc will be mipmapped automatically - you don't need to do it manually.
Confirm:If lod1_mesh.smd was UV mapped 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" ?
  • removemesh <original_material>.vmt
Removes all the triangles attached to the named material at this LOD.
  • nofacial
Disables facial animation at this LOD.
  • bonetreecollapse <original_bonename>
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 envelopes return to their reference position. Commonly used on fingers.
  • replacebone <original_bonename> <lod_bonename>
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
}