Terrain:WriteVoxel seems will not write Air to a voxel that has non-Air material

  1. What do you want to achieve?

Modify and restore dynamically generated Terrain using ReadVoxels and WriteVoxels. The process is: (1) Terrain is generated by a script, (2) later, Terrain is modified using Terrain:Fill* methods AFTER the voxels to be modified are saved using Terrain:ReadVoxels, (3) subsequently RESTORE the modified terrain using Terrain:WriteVoxels.

  1. What is the issue? Include screenshots / videos if possible!

Terrain:WriteVoxel will not (apparently) write Air to a voxel that already has a non-Air material.

If a saved voxel was originally Air, then subsequently rewritten to (say) Rock, the RESTORE step on that voxel using WriteVoxels has no effect - that voxel is not rewritten as Air.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

In the saved voxel data, If i change Air to something else (like Snow), then WriteVoxel effects the change appropriately (to confirm the saved voxel data is not crap).

I verified that the Fill* methods work as expected with Air.

To no affect, I also tried setting the voxel’s occupancy to non-zero (ReadVoxel records the Air as zero, evidently) .

I’ve tested and examined the script and voxel data to determine if there is a scripting bug, but I do not see evidence for that (other than WriteVoxel won’t write Air to a voxel that has non-Air).

I searched the forum and found only one slightly relevant post - however, the issue was reported in running games (but not studio) as a result of a flag that was rolled out and subsequently rolled back. It was claimed the issue did NOT manifest in Studio, though. That posting is: Terrain WriteVoxel ignores Air material voxels

1 Like