Blender, instances, more instances and thin instances

Well, I’ve been trying to recreate a scene from a game I once played, and it needs lots of vegetation rocks and stuff. And I’m always looking for ways to use BJS methods to reduce draw calls and vertices, and have used instances for a long time. But BJS now has “thin instances” - so I thought I would give them a try.

I looked at the docs, and for a non-coder like me was immediately frightened off when I saw the word “matrix”. But I remembered @PirateJC 's video on “Thin Instances” and the code seemed so easy and I settled in to see what I could create. I also wanted to be able to use Blender to define where the “thin” instances would go. I solved that after I followed a link that @JohnK posted that led me to this little BJS method :

var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);

So I created a mesh for my terrain that I deleted faces from, then triangulated the remaining faces, and then finally one last delete of triangles.(see image below highlighting the residual faces. This I used to place my “thin” instances across an up/down terrain. I did not use all the vertices - just some. And finally, in my code did a dispose of that mesh

Here is the result :

The Graveyard

Now, I’m pondering how to scale, rotate and use different materials for the mesh used for the “thin” instances - probably have to repeat the process with different meshes to be instanced.

I use the mixMaterials script to paint the terrain and with the mixmap in Blender I’m able to keep objects of the path.

So the trees are instances created with geometry nodes in Blender, the bushes with “thin” instances, and the windows, wall pillars and wall ivy done manually with instances.

TY to @PirateJC and @JohnK . Helped this crap coder a lot :wink:

Stay Safe All, gryff :slight_smile:

6 Likes

Three weeks ago I was wondering the same thing, so I created a couple of samplers. Take a look at: https://playground.babylonjs.com/#EXG61P#4 (static) and https://playground.babylonjs.com/#UQ4KRP (movement).

2 Likes

I looked around. Found a head stone, but no body.

On another note, when coming from a program like Blender, would not using duplicates (exported as a mesh with instances) and also marking the custom exporter property Freeze world matrix be almost the same performance wise, as thin instances? Theis would have the advantage of no post load code, and if you did want to move / rotate any of them, it would just be another call to freezeWorldMatrix() to get it applied. @gryff , I am not asking you. I am asking for you.