It is currently Sat Aug 22, 2020 1:54 pm


All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Stripping away layers of voxels
PostPosted: Mon Feb 13, 2012 3:30 pm 

Joined: Wed Jan 25, 2012 12:29 am
Posts: 18
I'm not ready to actually implement this but it's been on my mind so I figured I'd share it. Maybe I'm missing an easy option. Also please excuse the long and rambliness of this post; I'm brainstorming this as I write it.

What I want to be able to do is to strip away layers of voxels to expose the gooey innards of a solid region i.e. take a cross section along a cardinal direction. The problem isn't that this is a particularly difficult operation (although library support for setting the material for a whole region at once would be welcome).

The problem is with mesh generation and generally with performance.

Removing entire layers of voxels and re-meshing the entire landscape is too slow.

If there is no voxel/no-voxel boundary then no mesh vertices are generated so I can't generate meshes for each level and show/hide them as I move cross section. I could generate meshes for each level as I built the volume from the ground up but that's only a partial solution because once I start making updates to the inner voxels the pre-build meshes will go stale.

I could solve this by making a customized version of the mesh generator that generates vertices either on voxel/no-voxel boundary or the edge of the given region but I think that would probably introduce new problems, like unwanted vertices that aren't on the cross section since I won't be updating the whole layer all at once (see ManualRegion::sectionVolume)

I could remove all the voxels in the layer above, re-generate the mesh then put them back. This might actually work if I'm only working in small-ish regions

I could arrange the volume so that I alternate a real layer with an empty layer but that is waay ugly and I think it would cause more problems than it's worth considering cases like vertical shafts through the volume ugh no. Not to mention the coordinate hell that would be introduced across the board.

OK so the solution that I have is:
1) Divide the volume into regions that are 1 voxel thick in the direction we will be taking the section along and of reasonable size in the other two dimensions (see ManualRegion code)
2) When generating or re-generating the meshes fake out the mesh generator by removing the voxels in the layer above the region we are generating.
3) Show/hide the meshes as we as move the section through the volume.

Does anyone have any thoughts about this, did I miss any issues, is there an easier way?

Cheers,
Charlie


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Mon Feb 13, 2012 3:58 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
I have a hack to propose, that will look nicer, but only work if you have a single volume and a single thread.

Create a new type of voxel. That voxel will return it's regular density if it is inside a static global Region that you set everytime you run the extractor. if the voxel is outside that region, it returns zero as density.
voila, extract any region, but with borders!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Mon Feb 13, 2012 4:21 pm 

Joined: Wed Jan 25, 2012 12:29 am
Posts: 18
That is indeed a sneaky way of hacking the mesh generator without actually touching it.

The problem I had with my mesh generator hack was that you'd end up generating vertices that weren't on the section's face but if you were to make the special static region larger than the re-mesh region in the section face dimensions then it could work.

I don't see any reason to limit this to a single volume or thread. If you were to get creative and say encode a reference (abstract reference not a pointer) to the special region in part of the material value for the voxel ... anyway that's maybe going too far in the simple case.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Tue Feb 14, 2012 6:16 am 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
the problem with a nonstatic member is that your voxel will end up using sizeof(pointertype)+sizeof(oldvoxel) bytes... which will be on a 32 bit system 5 bytes/voxel when you had 1 byte per voxel before... on a 64bit system it would even be 9bytes/voxel total... what a waste :)
that's the reason it's a hack, you'll need a new voxeltype for each parallel (threaded or not) volume you extract from. or very careful design in the nonthreaded case.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Tue Feb 14, 2012 10:01 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
You should have a read of this post, in particular the ideas about 'isQuadNeeded()'. The idea of wanting to generate quads between solid voxels has a lot in common with what we need to achieve transparency.

Also, rather than hiding/showing a large number of meshes you night be able to make use of additional hardware clip planes. It depends on the structure of your data though.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Tue Feb 14, 2012 1:51 pm 

Joined: Wed Jan 25, 2012 12:29 am
Posts: 18
Very interesting stuff. I was recently promoted to a management position so I feel the need now to ask questions like, when do you plan to have this implemented? Ugh I feel a little dirty now.

So I think I'm going to hold off on any of the more hacky solutions until you have this, or something like it, in place. Like I said before I've got plenty of other stuff to worry about before I get there.

I'll worry about showing hiding all the meshes when it becomes a performance problem but it's good to know there are hardware supported options there.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Tue Feb 14, 2012 4:59 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
It's the next thing I'll be working on in PolyVox, but it's only getting a few hours a week at the moment (Voxeliens and real work are priorities right now). Actually I look forward to getting Voxeliens shipped so I can get back to some of this underlying stuff.

I'd estimate we'll do a new release in a couple of months which will have these changes in place.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Stripping away layers of voxels
PostPosted: Tue Feb 14, 2012 5:17 pm 

Joined: Wed Jan 25, 2012 12:29 am
Posts: 18
Thanks for all the great work.

I also look forward to voxaliens being finished but for a different reason :D


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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