This article relates to the game "Dota 2". Click here for more information.
This article relates to the SDK/Workshop Tools for "Dota 2 Workshop Tools". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

LodGroup

From Valve Developer Community
Jump to: navigation, search
English (en)Translate (Translate)

LOD (level of detail) Groups provide a way to group meshes, and set the distance at which they display on screen. They are used primarily for performance reasons, where a complex model is switched out to a simpler model the farther it is from the camera.

Display

  • LOD Groups are under the LOD Group List item in the outliner. Selecting a lod item will switch to that LOD in the viewport.
  • The LOD menu also provides access to switching LOD's.
    • Set AutoLod to mimic in engine LOD swithcing based on camera distance
Note.pngNote:All model's have 8 LOD levels, but 8 do not have to be defined. If less are defined the last one is used for all remaining levels.

Create

Edit

  • LOD groups are under the LOD Group List item in the outliner.
  • Select a the LOD Group List item's green + button in the property editor to add a new group.
  • Select a LOD item to edit in the property editor.

Data Structures

The vmdl lod group data looks like this

CVLODGroupListReference m_pLodGroupList = CVLODGroupListReference
{
	LODGroupList_t* m_pObject = &LODGroupList_t_0
	string m_sFileName = ""
}

m_pLodGroupList

The reference to the LODGroupList_t of the vmdl:

Attribute Friendly Name Description Type Default Value
m_pObject Pointer to the LODGroupList_t LODGroupList_t*
m_sFileName content relative path to the external lod group list string

LODGroupList_t

A list of LODGroup_t elements. Looks like this in the vmdl:

LODGroupList_t LODGroupList_t_0
{
	LODGroup_t[] m_lodGroups = 
	[
		LODGroup_t
		{
			int m_flSwitchDistance = 0
			string[] m_meshList = 
			[
				
			]
		},
		LODGroup_t
		{
			int m_flSwitchDistance = 0
			string[] m_meshList = 
			[
				
			]
		}
	]
}

LODGroup_t

Attribute Friendly Name Description Type Default Value
m_flSwitchDistance Switch Distance Distance when the LOD becomes active int 0
m_meshList Mesh List A list of mesh names associated with this group string[]
Tip.pngTip:Always make sure you have the first LOD group set to a 0 switch distance, otherwise the base mesh will never show up.
Note.pngNote:The switch distance is based on an inverse of the screen space. The smaller the model is on-screen, the larger the switch distance will be.