Skip to content

Instantly share code, notes, and snippets.

@slipster216
Created November 29, 2022 00:38
Show Gist options
  • Save slipster216/f313e2ec41bd967f18ceed3dbb90720e to your computer and use it in GitHub Desktop.
Save slipster216/f313e2ec41bd967f18ceed3dbb90720e to your computer and use it in GitHub Desktop.
Some of the issues with the terrain API
TreeInstance lets you set the Y position of the tree, and then you can tell it not to set the tree's to be on the terrain when setting the TreeInstance[] with SetTreeInstances, but when the terrain sync's the height data it aligns them to the terrain Y anyway. This prevents you from sinking the tree's into the ground without changing the model, or floating lilly pads on water, etc. It will work for a second, then snap back to the terrain height.
The terrain details API uses an Int[,] for details. It should be able to readback an R8 texture the same way height/alpha maps can be read back from the GPU. This would at least half the time of MicroVerse updates, if not more if there are more details in use.
Terrain isn't tessellated when flat - this breaks tessellation shaders which subdivide the terrain, and likely doesn't do much to speed up terrain except on really old GPUs or in preventing a few microtriangles. Would be nice to be able to disable this.
When reading back heightmaps from the GPU, you have the option to sync back to the terrain now or defer it. However, the readback is slow because it uses that moment to compute the data needed for LODs, which I assume means scanning the height map for height variation, which is not desirable a lot of the time. Would be nice if we could either provide this data, turn it off, or have it rewritten on the GPU to be fast.
Holes have the same problem as the details system - uses [,] array and no way to read from GPU.
[BUG] removing terrain details on Unity 2021.3 can crash unity.
Splat maps are very compressible, but no option is available to compress them easily, consuming a ton of extra memory and bandwidth. This would be a huge win on mobile.
Heightmaps are internally using a signed format. When instancing is enabled a max value terrain will wrap around to negative half.maxValue causing it to clip. This also reduces the total number of heights available from 64k to 32k, and manes you have to multiply height values by 2 all over the place. Likly not easy to fix without breaking everything.
Normal map generation seems to happen over frames for terrains. If you get all the normal maps for terrains on the first frame, many of them won't be correct if you try to use them elsewhere. A lot of the time MicroSplat and MicroVerse will generate their own normal maps since the one provided by Unity is unreliable, which wastes memory. These could be compressed in most use cases. (A dynamic vs static terrain option is really needed so you can have terrain be read only at runtime and take advantage of that with compression, etc)
Terran Layers are non-extensible, so a lot of tools have to spend a lot of time managing terrain layers in ways that conflict with other tools. For instance, MicroSplat has way more textures than a terrain layer provides - so syncs the terrain layers to what's in it's own container (TextureArrayConfig). This can be problematic with assets that also try to manage the terrain layers.
The TreePrototype, and DetailPrototype structures are not serializable, which means tools that want to store them have to make their own classes and copy back and forth, manage changes through unity versions, etc. Would be nice if they could be serializable.
@slipster216
Copy link
Author

Note that issue 6 is the reported daily by users and extremely easy to repro. I submitted a sample project with a script that caused it which Unity QA rejected. I also submitted an entire project that won't open because of it, we'll see if they bounce that.

But to repro it - open MicroVerse's Core Collection's demo from the MicroVerse-Demo package and delete the game object called "Details". This will 100% crash unity every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment