Need help with Grass utility

Hi friends
I watched a video about adding grass in JME3.0 RC2 . here is the link


sorry for low quality of image.

I do not see that option in JME 3.0 and 3.1
Can you help . Thanks a lot.
Also I found other tools like SimArboreal-Editor and Forester.
Can anybody create a small 10 min video of how to use them in my project ?(I did not find documentation for them in wiki) .
I will really appreciate you .
Thanks.

Unfortunately there is no grass in 3.0 or 3.1. If I remember correctly, Foresterā€™s documentation is slim to none and caused constant crashing with 0 functionality for me. Your best bet is to look around on the internet for how to create your own foliage system and write one from scratch. Iā€™ve written a very very basic one, but itā€™s outdated and not well optimized. Itā€™s not a hard feature to write, and if youā€™re proficient with GLSL, adding wind and other effects is also very straightforward with the vertex shader. Hereā€™s a basic rundown on how I did mine.

  1. Create a template mesh (a bunch of randomly scaled and rotated quads with random offset) and batch it into 1 mesh.
  2. Assign a grass texture with an alpha channel (such as this: http://www.reinerstilesets.de/3dtextures/billboardgrass0001.png). With the texture applied, your final template mesh will look something like this: https://img-new.cgtrader.com/items/39963/large_dense_grass_texture_3d_model_fbx_obj_max__6cf12509-5b33-4fb5-a567-3d23697393c7.JPG
  3. For every place you want grass (on a grid based on the size of the template mesh), attach the mesh. With 3.1 you may also be able to use instancing if your card supports it, but in 3.0, I used batching.

And hereā€™s a much more indepth explanation on the same implementation done in CryEngine: http://www.cryengine.com/community/viewtopic.php?f315&t=100319

1 Like

Instancing is bad for grass. Performance-wise this is somewhere between separate objects and one batched meshā€¦ but closer to the several objects side. Instancing only makes sense when you have larger objects. (like trees)

To use SimArboreal-Editor with JMEā€¦ you run the editor. Create a treeā€¦ and then save the .j3o.

Then load the j3o in the scene editor. Place it where you want.

Repeat as needed.

There isnā€™t any scene editor integration and no automatic tree placement from the scene editor.

Though for an example of using SimArboreal trees and a my own grass implementation, you can look at the source code for the IsoSurface-Demo.

(Latest code is really on github: GitHub - Simsilica/IsoSurfaceDemo: Technology demo of the IsoSurface terrain library.)

Note: it currently only works with JME 3.0 unless you make some tweaks.

And here is what it looks like running:

3 Likes

Ah, well you learn something new every day! Batching was definitely a huge performance improvement when I wrote my own grass system last year. I just figured instancing would work well too, but I guess I donā€™t understand instancing as well as I thought.

Instancing is one draw call to the driverā€¦ but the driver itself still has to setup each object and render it one at a time. So yes, you do gain a lot of performance in something like JME because you lose the impact of JMEā€™s per-object costs.

But itā€™s small in comparison to batchingā€¦ and for grass where you can get away with three or four vertexes per object, batching is an easy win.

By doing this can I also have the wind animation of tree ? For trees wind animation do you use skeleton ?

When I import the tree in jme which I made in TreeEdtior it says : error opening .j3o.
I put all textures in Texture folder.
Also when I try to link it to my scene it gives Error:
com.jme.asset.AssetNotFoundexeption:MatDef/TreeLightin.j3md

You also have to put the arboreal-assets.jar file in your project libraries.

1 Like

Ohā€¦ it is fantastic . thanks Paul .
It also imported wind animation. can you explain about how does this animation work?
because I do not see any bone in tree.
I am sorry if my question seams stupid . (I am a novice).

Edit: Is it vertex animation ?

Hi Ali!

Iā€™m pretty sure, that there are no bones needed. I think he did it with shaders. I just downloaded the source, but when you look into ā€œassets/MatDefsā€, there are a lot of *.vert and *.frag files. I think the reason for using shaders instead of bones is the much higher performance.

1 Like

I have another questionā€¦
Can I replace leaves texture with my own texture in SimArboreal-Editor for windows version ? If Yes can you say how?

Take a look at ā€œSimArboreal-master\assets\Texturesā€. In this folder you should see an file called ā€œleaf-atlas.pngā€. I would swear that this is the location you may change the the leaf-texture. But keep in mind, Iā€™m no expert in this, I just looked around in the source code.

EDIT: Forget it! Sorry, I wasnā€™t in the SimAboreal-Editor-file anymore. But Iā€™ll take a look at it and give feedback, if I will be able to :wink:

EDIT 2: As far as I undestand at this moment, SimAboreal-Editor is using the ā€œSimAborealā€-Library, which contains the above mentioned atlas-file. Iā€™m currently not at home, so I canā€™t ā€œinstallā€ both of themā€¦ maybe this evening. I think the editor uses the file from the library. If so, you could replace it with an alternative texture and check out how it works.

EDIT 3: Read the next posting! Paul should be the best person to answer this question :wink:

1 Like

There is no official way to replace the leaves in the editorā€¦ but you can provide your own atlas texture to the material or I believe you can include your own (with the same name) in your own assets directory and it will override the one from the jar.

You might take a look at this thread for grass. There even is a plugin.

1 Like

Thanks @mathiasj.
I have a request from dear core developers of JME.
Please document such cool things like GrassBanana and and IsoSurface and so many others in Wiki.
So it will make it easier for beginners to learn them and save a lot of time. Thanks

Just in case you get stuck with GrassyBanana, here a link with a working example at the end of the page: Thread
You just need to create a terrain with the build-in terrain-creator and link to it within the script.

1 Like

Thanks dear @Tankwart . You helped me a lot.

To be honest. I wouldnā€™t be able to help you in this thread, without getting the informations from
stomrage (the author of the plugin). So maybe you should thank him more than me :wink:

Yes of course . Thanks a lot dear @stomrage .