Sign in to follow this  

Terrain vegetation

This topic is 2340 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

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

Share this post


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

Share this post


Link to post
Share on other sites
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 [url="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter01.html"]http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter01.html[/url] 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.

Share this post


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

Share this post


Link to post
Share on other sites
[quote name='Monkan' timestamp='1311172314' post='4837973']
I'll just store all the bits of grass in an std::vector and draw them in batch.
[/quote]

What exactly do you mean by this? If you make one draw call for each item in the std::vector, that isn't batching.

Share this post


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

Share this post


Link to post
Share on other sites
[quote name='Monkan' timestamp='1311176053' post='4837996']
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.
[/quote]



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.

Share this post


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

Share this post


Link to post
Share on other sites

This topic is 2340 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.

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