lilith3d

 

Engine

Documentation

Notes

Tree Rendering

Lilith3D 1.2.0

3D Tree Rendering in Lilith3D is something I'm proud of. It may not compare to the best commercial packages (SpeedTreeRT impresses me greatly) but for a weekends work on a hobby package - it's pretty good.

In this picture, you can see:

  • All 4 tree models - tropical, temperate, arctic
    • A tropical tree model named tree0 is used at the lowest altitudes
    • The middle altitudes use both tree1 and tree2 to give variety
    • The highest altitudes use tree3.
  • The trees rendered at 2 LODs

The closest tree in the image is "tree1" rendered straight from the AC3D file that defines it.

However, there are a *lot* of trees in the background, and throwing that many polygons at each one quickly bogs down the system.

Therefore Lilith3D uses a Level Of Detail system to render the trees. The artist would supply the 3D models of the trees in the usual way. (Lilith3D comes with 4, of course). Lilith3D automatically generates the lesser LOD - 4 billboards that look like this:

They are renderings of the tree at 0, 90, 180, 270 degrees. For trees up close, the full model is used. But...for trees in the distance 2 billboards are used, at 90 degrees to each other. Very much enlarged, the result looks like this.

From a distance, it's quite convincing. The only problem is lighting - the trees up close are rendered with a simple, but directional, lighting model. Trees in the distance are rendered with only an ambient light. The engine is careful to calculate the closest match possible, but you will see a color shift if you look closely, especially at sunrise and sunset.

As a further optimization, trees that are very far away only use one billboard - the one "more facing" the user. The transition from one billboard to 2, at a reasonable distance, is imperceptable visually. But saves quite a few polygons - most objects in a scene are far away.

Typically, most engines use alpha blending to switch between the billboard and the 3D model. Lilith3D uses stippling. A series of stipple patterns are created at initialization, and used to "blend" between the models. Since stippling is in screen space, and the billboard closely matches the model, it works out nicely. It also has the advantage, over alpha blending, that the resulting image is still fully opaque during the transition.