Cleanup is going to take awhile, so the site is back up but editing has been disabled.

LOD Model Compiling

From HalfLife 2 Knowledge Base

Jump to: navigation, search

This tutorial deals with the changes that need to be applied to a .qc file if you want to add a LOD to your model. This is a bit tricky to figure out because no examples are offered in the SDK and the compiler displays no warning when there is a common mistake.




You will need a reference model (refered to as: model_reference.smd; its the high poly one), your LOD models (model_lod1.smd, model_lod2.smd, etc) and probably a collision model (model_phy.smd or sometimes model_phys.smd). A normal .qc for a model without LOD might look something like this:

 $modelname modelfolder/model.smd
 
 $cdmaterials models/
 
 $body studio "./model"
 
 $scale 1.0
 
 $sequence idle "model" loop fps 15
 
 $collisionmodel "model_phy.smd" {
      $Mass 10
    $concave
 }

You need to replace $body studio "./model" with $model model "model_reference.smd". Otherwise your .qc will compile without a problem, the modelviewer will display the correct LOD settings but your model will not be replaced by the LOD.

Then you add your settings for the first LOD:

 $lod 15 
 {
 	replacemodel "model_reference" "model_lod1" 
 }

$lod 15 means the model will be replaced with the LOD at a distance of 15 metres. If you have more than one LOD model, you still need to replace the model_reference, not a previous LOD model.

Your second LOD (model_lod2.smd) should look something like

 $lod 30 
 {
 	replacemodel "model_reference" "model_lod2" 
 }

$lod 30 means the model will be replaced with the LOD at a distance of 30 metres.

Your final .qc should look something like this:

 $modelname modelfolder/model.smd
 
 $cdmaterials models/
 
 $model model "model_reference.smd"
 
 $scale 1.0
 
 $sequence idle "model" loop fps 15
 
 $collisionmodel "model_phy.smd" {
      $Mass 10
    $concave
 }
 
 $lod 15 
 {
 	replacemodel "model_reference" "model_lod1" 
 }
 
 $lod 30 
 {
 	replacemodel "model_reference" "model_lod2" 
 }




You may also want to use a different skin on your LOD model, especially to remove expensive shaders such as normal maps, specular maps etc. You can not give your model_lod.smd a different skin than the model_reference.smd, both have to use the same .tga in there .smd! Otherwise everything will compile fine, but your LOD model will not show up at all. If you have your reference .vmt (refered to as modelmaterial.vmt) and your lod .vmt (modelmaterial_lod.vmt), you add this to your lod settings:

 replacematerial "modelmaterial" "modelmaterial_lod"

This has to be done for every LOD stage, if you have more then one. E.G.:

 $modelname modelfolder/model.smd
 
 $cdmaterials models/
 
 $model model "model_reference.smd"
 
 $scale 1.0
 
 $sequence idle "model" loop fps 15
 
 $collisionmodel "model_phy.smd" {
      $Mass 10
    $concave
 }
 
 $lod 15 
 {
 	replacemodel "model_reference" "model_lod1" 
 	replacematerial "modelmaterial" "modelmaterial_lod1"
 }
 
 $lod 30 
 {
 	replacemodel "model_reference" "model_lod2" 
 	replacematerial "modelmaterial" "modelmaterial_lod1"
 }




More settings for LOD models can be found in the SDK Reference Docs.

I hope this helps to sort out some common errors...

Vaarscha from HEAT

Minor edits Ac Colavin from Resistance and Libertation

Personal tools