Revision Difference
Player_model_LOD_settings#512524
<cat>Dev.Model</cat>⤶
# Why?⤶
In the vast majority of cases, the main source of slowdown in multiplayer servers with lots of players is the amount of bones that have to be processed by the Source engine.⤶
⤶
We can use a number of tricks to mitigate this aspect such as removing finger bones when you're far away enough.⤶
⤶
# How?⤶
⤶
Any QC includes (QCI files) that are referenced here can be found in the public Source SDK example files, which are located at Steam/SteamApps/your Steam username/sourcesdk_content/hl2/modelsrc/humans_sdk.⤶
⤶
Even if you have made no LOD meshes that reduce the polygon count of your player model, you should apply these LOD commands, since they will drastically reduce bone counts at a distance, helping with performance.⤶
⤶
The LOD settings that follow are used by almost all of the player models that ship with Garry's Mod.⤶
⤶
# Recommended reading ⤶
⤶
* https://developer.valvesoftware.com/wiki/LOD_Models⤶
* https://developer.valvesoftware.com/wiki/$lod⤶
⤶
# LOD 0 ⤶
⤶
No optimizations yet, since this is the highest level of detail.⤶
⤶
# LOD 1 ⤶
⤶
**Recommended distance:** 9⤶
⤶
```⤶
⤶
replacemodel "my_detailed_mesh.smd" "my_less_detailed_mesh_for_this_lod.smd"⤶
replacebone "ValveBiped.Bip01_L_Elbow" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Elbow" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Ulna" "ValveBiped.Bip01_L_Forearm"⤶
replacebone "ValveBiped.Bip01_R_Ulna" "ValveBiped.Bip01_R_Forearm"⤶
replacebone "ValveBiped.Bip01_L_Wrist" "ValveBiped.Bip01_L_Forearm"⤶
replacebone "ValveBiped.Bip01_R_Wrist" "ValveBiped.Bip01_R_Forearm"⤶
replacebone "ValveBiped.Bip01_L_Bicep" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Bicep" "ValveBiped.Bip01_R_upperarm"⤶
⤶
replacebone "ValveBiped.Bip01_L_Finger02" "ValveBiped.Bip01_L_Finger01"⤶
replacebone "ValveBiped.Bip01_L_Finger12" "ValveBiped.Bip01_L_Finger11"⤶
replacebone "ValveBiped.Bip01_L_Finger22" "ValveBiped.Bip01_L_Finger21"⤶
replacebone "ValveBiped.Bip01_L_Finger32" "ValveBiped.Bip01_L_Finger31"⤶
replacebone "ValveBiped.Bip01_L_Finger42" "ValveBiped.Bip01_L_Finger41"⤶
⤶
replacebone "ValveBiped.Bip01_R_Finger02" "ValveBiped.Bip01_R_Finger01"⤶
replacebone "ValveBiped.Bip01_R_Finger12" "ValveBiped.Bip01_R_Finger11"⤶
replacebone "ValveBiped.Bip01_R_Finger22" "ValveBiped.Bip01_R_Finger21"⤶
replacebone "ValveBiped.Bip01_R_Finger32" "ValveBiped.Bip01_R_Finger31"⤶
replacebone "ValveBiped.Bip01_R_Finger42" "ValveBiped.Bip01_R_Finger41"⤶
```⤶
⤶
⤶
This removes some of the procedural bones as well as the tip of the fingers.⤶
⤶
# LOD 2 ⤶
⤶
**Recommended distance:** 18⤶
⤶
```⤶
⤶
replacemodel "my_detailed_mesh.smd" "my_less_detailed_mesh_for_this_lod.smd"⤶
nofacial⤶
bonetreecollapse "ValveBiped.Bip01_L_Hand"⤶
bonetreecollapse "ValveBiped.Bip01_R_Hand"⤶
⤶
replacebone "ValveBiped.Bip01_L_Elbow" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Elbow" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Ulna" "ValveBiped.Bip01_L_Forearm"⤶
replacebone "ValveBiped.Bip01_R_Ulna" "ValveBiped.Bip01_R_Forearm"⤶
replacebone "ValveBiped.Bip01_L_Shoulder" "ValveBiped.Bip01_L_upperarm" ⤶
replacebone "ValveBiped.Bip01_R_Shoulder" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Trapezius" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Trapezius" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Wrist" "ValveBiped.Bip01_L_Forearm"⤶
replacebone "ValveBiped.Bip01_R_Wrist" "ValveBiped.Bip01_R_Forearm"⤶
replacebone "ValveBiped.Bip01_L_Bicep" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Bicep" "ValveBiped.Bip01_R_upperarm"⤶
```⤶
⤶
⤶
This disables facial animation, removes almost all procedural bones, and gets rid of fingers.⤶
⤶
# LOD 3 ⤶
⤶
**Recommended distance:** 32⤶
⤶
```⤶
⤶
$include "../../removehands.qci"⤶
```⤶
⤶
⤶
```⤶
⤶
replacemodel "my_detailed_mesh.smd" "my_less_detailed_mesh_for_this_lod.smd"⤶
removemesh "eyeball material, etc"⤶
⤶
nofacial⤶
bonetreecollapse "ValveBiped.Bip01_L_Forearm"⤶
bonetreecollapse "ValveBiped.Bip01_R_Forearm"⤶
bonetreecollapse "ValveBiped.Bip01_L_Calf"⤶
bonetreecollapse "ValveBiped.Bip01_R_Calf"⤶
replacebone "ValveBiped.Bip01_L_Elbow" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Elbow" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Ulna" "ValveBiped.Bip01_L_Forearm"⤶
replacebone "ValveBiped.Bip01_R_Ulna" "ValveBiped.Bip01_R_Forearm"⤶
replacebone "ValveBiped.Bip01_L_Shoulder" "ValveBiped.Bip01_L_upperarm" ⤶
replacebone "ValveBiped.Bip01_R_Shoulder" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Trapezius" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Trapezius" "ValveBiped.Bip01_R_upperarm"⤶
replacebone "ValveBiped.Bip01_L_Wrist" "ValveBiped.Bip01_L_Forearm"⤶
replacebone "ValveBiped.Bip01_R_Wrist" "ValveBiped.Bip01_R_Forearm"⤶
replacebone "ValveBiped.Bip01_L_Bicep" "ValveBiped.Bip01_L_upperarm"⤶
replacebone "ValveBiped.Bip01_R_Bicep" "ValveBiped.Bip01_R_upperarm"⤶
```⤶
⤶
⤶
Starting with LOD 3 and below, you should include removemesh commands to get rid of the eyeballs, transparent materials like glasses, stuff like that. Note that this seems to be bugged with the Orange Box compiler (which sometimes interprets most materials as being named "___error"), in which case you could delete the materials directly on your LOD meshes.⤶
⤶
# Lowest LODs ⤶
⤶
**Recommended distance:** 48 (level 4), 64 or more (level 5)⤶
⤶
```⤶
⤶
replacemodel "my_detailed_mesh.smd" "my_less_detailed_mesh_for_this_lod.smd" ⤶
$include "../../lowesthumanskeleton.qci" ⤶
$include "../../lowesthumannohelpers.qci" ⤶
removemesh "material etc etc"⤶
removemesh "more materials to remove"⤶
nofacial⤶
```⤶
⤶
⤶
## Shadow LOD ⤶
⤶
This is the LOD used for rendering the render-to-texture shadow. **It should always be present**, as shadows don't need nearly as much detail as the player models. It should be the same as LOD 4, though (albeit unrecommended) you might want to use the mesh from 3 or maybe even 2.⤶
⤶
⤶
⤶