User Tools

Site Tools


Overview

The SpeedTree run-time uses a number of techniques for effective dynamic LOD. Described at the highest level, 3D trees are rendered close to the camera, their geometric resolution and rendering effects are reduced smoothly as they move away, and finally they fade into a billboard image which matches most of its lighting state. The specifics of LOD behavior are different based on the type of geometry.

Note: It is recommended that users study LOD behavior in the Modeler application. It employs the same run-time/shader-based techniques used by the SDK. Its documentation also thoroughly outlines what's going on with the LOD algorithms and how to tune them.

Branches & Fronds

Branches and fronds can employ traditional methods of popping between LODs, where lower LOD representations have few polygons but retain basically the same shape. But, they also employ a scaling technique whereby small outlying geometry (think small wispy branches on the perimeter of the tree; these can consume a lot of triangles but may not contribute much visually, especially at a distance) are gradually scaled down to their center line. When tuned properly, it's very difficult to see because these branches are scaled away at a time when they're resolving to only a few noisy pixel anyway.

To accomplish this effect, the vertex format contains both a 3D position and a 3D LOD value. They're lerped between based on a CPU-supplied LOD value. In the Forest library, this lerp value is stored in the S3dTreeInstanceLod structure and is based on a tree's current overall LOD value and the number of discrete levels it has.


Leaves & Leaf Cards

SpeedTree's leaf LOD is based on using fewer and bigger leaf instances (card & mesh) as the camera moves away from the tree. As of 5.0, alpha tested “fizzling” is no longer employed. Rather, some percentages of the leaf instances are gradually shrunk away and the remaining instances are scaled up. It's a remarkably effective technique when tuned properly and very simple to implement in a vertex shader.

In order to execute this effect in the shader, LOD scales are uploaded per vertex that cue the cards when to shrink and when to grow.


Billboards

Once the 3D tree is far enough away from the camera, it will gradually become a billboard. With alpha-to-coverage enabled, this is a smooth transition. The alpha values of the 3D trees gradually become transparent while the billboards gradually fade in with an increasing opacity.

As the camera spins around the billboard, the shader will automatically select a billboard from an array of images that best matches the camera's azimuthal angle combined with the rotation of that tree instance.

For successful dynamic lighting of the billboards, numerous layers of image data are used:

  • The diffuse map's RGB channels hold a pre-rendered image of the 3D tree's unlit texture maps & diffuse material colors, all multiplied against light scalars & ambient occlusion values pre-computed in the Modeler.
  • The diffuse map's alpha channel holds an antialiased mask that defines the billboards outline.
  • The normal map's RGB channels hold a tangent-space normal map of the entire 3D tree, sampled from a rendering done in the Compiler application.
  • The normal map's alpha channel holds an ambient value that includes a skylight ambient dimming effect to help break up the monotony of an artificially even ambient shading.

Using all of these channels together can lead to amazingly good matches between the 3D trees and their billboard counterparts. The image below is a test screenshot showing how similarly the 3D trees and billboards match. The left half of the billboard field was faded using an image editor. Note that the lighting is dynamic across the entire scene and that the billboards have no pre-baked lighting.


Overhead (Horizontal) Billboards

Once the camera is high enough and looking down on the scene, a special billboard is used to capture the look of the tree from overhead. While it does not have multiple angles associated with it, it does support the same type of dynamic lighting.

The overhead billboard is cross-faded with the vertical billboards, depending on the camera angle. It is also used to cast a better shadow when the light is more directly overhead.


LOD State

The LOD state in the SDK is described as a floating point value, ranged from 1.0 to -1.0. The following table lists the states and how they map to the LOD range.

Value_Range LOD State Description
[ 1.0 to 0.0 ] Near 3D LOD 1.0 is the highest LOD state, complete with fullest wind, geometry, and rendering effects. As value approaches 0.0, effects and geometry are gradually scaled away.
[ 0.0 ] Lowest 3D LOD Model is in its lowest detail 3D form.
[ 0.0 to -1.0 ] Billboard LOD Transition As 0.0 becomes -1.0, the 3D tree fades out and the billboard fades in.
[ -1.0 ] End Billboard Transition The billboard is fully opaque and the 3D model is no longer drawn.