racer home

LOD - Level of detail

 

Home Keep framerates acceptable using level-of-detail (LOD).


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

NOTE!

This is an old documentation describing LOD as it was with Racer version v0.5.7 and before that. Rather use the latest LOD document, which slightly changes the way lod definitions are made (more logical and simpler).

INTRODUCTION

Level of detail can greatly enhance the framerate of tracks and races in general. When the viewer is far away from an object, not all detail has to be drawn.

Racer has level-of-detail based on extra models. In fact, these models don't have to be too related to the original, but ofcourse in general it looks very much like the original. But for example for a really distant car, you might just make a small cube with roughly the car's color for super performance.

Racer has a maximum 10 levels of detail, but ofcourse you may use as many of those as you wish.

MODEL FILENAMES

Level of detail models are implicitly searched & loaded. The filename is built from the original file, added with '_lod<level>'. For example, if the original filename is 'track01.dof' (the so-called LOD0 model, the one with the highest detail), then the LOD1 model is track01_lod1.dof, and LOD2 is track01_lod2.dof.

HOW LOD SELECTS THE RIGHT MODEL TO SHOW

LOD values are specified per level with a single Z (distance) value. This is the distance to the camera. Internally in Racer there is an 'apparent' distance, which is scaled as the camera zooms in or out (in that case, the physical distance remains the same, but you do get closer to or further away from the objects onscreen). Here's an image clarifying how you specify LOD distances in Racer:

Looking at the above:

LEVEL OF DETAIL FOR TRACKS

Default LOD levels (distances to the camera) are split per 100 meter. So LOD0 (the highest detail) object is shown from about 0..100m away, LOD1 is shown at 100..200m etc. You can overrule this in the track's geometry.ini file and the car.ini model definitions.

Since tracks generally have a lot of models, you can specify a generic set of LOD-in points. Here's an example showing a regular track object and a detailing piece of grass.

objects
{
; Generic LOD levels (in case no per-object LOD is given)
lod0_z=0
lod1_z=200
lod2_z=500
track01
{
; Overrule LOD1 level to 300m (levels are then: LOD0=0..300, LOD1=300..infinity) ; Note only the files track01.dof and track_lod1.dof exist. If track_lod2.dof exists, ; you may want to overrule lod2_z as well (from the original 500 above).
lod1_z=300 file=track01.dof
}
smallgrass01
{
; Hide the grass beyond 50m (levels are then: LOD0=0..50m, beyond that the model is hidden) ; This assumes only the files smallgrass01.dof exists.
lod_out=50
file=smallgrass01.dof
}
}

Note that the distances taken to the camera are relative to the center of the object. So if the object is very large or oblong, you may have difficulty finding suitable LOD levels, as the distance to the object can vary quite a bit from the distance to the CENTER of that object. The distance to the center of the object is taken for performance reasons though.

LEVEL OF DETAIL FOR CARS

You can also add LOD to cars; very important for races where you'll have multiple cars onscreen at the same time. Here's an example of the main body model from the car.ini file:

model
{
  file=body.dof
  lod0_z=0
  lod1_z=20
  lod2_z=80
  lod_out=1000
}

The above car will show body_lod1.dof from 20 meters on, and body_lod2.dof from 80 meters on. 'lod_out' is specified, so the last model disappear from 1000 meters distance (not really useful for car bodies perhaps, but for brake discs it is very useful to just make it disappear from a couple of tens of meters).

PRIORITY OF OBJECTS (NYI)

Related to level-of-detail is priorities given to track objects. Ranging from 1 (most important) to 10 (least important), this gives a chance for users and things like mirrors to reduce track detail from an object's perspective. The best way to view this would perhaps to visualize a detail slider, that ranges from 1 to 10. At 10, all objects would be visible. At 1, only priority-1 objects are visible, so only the bare essentials.

It is up to the track designer to decide which objects are important, and how important they are. The most important application for object priorities is the mirror; not all objects need to be drawn in there; it's a good place to optimize drawing a bit without sacrificing too much.


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated November 13, 2012 )