Terrain vegetation

Started by
8 comments, last by NickGomes 12 years, 9 months ago
Hi,

I've just made a 3D terrain using a heightmap read in from a file.
The question I have is fairly simple, I want to populate the terrain with bits of grass and trees. How would you suggest I do this? As I want to have bits of grass sticking up out of the ground I was thinking I could get a grass texture and billboard it. The only problem then is that if I define a struct called vegetation which has a position, orientation and texture variable and store many of these in an array or list or something then will this not be a bit inefficient as I may have thousands of bits of grass.

How else could I do this or how is it normally done?

Thanks for any replies
x

"To know the road ahead, ask those coming back."

Advertisement
Sorry I've never bumped a post before but I thought this would be fairly simple but noone has replied.

When I try to find the answer to this on google all I get is pages about terrain texturing and multi-texturing etc.
What I want is actual bits of grass coming out of the ground. Any ideas?

If I havnt been clear enough then say and I'll try to elaborate.

Cheers

"To know the road ahead, ask those coming back."

Microsoft DirectX SDK (August 2009) had a sample named Instancing10 they do grass and trees(Plants )
Thousands of bits of grass really isn't that bad. Many 3D engines do grass this way. Those small billboards can be batched and drawn very quickly. However, if it is a problem because of extremely large worlds (meaning millions of clumps of grass), you can implement some kind of system that spawns batches of grass and other ground clutter in just the area around the camera, using a deterministic random number generator to place the doodads such that if the area is visited again the same pattern of placement will be generated. See http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter01.html for an idea of what this entails. As the camera moves out of an area, those batches of ground clutter are discarded and new ones are generated.
Thanks for the replies,

So I'm on the right track, My world is fairly small so I'll just store all the bits of grass in an std::vector and draw them in batch. Thanks JTippetts for the link, I did a similar thing once when I was making a space game to create a clump of stars around the camera that moved with it.

One more question is can you give me advice on how to make randomly generated 'clumps' of grass?
I presume I would find a random location, then generate say 100 bits of grass using the position as the centre of the 'clump.' The only problem is that I don't want them to be in a circle or a square but have slightly more natural shape. Any advice on how I would achieve this so it looks more like a paint splat shape or something??

Cheers for the help.

"To know the road ahead, ask those coming back."


I'll just store all the bits of grass in an std::vector and draw them in batch.


What exactly do you mean by this? If you make one draw call for each item in the std::vector, that isn't batching.
Ok, I think I've got my wires crossed a tad, how exactly do I batch draw things? Is there openGL calls for it or do I have to look into shaders?
Cheers.

"To know the road ahead, ask those coming back."


Ok, I think I've got my wires crossed a tad, how exactly do I batch draw things? Is there openGL calls for it or do I have to look into shaders?
Cheers.




The basic idea is that you batch draw by grouping several bits of grass into one vertex array or vertex buffer and using one draw call per group, as opposed to having one draw call per each bit of grass. So what you can do in OpenGL is fill a vertex array or vertex buffer with the vertices of all the bits of grass you want to draw in a frame, then use one draw call to render that batch.



EDIT: that being said, you might want to compare both approaches. I think I've read that draw call overhead is lower in OpenGL compared to DirectX, so maybe If you don't have that many bits of grass, the advantage of batching won't be that big. Someone please correct me if I'm wrong.
Cool, cheers everyone,

I'll come back and ask again if I get stuck but should be fine.
x

"To know the road ahead, ask those coming back."

Along with you terrain heightmap you could also store a vegetation/biome map. That would define areas where different ground textures and vegetation billboards could be used. Ideally you would pass just one big sprite sheet with many different types of vegetation billboards. You would then texture the ground and use instancing to randomly billboard that section of the terrain.

This topic is closed to new replies.

Advertisement