Contents
Random Scattering: Creating Realistic Landscapes
 
 
Printer-Friendly VersionPrinter-Friendly Version
 


Part of:



[More information...]
 

Latest News
spacer View All spacer
 
November 22, 2009
 
Video Game Watchdog National Institute On Media And The Family Shutting Down [11]
 
Modern Warfare 2 Infinity Ward's 'Most Successful PC Version' Yet [12]
 
New Tech, Design Details Of Project Natal To Emerge At Gamefest In February
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 22, 2009
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
3D Environment Artist
 
Sucker Punch Productions
Network Programmer
 
Sucker Punch Productions
Texture Artist
 
Sony Online Entertainment
Brand Manager
 
Monolith Productions
Sr. Software Engineer, Engine - Monolith Productions - #113767
 
Crystal Dynamics
Sr. Level Designer
 
Gargantuan Studios
Lead World Designer
spacer
Latest Features
spacer View All spacer
 
November 22, 2009
 
arrow Upping The Craft: Susan O'Connor On Games Writing [6]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part II [6]
 
arrow iPhone Piracy: The Inside Story [48]
 
arrow And Yet It Grows: Analyzing the Size and Growth of the European Game Market [5]
 
arrow NPD: Behind the Numbers, October 2009 [13]
 
arrow Reflecting On Uncharted 2: How They Did It [5]
 
arrow Sponsored Feature: Rasterization on Larrabee -- Adaptive Rasterization Helps Boost Efficiency
 
arrow Postmortem: Wadjet Eye's The Blackwell Convergence [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 22, 2009
 
Accepting the Inherent Value of Games
 
Planckogenesis, Part II: Song Structure & Gravy Train [1]
 
Designing Games Is About Matching Personalities [1]
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Features
  Random Scattering: Creating Realistic Landscapes
by Mick West
5 comments
Share RSS
 
 
August 6, 2008 Article Start Previous Page 2 of 3 Next
 

Random Complications

This simple model works reasonably well, but the distribution is still patchy. What's going on? Well, obviously in real-life, trees do not have "kill zones" surrounding them. Rather they have something more like an inhibit field, where the successful growth of a tree is exponentially more unlikely the closer it is to other trees. The success of a tree is a function of the sum of all the other trees' inhibit fields at that point.

Secondly, trees don't grow one at a time in nature; they grow over the course of several years, with new trees germinating every year. Old trees die and open up space, which other trees then fill, competing for the space. Over many generations, this natural renewal of trees evens out the distribution, making it even and natural.

While natural tree distribution over the course of several decades is something we could simulate, this is for most games unrealistically expensive.

We really don't want to be running a simulation of a forest ecosystem just so we can get an even distribution of trees. We need to look at creating a simple model of the results without regard for the underlying physical process.

Teleological vs. Ontogenetic

Two competing methodologies in procedural content generation are teleological and ontogenetic. The teleological approach creates an accurate physical model of the environment and the process that creates the thing generated, and then simply runs the simulation, and the results should emerge as they do in nature.

The ontogenetic approach observes the end results of this process and then attempts to directly reproduce those results by ad hoc algorithms. Ontogenetic approaches are more commonly used in real-time applications such as games. (See "Shattering Reality," Game Developer, August 2006.)

Step back for a second. What we want are trees that are randomly scattered, not overlapping, yet still evenly distributed. What if we started off with the trees perfectly evenly distributed (say on a square grid), and then simply move each tree a random amount, but not so far that they can overlap?

This solution actually works quite well. If we spread the trees out on a grid with a distance D between each tree, and we move each tree in the x and y directions by a random amount between -D*0.4 and D*0.4, then we know no two trees can be closer than D*0.2. See Figure 3 and Listing 1, which contains the algorithm.

Listing 1

void CreateScatter(float x, float y, float w, float h, int rows, int cols)
{
float xd = w/cols;
float yd = h/rows;
for (int ix = 0;ix <(cols+1);ix++) {
for (int iy = 0;iy<(rows+1);iy++) {
float p = 0.4f;
CreatePoint( Vector2(x+xd*ix+rndf(-p,p)*xd,y+yd*iy+rndf(-p,p)*yd));
}
}
}

Figure 3 looks something like a cross between the pure random scatter and the minimum distance scatter. The trees are evenly distributed, but we still see some minor clumping, including two trees that overlap slightly. But overall this algorithm produces much nicer looking results than our first attempt, and it's simpler and cheaper to implement than the second.


Figure 3: The trees here in this random perturbation-style scatter start off in a regular grid and are moved randomly by a small amount. The result is a very even distribution.

It also has another advantage: It is repeatable. Repeatability is important in a spooling environment where you want each patch of ground to look the same in the same location. When you see a couple of trees, then leave the location and return later, you would expect to see the same two trees in the same place.

We can accomplish this in a game environment by using the low order bits of the original x, y position of the tree as a seed for your random number generator.

This can then be used to generate both the positional offset and the full appearance (the geometry and textures) of our procedural tree. Thus any tree generated from that unique point will always visually be the same unique tree in the same place whenever you return to it.

 
Article Start Previous Page 2 of 3 Next
 
Comments

Sebastian Bender
profile image
Interesting article especially for novice programmers since it shows nicely that complex phenomena can be coded with rather simple solutions.

Anonymous
profile image
As an artist, this just cracks me up. Looks like good tech for stub-art. Trees aren't random in any sense. The factors that put a tree in place are diverse and an artistic eye is needed to discern what makes sense and what doesn't. Trees don't grow out of rocks, trees don't grow under the shade of other trees, trees will cluster in the lower elevation ruts and water-paths along hills and mountains, not the high points...unless the dirt/rocks/angle of that particular mountain make those areas land-slide-prone. Trees will cluster along fence-lines because the saplings will get cut down by mowers or eaten by animals on one side of the fence. Trees cluster around rivers, then don't grow much at all around huge flat planes in some cases. There's so many variables that are biological that should be taken into account instead.

But if one is making an MMO and the artists don't have the time or the ability to think through that kind of thing and they need a LOT of trees in a hurry, this tech might help as a substitute for their better judgement and precious time.

David Delanty
profile image
Pretty cool insight there, Mick. I like how you emphasize the fact that there is a lot of "organization" required to make an effective "random" output. You can't just throw darts blindly at a board, the effect of random needs to be organized in such a way that it still follows a sort of order.

While I do agree with above comment that the analogy of trees does require a bit more detailing than what's in the article, and that you could probably write an entire novel on the physics of tree placement, it's the *principle* of making randomized placement of objects that I know you're going for, and it's very well explained.

Patrick Coan
profile image
There really is no such thing as "random" in my opinion, only behavior which is beyond our comprehension. So when considering a forest, all of the Anonymously mentioned factors will apply, but so does this method which Mick describes.

The described distribution model should only be used as a tool for initial plotting, if the target result is something of cinematic aesthetics. After the samples are placed, let the artists carefully move things around until the illusion is created. If you are flying a jet through the mountains, then I don't think that anyone cares about the trees along the fence.

Aaron Casillas
profile image
Anonymous is correct. Trees in nature follow two simple heuristics, follow the water and stay near mom.

If you look closely, they emerge in and out of valleys more than other areas.

Second, saplings will always be found near their parent tree. This pattern repeats over and over again.


none
 
Comment:
 


Submit Comment