It is currently Mon Dec 16, 2019 1:00 am


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Strange artifacts when removing from terrainvolumes
PostPosted: Thu May 12, 2016 1:20 pm 

Joined: Sun May 08, 2016 10:30 pm
Posts: 3
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:

Code:
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);
                }
            }
        }
}


Image
Image
Image

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


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Strange artifacts when removing from terrainvolumes
PostPosted: Fri May 13, 2016 8:53 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Strange artifacts when removing from terrainvolumes
PostPosted: Fri May 13, 2016 11:43 am 

Joined: Sun May 08, 2016 10:30 pm
Posts: 3
Image

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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Strange artifacts when removing from terrainvolumes
PostPosted: Sat May 14, 2016 7:50 pm 

Joined: Sun May 08, 2016 10:30 pm
Posts: 3
Where can I read more about density fields?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Strange artifacts when removing from terrainvolumes
PostPosted: Sat May 14, 2016 10:41 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net