SimArboreal instancing problems

I use @pspeed 's SimArboreal library (https://github.com/Simsilica/SimArboreal) to create a tree and its geometries. Everything works perfectly without instancing, but when using instancing, the following issues come up:

  1. The shadows of leaves are rendered as if they were at the origin (and not at the instanced position). The shadows of branches are rendered at the correct position.

  2. I couldn’t get the LodSwitchControl working with instancing. All trees are always rendered at highest detail (skinned 3d mesh instead of flat billboards).

An example project where the problems can be seen is here: https://github.com/andilem/tree-test . The left trees are without instancing, the right trees use instancing.

This used to work at one point.

I’d be curious to know if the shadows are still correct in the IsoSurfaceDemo prebuilt binaries:

…and if they would still work with the latest JME.

Unfortunately, I still haven’t converted that project to gradle yet so testing a new build may be non-trivial without the JME SDK.

I tried it, but I cannot see any tree shadows at all in the IsoSurfaceDemo. But I also don’t know how to get a mouse pointer to click on the GUI controls, perhaps something needs to be enabled there.

Usually to switch from mouse move to cursor in my apps is space bar or tab or something.

Yeah, spacebar: https://github.com/Simsilica/IsoSurfaceDemo/blob/master/src/main/java/com/simsilica/iso/demo/MainFunctions.java#L58

I would like to get instanced trees working again. I sort of feel like some JME version broke them (vague recollection)… but I don’t don’t what is actually wrong.

I also have limited time over the next couple of weeks. I might could look into it next weekend but I can’t make any promises.

If you poke into it and learn anything new then let me know. In the mean time, having this post on the forum, maybe someone else has also encountered this and has a work-around. I know SimArboreal trees are used in a few projects but I don’t know if they are instancing them.

Oh… looking at your code, I see that you are trying to use this with JME’s regular instance node or whatever. I’m not sure I ever tested it that way because I don’t use JME’s instancing node. I have a pretty strong guess that they might be incompatible.

I’m like 75% sure I setup my buffers differently.

You can see how IsoSurfaceDemo does it here:


If I’m not going to support JME’s default way of doing it (which I found kind of ugly for the ‘pre-batched’ case) then I should probably add a utility method to set it up.

Maybe you can unravel what I’m doing there in the mean time.

Leaf shadows can never have worked with instancing, the PreShadow shader contains no instancing code. Fixed that with https://github.com/andilem/tree-test/commit/07e4ac16c7ece45e37b26e74eedef932e4352ba5.

Considering the LoD problems, I think the InstancedNode just doesn’t support changing the culling. I will probably have to write my own instancing code similar to yours.

Yeah, the LOD only makes sense for single trees, I guess. Once it’s a whole batch of trees, not so much.