Well, as I have mentioned several times on the forum, I have traditionally scattered rocks and trees as “instances” using the Blender Particle System on a terrain I have created by various other methods.
Now with Blender’s Geometry Nodes I can create the terrains and add the instances. This first part is about the steps I use for creating the terrain with Geometry Nodes.
Steps :
1: Create a simple plane, scale to the size I want, then subdivide. In this example the plane is 80x80 metres, and subdivided 30 times - so 32x32 vertices for a total of 1024 vertices. See an example here:
2: After I create the plane, I go into the Geometry Nodes Tab and add a geometry node. See Image 1. A more detailed explanation is in Image 2:
A: the basic Geometry node with two nodes inserted - a) a get positions node and b): a smooth shading node.
B: the crucial nodes drive the “offset” randomly moving the vertex positions. and this is done using a noise texture - Voronoi, Noise, or Musgrave.that move the vertices along the normals to the faces (built in).
C - two nodes to move the position of the texture, allowing movement of the texture to suit needs.
D - two nodes to keep the plane along the Z = 0 axis.
E - to output the scale to the geometry Positions.offset.
As it stands, you see the terrain in “Object Mode” but in “Edit Mode” you see the vertices of the subdivided flat plane- Images 3 and 4.
At this point, I had no idea what to do next so I just did an export using @JCPalmer 's babylon exporter - and it worked (the example above is just the export) but if you wanted to alter the mesh (eg create a proper walking path or river) then something extra is needed.
The answer is to open the Geometry nodes tab, put the mouse in the 3D viewport window, hit "Ctrl + A" then in the menu that opens choose “Visual Geometry to Mesh” and now in “Edit Mode” the vertices correspond to the terrain and can be altered in various ways. Image 5
The texture on the terrain uses the Babylon script for “mixing” materials.
Exporter version: 2.93.4, Blender version: 3.0.0 Beta
========= Conversion from Blender to Babylon.js =========
Scene settings used :
Inline textures : false
Material Type : PBR
Positions Precision : 4
Normals Precision : 3
UVs Precision : 3
Vert Color Precision: 3
Mat Weight Precision: 2
Keep Z-up r-handed : no
Texture directory : H:\babylon_projects\demos
Python World class constructor completed
processing begun of camera (UniversalCamera): Camera
processing begun of mesh: Plane
processing begun of material: Material.001
processing texture terrain_map02a
texture type: diffuseTexture, mapped using: “UVMap”
num positions : 1024
num normals : 1024
num tangents : 0
num uvs : 2048
num uvs2 : 0
num colors : 0
num triangles : 1922
processing begun of light (HEMI FROM AREA): Light
========= Writing of JSON file started =========
writing mesh: Plane
========= Writing of JSON file completed =========
========= end of processing =========
elapsed time: 0 min, 0.2122 secs
Baffled me - I was expecting a failure of some kind!. In Edit Mode the vertices are in a flat plane. It must be something to do with where you are getting vertex positions from …
1: With STD Material - still works fine
2. Under the “Modifiers” tab - one “modifier” - the “Geometry Nodes”
Exporter version: 2.93.4, Blender version: 3.0.0 Beta
========= Conversion from Blender to Babylon.js =========
Scene settings used :
Inline textures : false
Material Type : STD
Positions Precision : 4
Normals Precision : 3
UVs Precision : 3
Vert Color Precision: 3
Mat Weight Precision: 2
Keep Z-up r-handed : no
Texture directory : H:\babylon_projects\demos
Python World class constructor completed
processing begun of camera (UniversalCamera): Camera
processing begun of mesh: Plane
processing begun of material: Material.001
processing texture terrain_map02a
texture type: diffuseTexture, mapped using: “UVMap”
num positions : 1024
num normals : 1024
num tangents : 0
num uvs : 2048
num uvs2 : 0
num colors : 0
num triangles : 1922
processing begun of light (HEMI FROM AREA): Light
========= Writing of JSON file started =========
writing mesh: Plane
========= Writing of JSON file completed =========
========= end of processing =========
elapsed time: 0 min, 1.0334 secs
I’m not a coder so I do what I can - and this is kind of progress in Blender’s current direction - so this is kind of a tutorial and an example of what can be done.
Sometimes as I explore Blender, things go wrong, sometimes they go right. I just try to let people know.
It is a long time ago since I started using Babylon.JS - the reason I stayed is because of the Blender exporter. I’ve had very very few problems with it. So I try to be positive
I do not read the vertices directly, but rather a temporary snapshot after all modifiers have been applied.
So you are getting vertex data with modifiers applied. I took that one modifier and applied it - now in Edit Mode it looks like image 5 - and exports fine. As I guessed, it is where your vertex data is being derived from.