LOD: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
m (fix TOC)
m (TOC again)
Line 30: Line 30:
Note: The '''dist_check_period''' spawnarg needs to be combined with one of "hide_distance" or "lod_X_distance" and "model_lod_X", "skin_lod_X" or "noshadows_lod_X" to have any effect!
Note: The '''dist_check_period''' spawnarg needs to be combined with one of "hide_distance" or "lod_X_distance" and "model_lod_X", "skin_lod_X" or "noshadows_lod_X" to have any effect!


=== Entities ===
== Entities ==


Example entities:
Example entities:
Line 39: Line 39:
More can be found in the "Nature" folder inside the DarkRadiant "Create entity" tree.
More can be found in the "Nature" folder inside the DarkRadiant "Create entity" tree.


=== Spawnargs ===
== Spawnargs ==


==== hide_distance ====
=== hide_distance ===


When set to a value > 0, then the entity will be hidden if it is further away than this distance from the player.
When set to a value > 0, then the entity will be hidden if it is further away than this distance from the player.
Line 47: Line 47:
Note: This might cause "popping", e.g. the entity will suddenly vanish or appear.
Note: This might cause "popping", e.g. the entity will suddenly vanish or appear.


==== lod_X_distanc ====
=== lod_X_distance ===


Sets the distance from where on LOD X is used. Will be valid until the next defined lod_(X+1)_distance, or infinty if there is no further LOD distance set.
Sets the distance from where on LOD X is used. Will be valid until the next defined lod_(X+1)_distance, or infinty if there is no further LOD distance set.
Line 53: Line 53:
To change the appearance of the entity inside this LOD, use the following spawnargs with a matching X:
To change the appearance of the entity inside this LOD, use the following spawnargs with a matching X:


===== model_lod_X =====
==== model_lod_X ====


Set the model the entity displays inside this LOD. If not set, uses the model from LOD 0 e.g. the one from the "model" spawnarg.
Set the model the entity displays inside this LOD. If not set, uses the model from LOD 0 e.g. the one from the "model" spawnarg.


===== skin_lod_X =====
==== skin_lod_X ====


Set the skin the entity displays uses this LOD. If not set, uses the skin from LOD 0 e.g. the one from the "skin" spawnarg.
Set the skin the entity displays uses this LOD. If not set, uses the skin from LOD 0 e.g. the one from the "skin" spawnarg.


===== noshadows_lod_X =====
==== noshadows_lod_X ====


If set, the entity casts no shadows while in this LOD zone.
If set, the entity casts no shadows while in this LOD zone.

Revision as of 17:12, 20 June 2010

LOD (Level of Detail)

A LOD system can be used to bring more details to the screen while still speeding up rendering. See Wikipedia for an introduction.

The LOD system in TDM was totally rewritten for v1.03. This pages describes its workings, how to use it in your maps and what results it can achive.

Comparisation

Here we compare the new (v1.03) to the old system (until v1.02):

  • The old system had only two levels: 0 (original model), and 1 (entity is hidden)
  • Due to a typo, all thinking for the LOD entities happened in the first half of the interval. That means if you set the intervall to 1 s, all entities did their distance check between 0 and 0.5 seconds, and none between 0.5 and 1 second and so on. This lead to fluctuating frame rates.

The new system:

  • Still works only for func_static (e.g. not for lights, AI etc)
  • Supports arbitrary many levels (currently maximum is 7, more would require a recompile)
  • You can use less levels if you want
  • Thinking is distributed over the entire interval
  • makes scenes with thousands of entities possible
  • Can not only switch the model, but also change the skin (f.i. use less expensive glass shaders) and turn shadows off

How to use LOD in your TDM map

To enable the LOD system, use either one of the pre-made LOD-enabled entities in your map (most of these are defined in def/tdm_lod.def) or use the following spawnargs on an entity:

  • hide_distance (will enable LOD and hiding of the entity)
  • dist_check_period

Note: The dist_check_period spawnarg needs to be combined with one of "hide_distance" or "lod_X_distance" and "model_lod_X", "skin_lod_X" or "noshadows_lod_X" to have any effect!

Entities

Example entities:

  • atdm:nature_pine_skeleton
  • atdm:nature_tree_stump

More can be found in the "Nature" folder inside the DarkRadiant "Create entity" tree.

Spawnargs

hide_distance

When set to a value > 0, then the entity will be hidden if it is further away than this distance from the player.

Note: This might cause "popping", e.g. the entity will suddenly vanish or appear.

lod_X_distance

Sets the distance from where on LOD X is used. Will be valid until the next defined lod_(X+1)_distance, or infinty if there is no further LOD distance set.

To change the appearance of the entity inside this LOD, use the following spawnargs with a matching X:

model_lod_X

Set the model the entity displays inside this LOD. If not set, uses the model from LOD 0 e.g. the one from the "model" spawnarg.

skin_lod_X

Set the skin the entity displays uses this LOD. If not set, uses the skin from LOD 0 e.g. the one from the "skin" spawnarg.

noshadows_lod_X

If set, the entity casts no shadows while in this LOD zone.

Increasing the LOD steps

The number of possible LOD steps is fixed in code and defined in game/misc.h as a constant. The current value is 7, meaning that there are 5 different rendering possibilities beside level 0 (the original) and level 6 (the object is hidden). That should be enough even for huge outdoor maps.

Performance

  • Section not yet written