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

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 uses a system based on extra 3D models. In fact, these models don't have to be too related to the original, but ofcourse in general it would look 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.

Versions below v0.5.8 used an older LOD system, which is now being phased out. You can read about it in this document. The changes made involve not using an explicit lod_out, but rather indicate till what distance an LOD model is visible, in contrast with the older definition of the distance at which distance the LOD begins to become visible. An example of the change would be to revise Swiss-Stroll to the next LOD system; for that, open the track's geometry.ini and modify all 'lod_out' statements to 'lod0_z'.

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, etc.

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

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 (check the Swiss-Stroll track for example).

objects
{
; Generic LOD levels (in case no per-object LOD is given)
lod0_z=50
track01
{
; Overrule LOD1 level to 300m (levels are then: LOD0=0..300, LOD1=300..600) ; Note only the files track01.dof, track01_lod1 and track01_lod2.dof exist. If track01_lod3.dof exists, ; you may want to set lod2_z as well.
lod0_z=300 lod1_z=600 file=track01.dof
}
smallgrass01
{
; Hide the grass beyond 50m (the global lod defined above, beyond that the model is hidden) ; This assumes only the file smallgrass01.dof exists.
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=20
  lod1_z=80
  ; Keep LOD2 visible for the rest
  lod2_z=10000
}

The above car will show body_lod1.dof from 20 meters onwards, and body_lod2.dof from 80 meters onwards. Note that models like brake discs could happily disappear within 100 meters or so without the player noticing.

PRIORITY OF OBJECTS (not yet implemented!)

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 needto 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 )