Terrain Generation Advice

I am creating a Unity Terrain Exporter… It exports the Terrain and and splatmaps and textures.

My question is 2 fold.

1… Is it better to create 1 LARGE terrain or segment the terrain into something like 4 x 4 chunks.

I assume it would be better to have segmented terrain so the walkable surfaces will be smaller when using Physics on the terrain as a mesh. Not to mention, things like camera frustrum culling… so only the segments of the terrain that are visible to the camera are actually rendered… Also makes it possible to generate terrain LODs if the terrain is segmented.

2… Is it better for me to export the heightmap for the terrain from Unity and use PlayCanvas script code to create a terrain mesh from the heightmap image… Or i can actually create the terrain mesh inunity and export in the scene gltf as actual mesh geometry.

If i actually create the terrian mesh in unity and export as mesh geometry… I can do things , easily, like creating mesh segments and lod levels. The drawback is the scene file size… Since we actually create the mesh in the scene file vs just exporting the heightmap and creating the terrain in PlayCanvas Code. But using the mesh in scene file will load better in ANY viewer cause the terrain is already there and ready to go in the scene file.

I am wondering about overall performance

What do you guys think about it ???

Pinging @Leonidas as they have built a terrain generator :stuck_out_tongue:

1 Like

It depends entirely on the scope of your project: if your game involves viewing the entire terrain at all times with great quality then it might be better to have 1 single terrrain mesh. On the other hand if you require a big open world it usually is better to generate chunks. Then you can generate LODs and achieve a decent polycount without sacrificing quality/camera view distance.

That’s the main reason behind this project, it doesn’t provide LOD generation but the logic is there and you can easily extend it / use the provided methods:

@Glenn_Ko took it even further working on a quad tree terran LOD engine:

Again it depends on your project’s specs. If you are targetting a minimal app download size it is better to use heightmaps and generate the terrain on runtime. I don’t think there will be any visual difference between the devices as I feel all popular browsers will run the code with the same precision.

On the contrary if you are targetting low performant devices like mobile phones generating the terrain/chunks on runtime might put a lot of load on the CPU.

Thanks guys for the info… just so I know what they are…

What is a Tiled Terrain Generator and Quad Tree Terrain… As a posed to the regular height map Unity uses to draw terrains ???

They are both community projects.

Tiled Terrain manager is an extension of the PlayCanvas Terrain Generation from Heightmap tutorial. It adds a lot of boilerplate code and provides a couple of methods to streamline chunks generation (like fixing the seams/normals between the chunks).

Here is the original tutorial for a single terrain from a heightmap:
https://developer.playcanvas.com/en/tutorials/terrain-generation/

The Quad Tree Terrain generator is far more sophisticated, a project @Glenn_Ko authored. He might be able to provide more details about it. Check the thread I posted above.

It keeps saying Tiled Hieghtmap. I’m sorry but I don’t understand the Tiled part of Tiled heightmap. How is that different from just an image … let’s say a 512 x 512 greyscale image that is generated for example from unity GetHeights function.

I see the word Tiled and that seems to imply more than one image that represents the terrain heights

If a Tiled Heightmap is just really a regular image chopped up into segments… is that right???

So then in actuality… I was using unity to create segmented terrain , fixing up all the edges in C# unity api then I just export all then generated meshes… so I am already using Tiled Terrain… I just do it at export time instead of at runtime during game startup…

Is that the just of it ???

Well, the tiled terrain manager is generating a mesh (chunk) per heightmap file. Why not from a single heightmap? Because that way you can have very detailed chunks.

Having a single heightmap let’s say 4096x4096 creating a total terrain area of 10x10km means you will get a resolution of 2.44 meters per pixel.

Generating a terrain the same size of 8x8 heightmaps of 2048x2048 each means now you will get a resolution of 0.61 meters per pixel.

Basically that’s the main reason you will want to split your heightmap. Most terrain generation applications (e.g. World Machine) are built around this feature.

Ofcourse if you don’t require large areas / detailed resolution you can still use a single heightmap to generate one or multiple terrain chunks.

Oh ok, I think I get it…, it’s not just chopping up a large height generated from unity. But actually piecing together several seperate heightmaps … each of which creates a mesh then aligning them together… and the better the heightmap edges are seamless … like the seamless textures … the better they look when placed next to each other.

I think I just export finish runtime ready terrain meshes from unity…, so if you construct your terrain using several tillable heightmap images and use unity to align them and paint them…

Then during export I just create the export meshes based on the amount of unity terrains you setup in your scene…

That the exporter doesn’t care HOW the terrain are put together… single or Tiled…, we just export the finished Unity terrain components.

Yes, you pretty much nailed.

In Unity I use World Creator to create my terrain and at the end it provides a split method which breaks the terrain in chunks. I end up with a bunch of heightmaps which I can use in playcanvas to construct my big world terrain.

How are you exporting the terrain from unity now… what file format ???

I never heard of world creator for unity… I will have to look for that on the Asset store

I use the heightmaps and the splatsmaps (PNG image files) generated by World Creator.

I imagine that exists a method or asset to export them from a standard Unity terrain.

I can actually create heightmaps or just generate the terrain mesh using the native unity terrain internal height data.

I was just curious how your doing it now. And I mainly started this thread to get advice about using heightmaps at runtime vs just creating native gltf mesh data for terrains…

I prefer serializing native gltf mesh data at export time rather the generating a bunch terrain meshes at runtime and is how I handle terrain export in my WebGL Canvas Tools for Unity

Thank you to all … Your responses cleared up thing for me … Thanks Again Everyone :grinning:

1 Like

World Creator seems kool, I might add support for exporting world creator terrains as native gltf meshes

Wheres Tiled Terrain Manager? The links are Offline for me.