How does water work with partial occupancy terrain

I have been searching everywhere for the last few days about this, and can’t seem to find any answer. Using smooth terrain, when reading voxels, and writing voxels, how do I handle terrain that has both water and terrain? Is there such a thing? From what I can tell, reading voxels, I only get a material of terrain for partially filled terrain cells when under water. So what determines the ‘water’ part of this? Is it just calculated by the engine somehow? Would I need to set a cell with water first, then set it with a partial occupancy material?

Any links to information on this or any understanding would be greatly appreciated.

Thanks.

2 Likes

I’m about 90% sure that each cell is either one material or another - it can’t be multiple. My understanding is that the offsetting and stuff that smooths terrain out is only rendered (i.e. cells only look like they’re not actually cells), and not treated like that in scripts or behind the scenes. There’s every chance I’m entirely wrong, however. (Edit: I forgot physics was a thing.)

Anecdotal evidence: I’ve generated a lot of hills, and noticed that unless I introduce artificial noise, they come out nice and smooth. However, water next to another material with a curved border between the two gives somewhat jagged edges. The last time I used water in procedural terrain generation was a while ago, however.

Cells are treated smoothly for physics too. Each cell has an occupancy, and the occupancy determines how full it will be for the rendering and physics engines.


All terrain cells can be only one material. If you have a low-occupancy non-water cell near water cells, the water will “take up” some of the “non-water cell’s space.” In other words, the non-water cell will become partially water. Water, essentially, expands to fill and touch surrounding cells for both rendering and physics purposes.

Similarly, sometimes a non-water material can expand out of its cell too. In this case, you can have a water cell with some non-water material in it.

To detect this, you would have to check the cell you want to check and all adjacent cells.


It’s calculated by the engine, which I described above.

If you want a cell to be “partially water” and “partially” some other material then you will need two cells – one filled with water and one filled with non-water. Depending on the material you choose and the occupancies of the cells, either the water cell or the non-water cell will become have both materials in it.

4 Likes

I don’t know if it will be useful for you, but zeuxcg made 2 blog articles that go in-depth Smooth Terrain:
https://blog.roblox.com/2017/04/voxel-terrain-storage/
https://blog.roblox.com/2018/01/voxel-terrain-physics/

3 Likes

Thanks so much for all the really good answers, Corecii stated what I was needing to know, that water in an adjacent cell will ‘fill’ the gap of a non 1 occupancy neighbor. However, Veldaren, those articles show that in a more visual and gives me something to read over in depth, so thank you both for the help, it is much appreciated.

1 Like