Sign in to follow this  
ayrton2388

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 haven`t implemented a quadtree/octree yet, but i definitely will.
So here`s 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 let`s say 10-15 more random plants around the one placed on the vertex?

Either way, the number of plants needed might be big. Let`s say 300 000. Just an example. Should i store all those 300 000 positions somehow? Guess it`s 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 this post


Link to post
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 haven`t implemented a quadtree/octree yet, but i definitely will.
So here`s 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 let`s say 10-15 more random plants around the one placed on the vertex?

Either way, the number of plants needed might be big. Let`s say 300 000. Just an example. Should i store all those 300 000 positions somehow? Guess it`s 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.

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