Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

simon_brown75

Animating a field of grass...

This topic is 6480 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 have a little D3D program i''ve written, which features a field of polygon grass (the Direct3D Grass program from my website at http://www.sbdev.pwp.blueyonder.co.uk). At the moment the grass is totally static. The program can run with 50k, 100k, 200k or 300k blades, and runs pretty decent using VB''s. There''s two obvious ways I can see of animating the grass, first, keep the vertex data buffered, process the buffered data and copy the new data into the VB''s per frame. Even with the fastest VB access methods this is way too slow. The second is to use the world matrix and rotate individual blades of grass about their bases. This is even slower, since it means drawing the blades one by one. Is there a way to achieve the effect I''m after and still keep decent performance? With static grass I can get 300k blades running at 21 fps, but with either of the above methods the best I can manage is 50k blades at 23 fps. So we''re talking >5x times slower.

Share this post


Link to post
Share on other sites
Advertisement
Have you seen nVidia''s grass demo?

quote:

This demo generates up to 10,000 individual blades of grass and multi-pass clouds on the fly, pushing the limits of transform and lighting. The grass and clouds even react to the breeze. The high depth complexity and dynamic level of detail push the limits of reality. Press the "space bar" to take control of the weather conditions, or press the "h" key to view other commands.



Power of 3D :: Top row, second from left





"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick

"It is far easier for a camel to pass through the eye of a needle if it first passes through a blender" -- Damocles

Share this post


Link to post
Share on other sites
That''s a very nice demo, the source code would be useful

Although it has an extremely short view distance, it does at least show that it''s possible to have lots of non-static geometry. Thing is though, they have <10,000 blades of grass, each made of around 10-20 tris each, whereas I have ~200,000 made of 1 tri each. It''s much easier in such a demo as nVidia''s to have the grass independently animated, since they can still batch send their tris (at least to some degree).

When video cards can generate scenes like this, but with view distances like Project IGI, that will really be something.

Share this post


Link to post
Share on other sites
Well, what first comes to mind for me is to animate small patches of grass instead of just particles. I don''t know if this would work too well though.

Or maybe you could just animate the grass that is closest to the viewer and leave the other grass static (until it becomes closest to the viewer).

Share this post


Link to post
Share on other sites
I have an idea...

Use one huge static vertexbuffer that contains all the vertices needed for the wave animation. Then draw your grass using indices. This may be less fluid but it will produce far less overhead.

Share this post


Link to post
Share on other sites
Would it be possible to animate a small patch of grass and then draw it multiple times across the scene? That way you''d only be animating a few thousand blades at the very most, and reusing them. But I do have a question: why do you need this much grass animated in real-time? It sounds like you can''t have anymore geometry, and a scene comprised solely of grass doesn''t sound very interesting.

Share this post


Link to post
Share on other sites
Thanks for the ideas guys

Tom/
It''s just an experiment in adding a little organic realism and movement. Plus I wanted to see how it''d look. If I had a detailed landscape I could of course only have 10-20k blades with current hardware.

Countach/
That''s a really clever idea, and it would work, but I think the vram requirements would make it unfeasible. My VBs already total around 10MB.

Actually, they are all good ideas, Ranok and Toms suggestion would work without compromising performance too much. I would like to be able to control each blade individually, but I think that''s going to be too slow, so if I can get the general look and feel of grass blowing in the wind by either tiling or grouping, that''s probably a good compromise.

Share this post


Link to post
Share on other sites
I think the idea of the ''one big static buffer'' is still viable; if you have a huge patch of grass you divide the patch into tiles until theyre small enough to fit into vram. To make it less obvious that you use the same patch over and over again you can give each patch a different wave pattern (remember, this only means that the indices change). This also makes the LOD implementation easier because you can just replace patches in the distance with a sprite.





ALL YOUR BASE ARE BELONG TO US

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!