It is currently Sat Aug 22, 2020 4:26 am


All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Tue Feb 17, 2015 8:28 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
maheshvele wrote:
I have a question about the volume chunks, I have seen in the cubiquity videos that the chunks are stored in an oct tree. What is the reason for this? Is it because it is a memory efficient data structure?


We are not (currently) using octrees for the volume data - that is just stored in a single LargeVolume/PagedVolume. A octree is instead used for managing the mesh data which we extract, and this is mostly related to LOD. Each level of the octree stores a different resolution mesh and we choose which one to use based on the distance to the camera. It's an active research area at the moment.

maheshvele wrote:
...I only see these artifacts when the mesh extends across different volumes.


Yep, this is another example of why you should put everything in a single large volume rather than many small ones (though you should still generate many small meshes). The LowPassFilter averages a voxel with it's neighbours, and if those neighbours are in a different volume then it doesn't have access to them.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Tue Feb 17, 2015 12:00 pm 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Hi David,

But I am using a single large volume. I am extracting the meshes in regions occupied by the chunk..

This is my exact code

The regions are separately filled for each chunk. (Note that I am filling 0 for air and 255 for ground)

PolyVox::Region region(PolyVox::Vector3DInt32(startX, startY, startZ),
PolyVox::Vector3DInt32(endX, endY, endZ));

RawVolume<uint8_t> tempVolume(region);
LowPassFilter< SimpleVolume<uint8_t>, RawVolume<uint8_t>, int16_t > pass1(mSimpleVolData, region, &tempVolume, region, 3);
pass1.executeSAT();
LowPassFilter< RawVolume<uint8_t>, SimpleVolume<uint8_t>, int16_t > pass2(&tempVolume, region, mSimpleVolData, region, 3);
pass2.executeSAT();
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> mesh
MarchingCubesSurfaceExtractor< SimpleVolume<BYTE> > surfaceExtractor(mSimpleVolData, region, &mesh);
surfaceExtractor.execute()


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Tue Feb 17, 2015 4:47 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I think you will also need to filter the whole volume in one go, where as you are currently doing it one chunk at a time? If you do want to do just a chunk at a time then you will need to take extra steps so that your temporary volume is larger than a chunk, so that you can include the neighbouring voxels as well (even then I'm not sure how well it works).

If the values come from a noise function then can you not generate smoother values in the first place to avoid the need for filtering?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Wed Feb 18, 2015 10:42 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
Quote:
I think you will also need to filter the whole volume in one go, where as you are currently doing it one chunk at a time? If you do want to do just a chunk at a time then you will need to take extra steps so that your temporary volume is larger than a chunk, so that you can include the neighbouring voxels as well (even then I'm not sure how well it works).


This is the way I do my extraction and usually contribute each post with it :D
In order to avoid writing the same all over, there is the post that you may get the idea:
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=624&p=4589&hilit=Crafterria#p4589
This way you don't store filtered volume, just extract your raw volume filtered.

Quote:
(even then I'm not sure how well it works)

You already know that it works and i managed to already make my chunks seamless, smooth without storing densities at all :) Well, this will change as now I am investigating for better algorithm based on that


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Sun Feb 22, 2015 11:49 pm 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Hi David,

I did try the method petersvp suggested it works really well until I start deforming the terrain. The terrain deformation is a bit wonky since the individual chunks need to be overlapped, whenever there is a terrain deformation at the edge of two meshes its causing gaps in the terrain.

I was wondering how you could use density values for smooth surfaces. I was using the example outlined in the polyvox examples but I could not get a smooth surface. Could you please help me understand this? I am using the following code.

Code:
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();

               float density = -fDistToCenter;
               density += fRadius;
               density *= 10;
               density += 127;

               uint8_t uDensity = MaterialDensityPair44::getMaxDensity();

               uDensity = (uint8_t)FMath::Clamp(density, 0.0f, 255.0f);

               MaterialDensityPair44 voxel = mSmoothVolData->getVoxelAt(x, y, z);
               isFilled = true;
               voxel.setDensity(uDensity);
               mSmoothVolData->setVoxelAt(x, y, z, voxel);
   


if I change the value I multiply the density with, I do get seemingly smooth surfaces but then, I also get a lot of thickness with the mesh(which I don't need). Does cubiquity use the low pass filter internally? If so, how does it handle the overlapping mesh issue?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Mon Feb 23, 2015 12:30 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
maheshvele wrote:
Could you please help me understand this? I am using the following code....


It's quite hard for me to explain this to be honest, I think you will need to study density functions in general. But the idea is that densities can have a range between 0 and 255 (at least in our case), and that if a density has a range < 127 then it is considered empty, otherwise it is considered solid.

The following code will give a very jagged mesh because all the densities are either 0 or 255:

Code:
uint8_t uDensity = 0;
//If the current voxel is less than 'radius' units from the center then we make it solid.
if(fDistToCenter <= fRadius)
{
   //Our new voxel value
   uDensity = 255;
}


To make it smooth you need to ensure that your voxel values have a gentle transition from low density to high density, and one way to do this is to use the distance directly (the distance changes gradually and smoothly). But the distance goes from zero to infinity, and you need to map that to the range 255 to 0 (our sphere should be solid near the origin and empty further out). In the code you showed, the multiplications and additions basically perform this mapping.

maheshvele wrote:
if I change the value I multiply the density with, I do get seemingly smooth surfaces but then, I also get a lot of thickness with the mesh(which I don't need).


Yes, imagine you have a voxel with density 20. The sphere does not include this voxel (as the density is less than 127), but if you multiply all voxel densities by 10 then the new density is 200 and so the sphere does include it (as it is now more than 127).

maheshvele wrote:
Does cubiquity use the low pass filter internally?


This stuff is actually separate from what PolyVox and Cubiquity provide. Both libraries allow you to turn a density field into a mesh, but in both cases the issue of generating the density field is left to the user. The user can use noise functions, implicit surfaces, or (in the case of Cubiquity) use built in sculpting tools to set the voxel values.

So Cubiquity does use low pass filtering (I forget if it uses the PolyVox code) but not for the purpose of generating the volume data as this task is not performed by Cubiquity. I think it only uses it for LOD generation.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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