Volumes Of Fun

Strange artifacts when removing from terrainvolumes
Page 1 of 1

Author:  theirah [ Thu May 12, 2016 1:20 pm ]
Post subject:  Strange artifacts when removing from terrainvolumes

When I try removing voxels, I get these strange planes of terrain that are a pixel thick but are visible and block movement. Does anyone know why this happens? Below is my code for removing voxels, as well as some screenshots after calling the following method a few times:

void DestroyVoxels(int xPos, int yPos, int zPos)
        MaterialSet emptyMaterialSet = new MaterialSet();
        int range = 1;
        for (int x=xPos-range; x<=xPos+range; x++)
            for (int y = yPos - range; y <= yPos + range; y++)
                for (int z = zPos - range; z <= zPos + range; z++)
                    terrainVolume.data.SetVoxel(x, y, z, emptyMaterialSet);


This black ball from the last image is what I use to select which voxel I have active, so that part is intentional.

Author:  David Williams [ Fri May 13, 2016 8:53 am ]
Post subject:  Re: Strange artifacts when removing from terrainvolumes

I'm not exactly sure why this is happening, but here are a couple of things to consider or test:

  • Does it also happen deeper underground, or are you only seeing it at the surface? Or perhaps it only occurs near the boundary of two different materials?
  • Does it still happen if you increase the 'range' parameter to 5 or so?

In general I can tell you that correctly manipulating density fields can be surprisingly tricky (it gave me headaches!). I would encourage you to look at the built in sculpting code and try to use that. It's kind of a cheat because it is actually just a call to the C++ code which has the actual implementation, but you only need to worry about calling it rather than understanding it. It's currently only exposed in the editor, but if it works for you then in principle it should be possible to extend Cubiquity to access it from game code.

Author:  theirah [ Fri May 13, 2016 11:43 am ]
Post subject:  Re: Strange artifacts when removing from terrainvolumes


Still happens with 5 range (and also with 0 range). I did notice that the grass grows darker when this happens, and with 1 range, if I aim straight down, it just turns the grass dark without removing it. It does seem to remove *something* under the dark grass though.

I had no luck with making this happen not at the boundary between the grass and dirt. I will do some more testing.

As for copying the sculpting, I took a look, but there's a lot of blending involved that makes it not as obvious what is happening. I was trying to get something to work without the blending.

Author:  theirah [ Sat May 14, 2016 7:50 pm ]
Post subject:  Re: Strange artifacts when removing from terrainvolumes

Where can I read more about density fields?

Author:  David Williams [ Sat May 14, 2016 10:41 pm ]
Post subject:  Re: Strange artifacts when removing from terrainvolumes

I'm afraid it's hard to know what to recommend to you here... I know from experience that the terrain representation is confusing and can be counter intuitive. The addition of multiple materials and support for blending between materials makes it quite hard to understand what is going on.

Can you also test your code on a different terrain? You are using an empty terrain here, but actually I recall there are some peculiarities about the way that particular terrain is constructed. Can you try your deletion code on the 'Voxeliens' example terrain or the procedurally generated example? Note that these examples already have deletion available (from a mouse click as I recall?) so you can probably just swap that code for you own. This is the code I am talking about:

https://bitbucket.org/volumesoffun/cubi ... lume.cs-68

Now that I look at it, I note that it blurs the terrain as a final step (call to TerrainVolumeEditor.BlurTerrainVolume). It might be worth including that in your code as well, and generally comparing how that DestoyVoxels() function compares to your own code.

There is a little information about the representation here:

http://www.cubiquity.net/cubiquity-for- ... l_set.html

It is indeed quite complicated, and this is why I wrapped

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group