$lod

From Valve Developer Community
Revision as of 11:34, 2 May 2008 by Beeswax (talk | contribs) (→‎Options: hypothesis about lod_model.smd default skins ...)
Jump to navigation Jump to search

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 reference model.
  • replacemodel <reference_model> <lod_model>.smd [reverse]
Causes the lod_model to be rendered instead of the reference_model.
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 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 reverse command is used only to correct reversed normals on the lod_model, caused by SMD export problems.
  • removemodel <model_name>
The specified Mesh or Sub-mesh will not be rendered at this LOD.
  • replacematerial <reference_material> <lod_material>
Replaces all instances of the reference_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_model.smd was UV mapped 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" ?
  • removemesh <material_name>
Removes all the triangles attached to the named material at this LOD.
  • nofacial
Disables facial animation at this LOD.
  • bonetreecollapse <bone>
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 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
}