Friday, August 29, 2008

Tree placement

In addition to the elevations that are read from wavelet-compressed dataset and then refined by fractal algorithm, the engine computes 3 other fractal channels in parallel. These contain 'normal' fractals that will be used as source for coherent random values for various engine parts.

First of these channels was used to enhance the tree placement algorithm. The algorithm in fragment shader first computes the probability of tree being there, according to elevation, slope and terrain curvature. If the actual tree occurrence is determined by comparing the probability against a fixed threshold, it results in large continuous forest areas. The fractal channel provides threshold value that changes continuously and modifies the probability threshold, that results in clearings and woods, but an occasional lonely tree too.

Here is a short video, flying from somewhere in Europe to Africa:

An earlier video without the trees, where angrypig madly flies and turns around


Anonymous said...

Being rendered out of probability, will the world be consistent between servers, or most importantly, between different clients on a server? To put it more succinctly, if I hide behind a tree on my computer, will another player see me as hiding behind a bush on his computer as well? The reason I ask is becaue if I'm in a battle simulation, I don't want to be seeking cover behind a bush that doesn't exist to my enemy.

Brano Kemen said...

The randomness is deterministic and does not depend on variables that would change in time or in between computers. The algorithm basically takes the world coordinates of a grid cell for which the tree occurrence is being computed, does a permutation that produces a semi-random number vector that is then used to displace the tree within the cell, and to determine it's type and height. The same random number vector is computed every time everywhere, since it depends only on the input coordinates.