• Advertisement
Sign in to follow this  

Tree/vegetation placement on a quadtree terrain

Recommended Posts

Hi everyone,

I'm pretty happy with my system for making an 'infinite' terrain using quadtree level of detail. At the moment though, the terrain is bare with no vegetation. I'd like to place trees, etc... on my landscape in areas where the slope is sufficiently small but I'm having trouble coming up with the best way to do it. Here's my best idea right now:

When a new quadtree node is created, if the slope at the central point is below a certain value, this node is eligible for vegetation. Choose a set number of random locations within the node and add trees. This means that a maximum number of trees exists per node and that larger, less detailed nodes will have a lower density of trees. However, there are problems, for example in large nodes, the centre point may not represent the terrain that the node encompasses. Also, it would be nice to have a system that will place the trees in the same 'random' locations every time a node in a particular location with a particular level of detail is created.

Perhaps you can share your ideas for how to automatically place trees? Thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement

I've seen this done using vegetation maps, so the artists have control over where the vegetation is placed, e.g. if you want the tree line of a forest to lead onto a grassy plain; the plain is flat-land and supposed to be devoid of trees but the approach you're suggesting (of looking only at the terrain gradient) would wind up placing trees on it.

The vegetation maps could perhaps be inferred from the ground material (grass, soil, rock, etc) and other factors such as the gradient, elevation, distance to water source, etc.

You could approximate the slope of a quadtree node by sampling the terrain height at the corners (rather than the middle) and calculate edge-to-edge gradients from that (dy/dx). If the gradients are small then you assume the whole node is relatively flat.

If you use the ID of the quadtree node as the seed for a PRNG then it will generate the same "random" sequence of values every time. I imagine you would not want to use the LOD as part of the seed for the PRNG because you would see trees popping into a different arrangement as you get nearer/further away from them.

Edited by dmatter

Share this post


Link to post
Share on other sites

So do you want runtime generation or offline? Rather, minecraft or all calculated beforehand? Because those are 2 different solutions.

I get the idea that this is a minecraft/runtime generated world type thing. Meaning your calculations are going to have to be fast, and since you want the same results everytime, deterministic. The first thing you could do is generate a deterministic noise. In which case you'd want to look up the halton sequence (just google it, I can't find a totally good coding overview but it's simple enough). This will give you an evenly space, random looking distribution for your trees.

Then you'd want to sample your heightmap to check for slope. The halton sequence is deterministic and I assume your slope isn't changing, so a tree will always be there. Alternatively you can also generate a "foliage" map everytime you generate a new piece of terrain, which is to say do the above then store the result in its own texture so you don't have to redo it everytime the user comes back to that area.

From there you can get fancier and fancier. Check the terrain's material to see if it's the right place to put a tree, no on rocks or water, yes on grass and dirt for example. "Elevation" is another consideration often used, eg transition from broadlead trees to pine trees could be done if elevation > x. Then there's multipass generation. EG Generate boulders first, then trees where boulders aren't, then undergrowth beneath trees and grass where there aren't trees. You can go nuts, check for distance from water, whatever you want. You can take the above, then stored in a "foliage object map" will also work for "offline" generation as well. Just read your texture back to place trees. Same works for rocks, grass, whatever detail objects you want.

But what you don't want to do is have some trees disappear and reappear as you get nearer and closer. Distance culling is usually done uniformly by object size, so the smallest objects disappear all at once first, then etc. etc. Also trees never usually disappear as they're considered "too big" by most games standards. Star Citizen for example will have them disappear certainly, but then most games don't allow you to go from orbit down to a (somewhat) realistically scaled planet sans loading screen or travel restrictions. So to finish I'd take a look at impostors and ... well their was also a fantastic, crazy realtime editable simulation of entire ecosystems done at I want to say siggraph in the last year or 2. But my google fu fails me, if anyone knows of the paper it'd be awesome to see it.

Edit- With that being said, while not as impressive as the paper I failed to find these 2 recent GDC presentations have procedural tools: Ghost Recon Wildlands and Horizon Zero Dawn

Edited by Frenetic Pony

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement