How to Render a Forest in 3D

Version history

Date

Version

Author

Nick

Changes

2001-03-13

0.1

Hans H�ggstr�m zzorn Started on the paper. Some areas still missing.
2001-03-16

0.2

Hans H�ggstr�m zzorn Wrote most of the unfinished chapters, filled in details.
2001-03-17

0.3

Hans H�ggstr�m zzorn Filled in the rest, wrote abstract, added the grass field idea. First public announcement.

ToDo

Abstract

This paper presents a way to render realistic forests using multiple coulisses around the camera. This limits the amount of trees that have to be drawn, and solves the problem of how to fill in the area visible between the trees, so that a realistic forest can be drawn without using a vast amounts of tree models, or fog. A way to animate the coulisses so that they look realistic as the camera moves, is presented. The paper also addresses issues such as transitions between different forest types, how to deal with the forest edge, and how to draw the forest from far away or from above. Some ideas for other usage are presented, most notably weather effects and rendering forest like things at smaller scales, such as grass fields. An idea of how to generate trees on the fly with an L-system like technique is also described. Lastly the implementation is discussed; the performance is estimated, a rough architecture is presented, and an example implementation plan is given.

Glossary

Term

Definition

Forest Rendering System The name of the technique described in this paper.
Coulisse Think of it as an coulisse on a stage, providing a partial or complete background image for the scene. The coulisses in the forest rendering system typically consist of one or more coulisse segments, that are just textured polygons. �
Vertical coulisse A vertically standing coulisse, used for forests when seen from the same level.�
Horizontal coulisse �A horizontal coulisse, used for forests when seen from above.
Dynamic coulisse A coulisse that changes and moves when the camera moves. In the case of forests, a dynamic coulisse is always a vertical coulisse.
Static coulisse A coulisse that stays at the same position. For example coulisses at forest edges (when the forest is seen from the outside).
Coulisse segment A coulisse is built from a number of coulisse segments. A coulisse segment is simply a normal polygon that is rendered with some texture. In some cases a coulisse segment can also have different opacity at each corner. Vertical coulisse segments normally have four corners, horizontal ones might be easiest to handle as triangles.
Camera The 'viewer' that sees the world. This is a commonly used 3D graphics term.
Parallax scrolling A technique to generate the illusion of depth in a moving background, by using several, partly transparent and overlapping layers, where the close ones move faster than the more distant. Commonly used in old side scrolling computer games.
LOD Level Of Detail. 3D graphics term describing how detailed a model or terrain is (how many polygons it contains).

Introduction

Realistic forests are one of the hardest things to render efficiently on a computer today. The problem is that you have to render a very large number of trees to completely obscure the landscape beyond, as is the case in a real forest.

One way to address this problem is to just draw a background bitmap with static tree trunks at some certain distance. However, this will still look unrealistic, because it just sits there and doesn't get any closer, and new trees just pop or fade into view.

This paper proposes a solution that uses multiple layers of translucent background bitmaps, and trees that initially appear behind the bitmaps, partly obscured. The background bitmaps also change and move as a result of the camera movement, to create a more realistic effect. Different forest types can use different backgrounds, and a seamless transition between forest types is possible.

First we look at the basic setup of coulisses. Then we consider different forest types, and how to handle transitions between them. After that we look at how to achieve realism when the camera moves. Then we consider forest edges, how to handle movement into and out of a forest, and what a forest looks like from afar. Then we examine various other uses for the forest rendering system, and look at a way to generate realistic trees. Finally we consider implementation issues, such as performance, architecture and implementation order.

The background bitmaps

A number of bitmaps are used to get a depth effect. They should tile horizontally and have natural upper and lower edges. The most remote bitmap is opaque, with a silhouette of the tree line. The lower edge has a more gradual transition, possibly with tree trunks. Closer bitmaps are increasingly transparent (this is mainly achieved by having larger transparent areas). A minimum number of bitmaps is around three, more might be used for a better effect. See figure 1.

Figure 1. Three background bitmaps and the separate 3D tree models are combined to produce the final frame.

Coulisses

The bitmaps are drawn on a series of concentric coulisses around the character (see figure 2). Each coulisse is divided up in segments that are drawn separately as textured polygons. When the character moves, the coulisses move with the character. The coulisses follow the shape of the landscape under them. This means that the coulisses can sometimes move unrealistically when there is small irregularities in the underlying landscape. One way around this could be to average the nearby nodes when calculating the coulisse height, to smooth the vertical movement of the coulisses.

The real 3d tree models and other items can be in front or between coulisses.

The most remote coulisse, called the background coulisse, is opaque. Items behind the background coulisse don't need to be drawn, unless they are so tall that they can be seen by the camera.

Figure 2. The background bitmaps are drawn on a set of coulisses surrounding the character.

Drawing suggestions

The bitmaps for one coulisse should be fairly uniform, and not contain any too noticeable details. The same rules as for drawing textures apply; make sure it tiles (horizontally), and minimize repeating artifacts. A few different textures could be created instead of just one, to reduce repetitiveness. They could be used in random order by the drawing code.

Different forest types

In nature, there are many different forest types, conifer forests, birch groves, oak woods, rain forests, and so on. A single forest can also change in type depending on the location. The edges can be light and consist mostly of oak, while deeper parts can be darker and contain mostly spruce.

The map can contain one forest type at a specific location, or a mix of different forest types. Each forest type can have an own set of background images. The type and distribution of the trees also vary depending on the forest type, but the map or terrain generation library handles that. The rendering engine just gets a set of trees (and other items, like boulders or characters) that exist in the current surroundings.

Transitions

When moving from an area with one forest type into an area with another, the background bitmaps need to change.

When there is some amount of both forest types present, they are blended together (by making the closer bitmap partly transparent). An alternative would be to use several sets of coulisses simultaneously, with different transparency and diameters. The one with smaller diameter (the closer one) should be more or less transparent, the one with the larger diameter should be drawn with normal transparency. Which one is inner and which one is outer at some point depends on which one is stronger in the local area. The one which is stronger should be the closest one. This means that the coulisses wouldn't have to form perfect circles.

Examples of forest types

There should be a good standard set of forest types, to ensure sufficient variation. New forest types can also be created as needed, for example the Glitterdark forest in Dural could have two or three forest types designed specially for it. Each forest type has a number of parameters controlling the trees and other things, but the most interesting property for this paper is its coulisse textures.

Here is a list with suggestions for some useful forest types, and a short description of each.

Light birch woods
This type of forest is light and airy. The sight is good. The ground is usually covered in birch leaves and patches of moss.

[TODO: Fill in more examples..]

Movement

How trees appear

Trees fade into view from from just in front of the background coulisse. By the time they have passed the closest coulisse they should be fully solid. They could become solid before that too, that is something that can be experimented with and fine tuned. The level of detail of a tree model can also change depending on its distance from the camera.

Parallax

One problem with the current approach is that it is possible to take sight at some tree in a coulisse, and try to walk towards it. At first everything seems okay, but soon the player notices that the tree always stays at the same distance, just out of reach. When walking forward the trees at both sides also stay where they are, which looks unrealistic.

The solution is to use parallax scrolling.

When a character walks forward the coulisses at both sides scroll backward, the coulisses straight ahead scroll slowly to the sides, and the coulisses behind scroll slowly inwards. This means that the textures will not tile up seamlessly at the segment boundaries, because the scroll speeds are different. One way to fix this is to have overlapping boundary regions, and fade in/out the textures of the adjoining segments (see figure 3). Just having a non seamless boundary could look acceptable, at least in an initial implementation.

The closer coulisses also scroll a bit faster than more far away coulisses, this creates an illusion of depth.

With this system it is harder to keep track of one tree when the camera moves, and so the effect is less noticeable. The trees at the sides also behave realistically.

Figure 3. One possible way to handle segment edges so that different scrolling speeds don't produce a non-seamless edge. The two meeting segments continue a bit past the meeting point, fading to transparent. The fade could start before the meeting point too. Note that this doesn't work well for the opaque background coulisse.

Animation

The coulisses should look different depending on the season, this could easiest be done by having different snow, ice, and leaf layers.

Things like animating the coulisse to respond to wind is also possible. One way to do this would be to stretch the upper edges of coulisse segments in the local wind direction.

Forest borders

Near the edge

For forest edges, we can use a similar approach as with edges between forest types.

When the camera approaches the edge of the forest from inside the forest, the coulisse layers towards the edge become more and more transparent. As with forest types, the coulisses closer the the edge are affected more. In the implementation we can use the forest thickness at the location of the coulisse segment directly as the source for the opacity of the coulisse at that point.

A forest seen from the outside

A forest edge needs coulisses too, to look good. The difference is that now the coulisses don't surround the camera, or move with it, but are just standing there, some way into the forest. The forest edge coulisses have the same function as coulisses in a forest; they restrict the view, allowing us to cut down on the number of trees that have to be drawn. They also make the forest look similar when seen from the outside to when seen from the inside.

The non-moving forest edge coulisses are static coulisses, and coulisses surrounding the camera are dynamic coulisses.

When the camera moves into the forest, the static forest edge coulisses near the camera should be replaced with dynamic coulisses. This happens bit by bit, so for some time both the static and dynamic coulisses are visible, and should meet more or less seamlessly. See figure 4.

Figure 4. When the camera moves into a forest, the static coulisses are gradually replaced by dynamic coulisses.

The coulisses forming between the outside of he forest and the camera can initially be very transparent, and gradually solidify when the camera moves deeper into the forest (as described in the previous section).

The same process also applies when the camera moves out of the forest.

Varying level of detail for a forest edge

When seen from afar, the forest edge can be drawn with less detail. Trees at the edge can be drawn with lower detail level, or skipped completely for long distances. The foreground coulisses can be drawn increasingly transparent with distance, and dropped one by one until only the solid background coulisse remains. For very long distances even the background coulisse can be dropped, and the forest simply drawn as a forest texture on the ground.

The forest from above

When a forest is seen from above, horizontal coulisses can be used instead of the vertical ones. These simply consist of one or more partially transparent textures, that are drawn at different heights above the ground, the highest at approximately maximal treetop level. The textures depend on the forest type, and should be specified in the forest type data, along with normal vertical coulisse textures.

When the camera moves closer to the ground, vertical coulisses are created at a point directly beneath the camera, and then enlarge as the camera moves lower. The horizontal coulisses stop or fade away at the edge of the vertical coulisses.

When seen from very far above, only one forest texture is used.

Ideas for improvements

Generating trees

In the real world each tree is an individual. Some are young, some are old, some are tall, some are short, some have well developed branches due to growing in an open space, and others have only a few branches of leaves at the top. Some are bent, some are straight, some are fallen and some are sick. (Okay, that pretty much covers it ;-). Now look at your average game with trees. One or two models, seen from different angles. The same pattern of branches is easy to note on each. Can we do this better?

The answer would be to generate the tree model dynamically. As input the generation algorithm would have soil quality, moisture, shade, poisonous materials in the soil, tree age, time of the year, time of the day, etc. From these, and the tree species, parameters would be calculated for some L-system type method, that would be used to create the model. The parameters used to specify the shape of the model could be: number of branchings, branching pattern (how many new branches there is at each split, and what angles they have relative to the previous one and relative to the trunk, how much mass goes into the trunk and how much into the branches), effect of gravity, change in branch length at each step, etc. In addition, each of those parameters should also have a random factor that would be given as a parameter. And lastly, the trunk and leaf/end branch textures should be specified.

An advantage of using L-spaces is that it would be easy to implement a variable level of detail system too. The model building algorithm would iterate to some branching depth that depends on the desired level of detail, and then use scaled 2D textures for the smaller branches and leaves. There could be just one 2D texture, or different ones could be used to represent different amounts of branches and leaves (the largest texture would be a whole tree (used for low LOD), and the smallest a single leaf).

Running an L-system is roughly linear to the number of branches created, and it could be hard coded instead of interpreted, using the parameters given to it to control the shape, so the performance costs wouldn't need to be unrealistically high. The LOD algorithm should be able to implement so that it can add or remove branch levels without recomputing the whole tree.

Bonus points for implementing a similar system for flowers. ;-)

Other uses for the forest rendering system

Can this rendering system be used for other things than forests?

Weather effects

One idea is fog, rain and snow. For this we might want to generalize the coulisses into spheres. Some rain and snow particles are rendered inside the coulisses with particle systems, but the surrounding ones are drawn as moving textures on the coulisses. The radius for these coulisses could be somewhat smaller than for forest coulisses. Instead of spheres we might be able to use both horizontal and vertical coulisses.

Another possible use for spherical coulisses could be to render clouds. This might be better handled by some other way, though.

Macroscopic and microscopic scales

An interesting idea is to implement different scale levels. One example is a space scale, where the planet is seen from far away. The level of detail techniques described above will provide a seamless transition from space to inside a forest. The valleys and ridges of the initially flat green spot become more apparent as the camera moves down, the forest texture becomes gradually more detailed as coulisses levels are added to the forest under the camera, and finally individual trees become visible.

Now, imagine that the camera continues to move down, towards the grass covered ground. Gradually the ground becomes more detailed, as the polygons are subdivided and their height calculated at a finer and finer scale, and finally we can see individual grass straws, flowers, small pebbles, fallen leaves, ants and a big frog.

A field of grass can be treated in the same way as a forest seen from space, and when the camera is close to the ground, vertical coulisses and grass straw models can be used for the 'grass forest'.

The terrain could be created by a fractal terrain generation system, repeating maps, or some combination. But special areas, like the Smurf village or a fairy ring, could be mapped out by hand.

Implementation

Performance

A relatively realistic effect should probably be possible to obtain with the coulisses around 10 - 100 m away, depending on the forest thickness. The amount of trees inside the coulisses would be more or less constant, because a denser forest could decrease the coulisse radius's more than a sparse forest, while keeping the same quality. A plausible estimate is around 50 - 500 trees. With use of variable level of detail a modern graphics card should manage this.

It would also be easy to change the vision range to best suit the used hardware (within limits specified by the game rules, of course). The coulisse radius's could simply be changed. The level of detail of the trees could also be changed, as could the number of coulisses (but with less than three coulisses the quality would probably drop noticeably).

Other processing tasks involve reading the forest data from the map, creating trees, changing the LOD of the trees dynamically and moving the coulisses when the camera moves. These are relatively fast operations, and probably affect the time cost less than the rendering of the trees (depending on used graphics hardware).

Modularization

The forest rendering could be implemented as a separate module. Its central purpose is to create and update the coulisses, and to provide a clipping area for trees and other items that are hidden by the coulisses.

Inputs

Outputs

[Hmm.. other things than trees could be handled like this too, but I don't think it really is the forest rendering modules task to do that.

TODO: So change the system so that it just provides a 2D clipping area, or radius.]

Implementation plan

Implementation could start with the simplest case (one coulisse) and add more features in subsequent stages. Each stage can address weaknesses found in previous stages. Here is one possible implementation sequence.

  1. Basic forest background. One coulisse, with an unchanging forest background. Clipping trees. Fades on or off depending on presence of forest.
  2. Multiple coulisses. Many coulisses with different bitmaps. Clips trees and items that are hidden by the coulisses. Optionally implement coulisse scrolling with movement.
  3. Changing forest types. Transitions between different forest types supported. Coulisse segments have different amounts of the forest types depending on their location.
  4. Fancy stuff. Fine tuning of the previous features, and optional features like implementing seasons with layers (snow, leaf, etc), forests moving in the wind, dynamically generated tree models (in a separate module), generalization to fit other uses (such as snow/rain), and other things.

Conclusion

The described technique has the advantages that it creates a potentially good looking forest background, and can reduce the clipping area and visibility in a forest, making it possible to draw more trees in a smaller area and increasing the realism. It also looks better than traditional approaches (fog) for low detail settings.

The drawbacks are that the coulisses used for the background could behave unrealistically when the camera moves (especially when the ground height varies), and that trees appearing and disappearing could still look unnatural.

Implementation can start from the simplest cases, and add the optional ideas as time and developer interest allows.

All in all this seems like a nice solution to the problem of rendering realistic forests, and seems to produce better results than alternatives, such as fog.