Help with a Grass System

I want to add good looking Grass into my Applet.



The current system looks like this:





It’s created using Geometry Instancing for about…10k quads(for a small area, 4 times the area in the picture).

I’m not pleased with the FPS which drops significantly(30 fps in fullscreen mode?wth?

When i tried it without Geometry instancing, it gave about 10-15FPS in fullscreen mode).

is there a better way, known to anyone, for programming grass?

Keep in mind that I’ve already used the search option, the old posts don’t help.



Thanks ahead,

Mythos.

Well, if you're grass isn't moving and won't change in another way,

you could try node.lock();

tim8dev said:

Well, if you're grass isn't moving and won't change in another way,
you could try node.lock();


sorry, but that doesn't help at all...

Geometry instancing 10k quads is too much… There are limits to everything, and this is one case.



You should partition it so a group of grass fits the entire screen. It will be efficient due to frustum culling so at most only 4 groups of grass will be rendered on the screen (not bad at all). Whereas geometry instancing all the grass in the level is bound to process a lot of triangles that are not even in the screen.

Momoko_Fan said:

Geometry instancing 10k quads is too much.. There are limits to everything, and this is one case.

You should partition it so a group of grass fits the entire screen. It will be efficient due to frustum culling so at most only 4 groups of grass will be rendered on the screen (not bad at all). Whereas geometry instancing all the grass in the level is bound to process a lot of triangles that are not even in the screen.


several questions:
1. how do i partition it?
2. currently,I've changed the grass to a model and am using Shared Nodes instead of Geometry Instancing.
When i run the game, no matter where my camera is looking at, or my position, the FPS is very low.
The whole scene has about 700k triangles.


EDIT:
forgot to mention also, the grass is animated.
MythoS said:

several questions:
1. how do i partition it?
2. currently,I've changed the grass to a model and am using Shared Nodes instead of Geometry Instancing.
When i run the game, no matter where my camera is looking at, or my position, the FPS is very low.
The whole scene has about 700k triangles.

1. Just arrange all the grass into blocks the size of the screen, use the geometry instancing API to create the groups.
2. The best way to arrange your scene is so that you have the least number of batches per frame. That's why creating a separate model for each blade of grass lowers your fps a lot. Also, make sure you're updating the scene (updateGeometricScene on the rootNode) and have bounding volumes on all your models, you should have the culling hint (setCullHint) set to Dynamic to enable frustum culling.

maybe dont draw single blades of grass, make bigger and less patches of grass.



Or try to do it with a shader, like Mrcoder demonstrated some time ago:

http://www.cg.tuwien.ac.at/research/publications/2007/Habel_2007_IAG/Habel_2007_IAG-Preprint.pdf

http://www.youtube.com/watch?v=yBIHr8kI3XA

how are you making 700,000 triangles out of that scene? that doesnt seem manageable for a game thats alot of triangles for ground + character + grass

Eggsworth said:

how are you making 700,000 triangles out of that scene? that doesnt seem manageable for a game thats alot of triangles for ground + character + grass



Easy, the character is about 4k tri, the TerrainBlock - 10k, and the rest is the Grass  :D
so yeah, its really not efficient.
I've also used the VBO technique and it helped only a little.
I guess the only way to really implement grass in jME is with shaders.

Shaders will only make things slower, not faster. The only way to handle grass is proper partitioning and it doesn't seem you tried that yet.

its really not efficient.
....
I guess the only way to really implement grass in jME is with shaders.

:?

That's a leap and a half!

how do you get 10k quads to add up to 686k triangles?

MrCoder said:

how do you get 10k quads to add up to 686k triangles?


simple, i just stopped using the Quads, and used a low poly animated grass instead.
couldn't make the quads look good.

Momoko_Fan said:

Shaders will only make things slower, not faster. The only way to handle grass is proper partitioning and it doesn't seem you tried that yet.

Ok, can you explain a little more about proper partitioning?
MythoS said:

Ok, can you explain a little more about proper partitioning?

You said you used geometry instancing in the first post, so all you need to do is apply that knowledge but instead generate the geometry batches for groups of grasses instead of for the entire level.
In pseudocode:


Map<IntPair, GeometryInstanceBatch> batchMap

for each grass quad:
     x = grass.getPosition().x / blockSize
     y = grass.getPosition().y / blockSize
     batch = batchMap.get(new IntPair(x,y));
     if (batch == null):
         batch = new GeometryInstanceBatch();
         batchMap.put(new IntPair(x,y), batch)
    
     batch.addMesh(grass)


Then you grab all the geometry instance batches in the map (batchMap.values()) and add them to the rootNode.