It is currently Sat Aug 08, 2020 8:05 pm


All times are UTC




Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [Resolved]: Duplicate faces in surface extractor
PostPosted: Sun Apr 10, 2011 2:50 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Topic split of from here: viewtopic.php?f=14&t=190

Hey psquare or beyzend, since you guys having working paging+decimation, would one of you mind doing me a favor?

Could you post a couple of screenshots of your scene with/without decimation using wireframe only?

I am getting a few bugs with the resulting decimated meshes and are not sure if it is my code, or PolyVox. In particular I am having issues with vertex collapse along region borders.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Faster decimation?
PostPosted: Sun Apr 10, 2011 6:42 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
DefiniteIntegral wrote:
I am getting a few bugs with the resulting decimated meshes and are not sure if it is my code, or PolyVox. In particular I am having issues with vertex collapse along region borders.


Aren't you actually working with the smooth meshes though, rather than the cubic ones? Also, does the problem go away if you edit the function 'canCollapseRegionEdge' to always return false?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Faster decimation?
PostPosted: Mon Apr 11, 2011 2:45 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Actually I am using cubic meshes without normals. I haven't tried forcing no edge collapse yet, I will try that later once I have time.

I do have another issue as well though, to do with mesh extraction, not decimation. Extracting meshes from two adjacent regions where one face is flush against the region border results in a duplicate mesh along the border.

See the screenshots below. The red lines indicate the region border.

Non-flush edge / normal face: ftp://definiteintegral.net/regionedge_meshextract_normal.png
Flush-edge / duplicate face: ftp://definiteintegral.net/regionedge_meshextract_duplicateface.png


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Faster decimation?
PostPosted: Mon Apr 11, 2011 8:17 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I believe I might have seen something like this in the past though a quick and basic test didn't manage to reproduce it. I opened the BasicExample and replaced the main() function with this:

Code:
int main(int argc, char *argv[])
{
   //Create and show the Qt OpenGL window
   QApplication app(argc, argv);
   OpenGLWidget openGLWidget(0);
   openGLWidget.show();

   //Create an empty volume and then place a sphere in it
   Volume<MaterialDensityPair44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
   //createSphereInVolume(volData, 30);

   //Our new density value
   uint8_t uDensity = MaterialDensityPair44::getMaxDensity();

   //Get the old voxel
   MaterialDensityPair44 voxel;

   //Modify the density
   voxel.setDensity(uDensity);
   voxel.setMaterial(1);

   //Wrte the voxel value into the volume   
   volData.setVoxelAt(32,32,32, voxel);
   volData.setVoxelAt(32,32,33, voxel);
   volData.setVoxelAt(32,33,32, voxel);
   volData.setVoxelAt(32,33,33, voxel);
   volData.setVoxelAt(33,32,32, voxel);
   volData.setVoxelAt(33,32,33, voxel);
   volData.setVoxelAt(33,33,32, voxel);
   volData.setVoxelAt(33,33,33, voxel);

   //Extract the surface
   /*SurfaceMesh<PositionMaterialNormal> mesh;
   CubicSurfaceExtractorWithNormals<MaterialDensityPair44> surfaceExtractor(&volData, PolyVox::Region(Vector3DInt32(32,32,32), Vector3DInt32(33,33,33)), &mesh);
   surfaceExtractor.execute();*/

   SurfaceMesh<PositionMaterial> mesh;
   CubicSurfaceExtractor<MaterialDensityPair44> surfaceExtractor(&volData, PolyVox::Region(Vector3DInt32(32,32,32), Vector3DInt32(33,33,33)), &mesh);
   //CubicSurfaceExtractor<MaterialDensityPair44> surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
   surfaceExtractor.execute();

   std::cout << "Vertices = " << mesh.getNoOfVertices() << ", Indices = " << mesh.getNoOfIndices() << ", Triangles = " << mesh.getNoOfIndices()/3 << std::endl;

   //Pass the surface to the OpenGL window
   //openGLWidget.setSurfaceMeshToRender(mesh);

   //Run the message pump.
   return app.exec();
}


It prints out 48 triangles, which seems correct to me. Is there any chance you can make an example which shows the problem? Or can you see what I missed? It doesn't need to render anything, just printing stuff out like above would be enough.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Faster decimation?
PostPosted: Tue Apr 12, 2011 2:47 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
The problem only occurs with CubicSurfaceExtractor, but not CubicSurfaceExtractorWithNormals.

Code example:

Code:
#include "MaterialDensityPair.h"
#include "CubicSurfaceExtractor.h"
#include "CubicSurfaceExtractorWithNormals.h"
#include "SurfaceMesh.h"
#include "Volume.h"

//#define USE_NORMALS

using namespace PolyVox;

int main(int argc, char *argv[])
{
   typedef MaterialDensityPair<uint8_t, 4, 4> Material44;

   // Create a volume
   Volume<Material44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
   
   // Set up a voxel material
   uint8_t density = Material44::getMaxDensity();
   Material44 voxel;
   voxel.setDensity(density);
   voxel.setMaterial(1);
   
   // Set some voxels just inside the edge of the region to be extracted. Don't set any voxels on the other side of the region border
   volData.setVoxelAt(0, 0, 31, voxel);
   volData.setVoxelAt(1, 0, 31, voxel);
   volData.setVoxelAt(2, 0, 31, voxel);
   volData.setVoxelAt(3, 0, 31, voxel);

   // Extract the surface mesh from Region0 (contains voxels)
#ifdef USE_NORMALS
   SurfaceMesh<PositionMaterialNormal> meshRegion0;
   CubicSurfaceExtractorWithNormals<Material44> surfaceExtractorRegion0(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 31)), &meshRegion0);
#else
   SurfaceMesh<PositionMaterial> meshRegion0;
   CubicSurfaceExtractor<Material44> surfaceExtractorRegion0(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 31)), &meshRegion0);
#endif
   surfaceExtractorRegion0.execute();

   // Extract the surface mesh from Region1 (does not contain voxels)
#ifdef USE_NORMALS
   SurfaceMesh<PositionMaterialNormal> meshRegion1;
   CubicSurfaceExtractorWithNormals<Material44> surfaceExtractorRegion1(&volData, PolyVox::Region(Vector3DInt32(0, 0, 32), Vector3DInt32(63, 63, 63)), &meshRegion1);
#else
   SurfaceMesh<PositionMaterial> meshRegion1;
   CubicSurfaceExtractor<Material44> surfaceExtractorRegion1(&volData, PolyVox::Region(Vector3DInt32(0, 0, 32), Vector3DInt32(63, 63, 63)), &meshRegion1);
#endif
   surfaceExtractorRegion1.execute();

   // Check vertices on meshRegion0 - should be 20 vertices
   std::cout << "meshRegion0 Vertices = " << meshRegion0.getNoOfVertices() << ", Indices = " << meshRegion0.getNoOfIndices() << ", Triangles = " << meshRegion0.getNoOfIndices()/3 << std::endl;

   // Check vertices on meshRegion1 - should be 0 vertices
   std::cout << "meshRegion1 Vertices = " << meshRegion1.getNoOfVertices() << ", Indices = " << meshRegion1.getNoOfIndices() << ", Triangles = " << meshRegion1.getNoOfIndices()/3 << std::endl;

   return 0;
}


With USE_NORMALS defined:

meshRegion0 Vertices = 16, Indices = 24, Triangles = 8
meshRegion1 Vertices = 0, Indices = 0, Triangles = 0

With USE_NORMALS undefined

meshRegion0 Vertices = 20, Indices = 108, Triangles = 36
meshRegion1 Vertices = 10, Indices = 24, Triangles = 8

Somehow the extractor without normals is putting out more vertices than it should be, even when the result should have 0 vertices such in the region border case.


Last edited by DefiniteIntegral on Wed Apr 13, 2011 1:51 am, edited 1 time in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: Faster decimation?
PostPosted: Tue Apr 12, 2011 8:10 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Sorry I probably should have posted that in a new thread in PolyVox Bugs. Perhaps you can chop my posts out into a new thread in there....


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Duplicate faces in surface extractor
PostPosted: Tue Apr 12, 2011 7:59 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Great, thanks for the example, it does indeed look like there is an issue here.

Note that I don't necessarily expect the number of vertices and triangles to be the same between the two extractors though. The version with normals may have more vertices because they cannot be shared as easily (adjacent faces on a cube have different normals). It may also have less triangles because I think it doesn't close of the final slice of the region (I might not fix this - this extractor is just for testing purposes really).

I'm mostly concerned about your last line as I agree this should probably be empty. I should have a chance to look at it at the weekend.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Duplicate faces in surface extractor
PostPosted: Wed Apr 13, 2011 1:50 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Thanks. I have some time over the next couple of days and might take a look into the CubicSurfaceExtractor code myself. But I really know nothing about mesh extraction so I might not be very useful ;-)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Duplicate faces in surface extractor
PostPosted: Wed Apr 13, 2011 3:06 pm 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
OK I think I have it. Only required a minor change.

ftp://definiteintegral.net/CubicSurfaceExtractor.inl


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Duplicate faces in surface extractor
PostPosted: Wed Apr 13, 2011 8:11 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Great, thanks, I've applied your change to the Git repository.


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

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