LOD Models
This tutorial will help you creating Level of Detail Models in an efficient way. Efficient means that we want to increase the performance noticeably, spent as less time as possible but still keep our model visually appealing at all stages.
Planning stage
Before you begin you should make sure if your model is in need for a LOD model, if desireable results can be achieved or if making one is a waste of time.
When to use LOD models
If your model has one or more of these characteristics, you should consider taking the time to create one or more LOD models:
- small details which increase the polycount but can not be seen in distance
- a mesh that uses lot's of polys to create a round or organic apperiance
- physic props - you never know where the player is going to carry them
- the model has expensive shaders (e.g. a Normal Maps)
LOD model useless?
In some cases, a LOD model will not improve the performance noticeable. This might be the case if:
- your model already has a small polycount or is low detail
- you don't think you can reduce the polycount by at least 30% (the model has no round/organic structures)
- it's a static model that is only going to be used in areas with a good performance
Conclusion
Whereever you draw the line if your model needs LODs or not is your decision. It's also a good idea to look at the HL2 models to see when Valve has created LOD models and when they thought that it wasn't necessary.
Modeling LODs
Tips
The work in the model editor should be kept to a minimum. You don't want to spent as much time on your LOD models as you did on the original model! Our goal is to make a few modifications on the model that will reduce the polycount within a few minutes. However, we don't want to make a whole new model, redo our UV map or something else that consumes a lot of time.
Get used to the fact that a LOD model can only be seen from a large distance. If a player wants to see details, he'll step closer. Since the player does not focus on the details, we can remove them without him noticing if it is done in a subtle way. Things you don't want to do:
- Changing the outline of the model or anything that gives cover. You can remove the seats within a car, but don't remove the roof.
- Moving details on the UV map. The texture will most likely get stretched during the process, however only if details move from one place to another it'll be noticeable.
- Smoothing groups changing in a way that one large area turns from shadowed into brightened or similar.
Techniques
Removing small details
Often details are too small to be seen from a distance - they'll simply not be drawn with the resolution of modern day hardware or can't be noticed.
Reducing polys of complex surfaces
This can be done by using the tools your modeling package offers. It'll weld vertices without destroying the UV map.
Rebuilding complex geometry with very simple one
This is only recommend if the automatic tools fail as it is rather timeconsuming and needs a new UV map (use the same skin in any case). Rebuild the basic shape of the model (or a part of it) as low poly as possible.
Example (using 3DS Max)
This animated outdoor camera is high detailed. Bolts, Cables and the rotating camera-holder are small details with lot's of polys. The chassis of the motor is round and highly detailed as well. The mounting on the wall is pretty straight forward. Not much polys are used here, an optimization is not necessary.
The goal is to make two different LOD models: One for a distance of 25 meters and one for 50 meters.
For the first one, some very small details (bolts, cable) are deleted. If we check the difference of the reference and the LOD model in the modelviewer, the missing bolts can not be noticed. The loss of the cable might seem a bit drastic, but in-game you'll most likely have a brighter background so the contrast between cable and wall will not be as big. Furthermore the player doesn't focus on the cable - he will simply not notice it.
In the second step, the camera-holder was deleted. Furthermore we want to reduce the number of polygons used on the chassis of the motor. The polygons have been selected and the vertex weld
tool is used. By increasing the threshold, vertices are weld together and max adjusts the UV map. Try to find a good value which removes as much polys as possible while retaining the shape of the model.
Checking in the modelviewer once again, the difference is once again hardly noticeable, but the polygon count is significantly lowered.
Using different shaders
Expensive shaders often have a big performance impact as well. Disabling them after a certain distance is an easy way to increase the performance.
You just need another .vmt. Simply open the original one, delete all expensive shaders like Normal Maps and save it with a different name.
.QC file and compiling
Here's an example .qc for a static model. Of course you can use LOD models on animated models or physic props as well. The commands to add are the same.
$modelname mymodelfolder/mymodelcompiled.mdl $cdmaterials modeltextures/mytexturefolder $surfaceprop metal $staticprop $body studio "mymodelsource.smd" $sequence idle "mymodelsource" loop fps 15 $collisionmodel "model_phy.smd" $lod 15 { replacemodel "mymodelsource" "mymodelsource_lod1" replacematerial "modelmaterial" "modelmaterial_lod" } $lod 30 { replacemodel "mymodelsource" "mymodelsource_lod2" replacematerial "modelmaterial" "modelmaterial_lod" }
Add $lod <distance in meters>
.
Within the brace, use replacemodel
if you want to replace the model. In the next step, add the name of this model. In case you use $body studio
, it is the name of your .smd file, if you use $model modelname
it's the modelname, obviously. After that, add the name of the .smd that contains your LOD model.
With replacematerial
, you can replace the material used. The name of it must be similar to the name in the .smd. If you use several materials on your model, you can replace them individually.
Note: You have to replace the model or material within every step. The previous one is not taken over. For example, if you delete replacematerial
in $lod 30
, the original .vmt is loaded again.