Dynamic Terrain extension, How to make infinite terrain?

I like your idea.
Yes, the mapData is to be rectangular.

In the standard usage, only the “chunks” where your terrain (camera) is currently located is accessed. This means that only the related part of the global map is accessed, so unknown or null values should work also … if we think before about the normals.
So, either you download and set at will both, the map coordinates and the precomputed normals, either you compute the normals (and uvs, if needed) of this dedicated section just after downloading and set the DynamicTerrain normals array.

Note 1 : if keeping null values, you’ll probably need to disable the DT automatic normal computation at creation time How to Use Dynamic Terrain - Babylon.js Documentation

Note 2 : This static method computes the normals of a passed mapData (your chunk, here) Extensions/babylon.dynamicTerrain.ts at master · BabylonJS/Extensions · GitHub
Then up to you to update the right section of the single real global mapData used by the DT.

Maybe it’s easier finally to fill the global mapData with zeros and to update only parts of it with downloaded heightmaps and downloaded pre-computed normals.

Another tip : instead of downloading an image, you could just download a flat array of altitudes (y float values only), then fill client side a mapData array by setting x and z values from a given step.
=> download only y values, populate the mapData array with computed (x,z) values. It will be simpler than dealing with heighmaps imho.

1 Like