A problem about rendering many grasses

Started by
6 comments, last by rubicondev 13 years, 11 months ago
Hello everyone! There is a problem in our game about rendering grasses. Our game has a scene with many grasses. All the vertexes of grasses used about 300MB memory. It's too large. So we can't load them at the time loading map. Now we divide them by some rectangles on terrain, each rectangle of vertexes use a mesh. When the rectangle is in the sight, all the vertexes in the rectangle will be generated. The problem is that, it takes too much time to render grasses when all vertexes are dynamic, or it causes CPU waiting in the lockVertex() function when all vertexes are static. Does anyone have suggestions? Thanks.
Advertisement
Use hardware instancing and manage level of detail yourself.

Or at least double buffer your locks. Failing that, then I guess you need to rethink the amount of grass you have.

Here's my stuff working at ~100 fps without any code optimisations at all yet. This is on DirectX 9.

Grass
------------------------------Great Little War Game
Hardware instancing is your friend. For the positions just use some sort of repeating grid offset and only render the grasses within x distance of the camera.
Portfolio & Blog:http://scgamedev.tumblr.com/
Thank you!

I want to ask to Darg. Do all the grasses in your scene constructed by billboard? Star type, triangle type or cross type?
A typical patch of grass can easily have hundreds of blades. Each blade is similar to the other, with slight variations in color, position, and orientation. Rendering a large number of small objects using your way is not optimal.

There are two solutions which will be faster than your method.

1. using Texture Mapping.
1) static grass: easiest. Map your grass textures, that is it.
2) dynamic grass: you need a series of grass textures(like a movie
frames), use a timer and map them one by one in a fixed/varied time interval.

2. using Geometry Instancing
Geometry Instancing refers to the practice of rendering multiple copies of the same mesh in a scene at once. This technique is primarily used for objects such as trees, grass, or buildings which can be represented as repeated geometry without appearing unduly repetitive, but may also be used for characters.

Starting in Direct3D version 9, Microsoft included support for geometry instancing. Here are 2 good articles for instancing from MSDN and INTEL

Instancing10 Sample
http://msdn.microsoft.com/en-us/library/ee416415(v=VS.85).aspx

Rendering grass with Instancing in DirectX 10
http://software.intel.com/en-us/articles/rendering-grass-with-instancing-in-directx-10/

Good luck.

[Edited by - standby01 on May 5, 2010 6:02:55 PM]
Jimmy Chen
Rubicon, that looks great... though the sharp drop off from grass to no grass looks a bit ugly. Do you multitexture? I'd love to see your source sometime.
I haven't actually gotten around to rendering grass yet but if I was going to I would like to try doing something similar to this http://www.kevinboulanger.net/grass.html with hardware instancing for the closeup 3D grass.
Portfolio & Blog:http://scgamedev.tumblr.com/
Quote:Original post by Burnt_Fyr
Rubicon, that looks great... though the sharp drop off from grass to no grass looks a bit ugly. Do you multitexture? I'd love to see your source sometime.

Thanks. :) Not sure where you see a sharp drop off though, it can be faded out as smoothly as you like. There is a path on the horizon if that's what you see.

That paper by mr Boulanger was what got me started on this tbh, though he does skip a lot of the nasty details in there, such as how to get your mipmapping to actually work!
------------------------------Great Little War Game

This topic is closed to new replies.

Advertisement