Using IsoSurface Grass and trees with standard terrain

Hello! This thread is for people who want to integrate IsoSurface style grass and trees into a standard JME3 terrain. Grass will only spawn on areas where the terrain alphamap has grass (Green channel).

So far, I have the IsoSurface demo compiling on 3.1 and I am trying to isolate the grass and trees from the isosurface.

So, lets start with the grassZone. How can I spawn the grass onto Jme3 terrain?

You may have to extract a lot of code as the “Zone” stuff is all based on my open source paging library and has nothing to do with JME’s terrain. So you may have to take the ‘iterate over the mesh and find places to put grass’ part out and use it somehow another way.

The pager library was meant to deal with this multi-level paging problem. I don’t think JME’s terrain deals with it at all so you will somehow have to hook into it to load the grass when it loads the terrain. (I’ve never used it before.)

Non-trivial, probably.

Haha good, I like a chalenge! A few questions:

  1. What does the grass do? I see that they are spawned with different rotations at different positions and that they react to player distance and “wind”. What else does it grass do?

  2. Why can you have so many grass blades? Is batching the only reason?

  3. What is multi-level paging ?

I think that’s it.

Batching. Each blade of grass is one triangle in a mesh for the zone.

In this case, the grass can’t page in until the terrain is paged in because the grass needs to know where to plot. So there is a parent-child relationship between grid zones but all grid zones are built in the background and it’s taken care of by the pager. This also allows the parent zones to be larger and stuff… so you could have 128x128 size terrain tiles with 32x32 grass tiles or whatever to allow different LOD schemes for both. The pager makes sure that the grass zones don’t try to build until the parent terrain zone has built. It also makes sure that if a parent is canceled then the children are canceled, etc…

Also note: my grass implementation resorts the grass in the zone the player is in as the player moves around. (Though that may be only in the game I was making, don’t know if I ported that back.)

Sorting the grass blades in the mesh is important for the semitransparent edges to look right. So the proper approach sorts the current zone as you walk around and sorts the neighbor zones once based on facing the current zone.

1 Like

Ok, thats good to know. I will try to pull out the bits and pieces I need and make it happen.

Let me get this strait:

Each blade of grass is one triangle in a mesh, a series of meshes is a zone, and the sum of zones is what we call grass.

The pager pages terrain and grass, so I need to make the grass pager page on terrain instead of isosurface. I also need the feed the alphamap info so that the grass knows where to plot.

This should be fun :smile:

A “blade” is technically a clump of blades because my texture atlas has little clumps… and yes, it’s a triangle to save one vertex and require no index buffer.

A zone of grass is just one mesh, though. A zone is a cell in the grid. Terrain has its own grid of which the grass grid is a child.

re: pager, yeah, basically. If you didn’t care about editing terrain in the SDK this would be a lot easier as you could just make a heightmapped based terrain zone implementation pretty trivially.

I don’t know if it can help, but the OpenRTS’ Sower feature has a placing algorithm for grass and other assets on heightmapped terrain.

It is essencially a poisson-disc fast travelling, looking in a random way (Montecarlo) for best places to put an assets, accordingly to a set of user rules.

It’s a WIP but may worth a look. Here is the code

1 Like