# Need some help designing a 3d vegetation system.

## Recommended Posts

I decided to use some 3d models for the vegetation. Nothing very very fancy. Not very detailed model, but a bit more than the 3 quads, star-formation grass.

I do have some individual, bigger plants, but also small patches of grass. Each type of small patch as a model. I havent implemented a quadtree/octree yet, but i definitely will.
So heres my question.

How should i store the plants/grass positions?
- should i manually place them? store all the positions in a vector or something?
- should i use a color map?

If i use a color map, generating just a patch of grass or a plant might not be enough. Im using a 1024x1024 heightmap for the terrain, and a scale of 60. So the plants could be wide apart. Should i also generate lets say 10-15 more random plants around the one placed on the vertex?

Either way, the number of plants needed might be big. Lets say 300 000. Just an example. Should i store all those 300 000 positions somehow? Guess its not a good idea.

Should i store only the positions from the color map, and generate few random positions around each, every time i enter another block from the quadtree?
When im drawing the vegetation, should i have a fixed block size, and draw just the surrounding quadtree blocks, around my character?

##### Share on other sites
[quote name='andreilng' timestamp='1313057625' post='4847588']
I decided to use some 3d models for the vegetation. Nothing very very fancy. Not very detailed model, but a bit more than the 3 quads, star-formation grass.

I do have some individual, bigger plants, but also small patches of grass. Each type of small patch as a model. I havent implemented a quadtree/octree yet, but i definitely will.
So heres my question.

How should i store the plants/grass positions?
- should i manually place them? store all the positions in a vector or something?
- should i use a color map?

If i use a color map, generating just a patch of grass or a plant might not be enough. Im using a 1024x1024 heightmap for the terrain, and a scale of 60. So the plants could be wide apart. Should i also generate lets say 10-15 more random plants around the one placed on the vertex?

Either way, the number of plants needed might be big. Lets say 300 000. Just an example. Should i store all those 300 000 positions somehow? Guess its not a good idea.

Should i store only the positions from the color map, and generate few random positions around each, every time i enter another block from the quadtree?
When im drawing the vegetation, should i have a fixed block size, and draw just the surrounding quadtree blocks, around my character?
[/quote]

Theres lots of ways of doing it. You probably want a separate solution for grass to plants and trees though. Per vertex or per texturemap pixel you could store a chance of grass/plane, or a density value. As you approach each area, regenerate a list of instances for that section. For grass / trivial plants you would want to have this lodded based on distance - no need to render grass at 40km away.

Plants/Trees can be placed on the surface of a triangle, not just on each vertex. Interpolating a triangle is fairly cheap. You could even go and use a voronoi structure for dividing your surface area between different plant types and densities.

Grass on the other hand, i'd recommend constructing in a way where a single patch can be fitted to the shape of the terrain for the area around the camera. Once you have this, its trivial to cut away the areas you don't want via vertex shader or index buffer trickery. The reason for the patch approach is the sheer number of draw calls/instancing batches required to otherwise fit a reasonable amount of grass to a polygonal mesh.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627655
• Total Posts
2978458

• 10
• 12
• 22
• 13
• 33