How create terrain underwater?

I am trying to place terrain underwater with a script.
I first create a column of water, then I go back, and place the terrain.

Any time there is a percentage of a voxel, it always seems to leave an air pocket.

If I modify my code to NOT create partial voxels, the bubbles disappear

image

The code I am using to render the partial voxels is…

			local mat = {{{Enum.Material.Slate}}}
			local occ = {{{list[n].Extra}}}
			workspace.Terrain:WriteVoxels(list[n].Region,4,mat,occ)	

The list[n].Region is a region of only 1 voxel, and list[n].Extra is a value from >0 to <1

Are there any tricks to understanding how to properly place terrain underwater?
Thanks.

Does anyone know where I could find the old source code for the terrain editor, when it was a plugin?

This might help me understand better the process for creating terrain under water.

Thanks

So… I solved it…
Apparently, the little bubble spots were areas where my ‘extra’ (partial voxel) was 0, and so it was putting a 0 volume voxel (thus a bubble) at those spots.

You might wonder… why were you not checking the value of ‘extra’ to make sure it was > 0 ?

Well… I thought I was. I had the statement …

if extra then

instead of

if extra > 0 then

Apparently, this was returning true even when the value was 0

This shows the importance of being specific with your code, I would suggest ALWAYS keeping these type of statements, and the ‘not’ statement for use with Boolean values ONLY.

I need to get in the habit of checking for the actual value or lack of value, even nil.

So… good lesson for me I guess. XD