Skip to main content
GameDev.net gamedev.net
🔒 Locked

Best technique for foliage layout

Started by denisnovak Dec 31, 2005 at 10:21 AM 6 replies 1.3k views
Original Post
denisnovak
denisnovak
I wonder which technique is the best way to cover a big landscape map with foliage (grass, trees,bushes)? All foliage objects should take the same position every time when level is loaded. I specially wonder how to do this, when you have thousand or more trees in the level? THX, Denis
acid2
acid2
Monte Carlo Tree-Coverage sampling. On a more serious note (yea, don't try googling for the former ;)), perlin noise might work if you use an expoential function to cut it off (as you would do with clouds). Another idea is to take your height map and apply the same theory as before, but on this heightmap. This will give the effect that trees and vegetation stop growing in high terrain.

Now, you would still get a grid like effect with this, so you could just randomly offset vegetation.
JohnBolton
JohnBolton
One way is to use something unique about the level (such as its name) as a seed to a random number generator. The output of the RNG will give you the same random placement every time and it will be different for every level.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
JohnBolton
JohnBolton
On the other hand, the locations of 1000 trees is only 12k of data, so why not just include the locations in the level data?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
zedzeek
zedzeek
simplest method + easy to visualize
encode a texture with the layer data
eg
red == amount of grass
green == amount of shrubA
etc (u can also pack multiple plants into a channel)
denisnovak
denisnovak
I was also thinking about texture with the layer data. Problem is when you have a heighmap 512x512 (or any other pixel dimension) and that map present quite a big space in nature (5km x 5km or even bigger).Then a single point in layer data map is not enought to present a single tree or a group of trees. Distance between trees are to big when you try to make a nice forest. And if you try to make a nice looking forest it is hard to do this with a layer data map. At least, this is my opinion.


zedzeek
zedzeek
also it will also be uniformly spaced out which will look crap if each pixel == one plant
u need to make each pixel == foliage coverage of a Xmeter*Xmeter sized area
eg for a single pixel u will most likely wanna have more bushs in the area than trees
soconne
soconne
Well FarCry does it by creating a HUGE XML file with the positions of each piece of vegetation. That's the way their Sandbox editor handles it.

So for vegetation you could just store a 3x3 matrix, which holds the entire transformation of each piece of vegetation. So for a 2048x2048 grid, where each cell is a single matrix for a single piece of vegetation, that would only take up 150MB of disk space. And you don't necessarily have to have ALL of it loaded into memory. PLUS with the way Windows handles memory allocation, if you don't have all of the cells that do not contain vegetation data would not take up ANY MEMORY depending on the way you implement it.

For instance, I created an Undo/Redo system for my own terrain editing software....I have a saved heightmap array of the terrain before editing AND after editing. The array consists of floating point values. I also have a boolean flag map, that contains a 0 or a 1 depending on if that cell in the heightmap was edited.

Well I found that if I dynamically allocate the saved heightmap:
float *before = new float[terrainsize * terrainsize];

Then Windows ONLY allocates memory for the array for the cells that I actually write to. If I don't write to them, Windows won't allocate memory. Kind of cool if you ask me :-)

Saves a lot of memory and headaches associated with paging.
Author Freeworld3Dhttp://www.freeworld3d.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.