When using terrain in a StreamingEnabled game, it looks corrupted in certain cases (low-memory, I presume). With the new memory limit emulator in Studio this can be reliably reproduced, but this happens on real devices a lot too.
Reproducing/illustrating with an example;
Put this script in ServerScriptService on a baseplate, then enable StreamingEnabled in Workspace (default settings), then run the game.
local material, occupancy = {}, {}
math.randomseed(0)
for x = 1, 100 do
material[x] = {{}}
occupancy[x] = {{}}
for z = 1, 100 do
local spawn_water = math.random() < 0.5
material[x][1][z] = spawn_water and Enum.Material.Water or Enum.Material.Air
occupancy[x][1][z] = spawn_water and 1 or 0
end
end
workspace.Terrain:WriteVoxels(Region3.new(Vector3.new(), Vector3.new(400, 4, 400)), 4, material, occupancy)
If you have enough memory (or use the emulator with a high memory setting, such a 64 GB), it’ll look correct:
With a lower memory setting (even 8 GB is too little?), or simply one of the phone/tablet options:
Notice the inverted normals, random slices of disconnected geometry and in general inaccurate geometry, even close to the player. In real games it can look very, very corrupted, with spikes all over the place, depending on the terrain.
The appearance will change as the terrain changes too, or as you move around:
The terrain material does not matter. Collisions will continue working correctly. Even moving into it will not load higher quality/correct visual geometry either.
Disabling StreamingEnabled will prevent this issue from occurring.
This started happening about 2 months ago.
This was tested on Windows 10, but this issue seems to occur on all devices (at least on Windows 10 and iOS).