Jump to content
  • Advertisement
Sign in to follow this  
denisnovak

Best technique for foliage layout

This topic is 4528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!