Level-Of-Detail (LOD)
The SpeedTree run-time uses simple but effective techniques for LOD. Described at the highest level, essentially 3D trees are rendered close to the camera, their resolution and rendering effects are dropped gradually 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 and fronds 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.
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 stunningly 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.
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:
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.
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.
The LOD state in the SpeedTree SDK is described as a floating point value, ranged from 1.0 to -1.0. Unlike previous SpeedTree versions, LOD state is governed by four values, not two. The following table lists the states and how they map to the LOD range.