Model Instancing

From Mod Wiki

Jump to: navigation, search

Instancing is the re-use of model data across a map in order to save memory and improve performance. When a model is placed several times in a map, its triangle data is saved for each occurrence. However if the model is instanced, its data is saved out just once and shared between each instance in the map. This results in a smaller map file and less data to manage.



Instanced models are created in the same way as any other model. By default, all model_static entities are instanced, and func_static models are not.

Models are also instanced if they are placed inside LOD Groups with Model Instancing set to true.

Generally, any model that is reused many many times in a map - such as trees or rocks - benefit from being instanced. The screenshot below shows Slipgate with instanced models turned on and turned off. Note how the craggy, pointed rock models and some Strogg structures that feature heavily in the map are instanced to save memory.

Instanced models turned on and off in Slipgate


Very generally, instancing is something that is safe to forget about unless your map has an unusually large number of models, and starts to shows signs of slowdown or excessive memory usage. Basic maps will rarely require tweaking of instanced models, and common sense is the key to maintaining good performance without much effort (i.e. realising that a model that appears 500 times should be instanced)

Collision Data

Since instanced models share both their rendered mesh and their collision mesh data, there is a small performance cost for the reduced memory use. However, an instanced model can be made to output its own collision data by using the mergecm key on the entity, which results in faster collision testing at the cost of higher memory usage.

Models can also have their collision data disabled with their noclipmodel key, which will save memory on non-instanced models.

Developer Commands

  • r_skipInstances - turning this on prevents instanced models from being rendered.

See Also

Personal tools