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


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: regenerating and replacing specific bits of mesh?
PostPosted: Tue Jun 26, 2012 7:30 am 

Joined: Tue Mar 08, 2011 3:57 am
Posts: 46
I'm currently generating 16*16*16 region chunks to a mesh from my volume. I had intended to then modify the resultant mesh by adding noise, smooth, add geometry, etc. However I've just realized that when one of my voxels are changed I will have to regenerate the entire mesh. I think it would be too expensive to do this with my added functions.
Is there any way to keep the relationship between a voxel and its mesh components? So for example a voxel is turned to air can i cut a hole in my mesh and regenerate the surrounding 15 voxels to create a patch?
Any other more elegant solutions?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: regenerating and replacing specific bits of mesh?
PostPosted: Tue Jun 26, 2012 2:06 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
DJDD wrote:
I'm currently generating 16*16*16 region chunks to a mesh from my volume. I had intended to then modify the resultant mesh by adding noise, smooth, add geometry, etc. However I've just realized that when one of my voxels are changed I will have to regenerate the entire mesh. I think it would be too expensive to do this with my added functions.


In general I would avoid smoothing the mesh as it usually causes artifacts along the region boundaries (as you don't have access to the neighbouring region when smoothing). I have found it is much more effective to smooth the volume data instead.

I imagine that adding noise to the vertex positions look ok, but maybe it is too slow to redo it every time the mesh is regenerated.

What kind of geometry are you adding?

DJDD wrote:
Is there any way to keep the relationship between a voxel and its mesh components? So for example a voxel is turned to air can i cut a hole in my mesh and regenerate the surrounding 15 voxels to create a patch?


No, and I suspect that such an approach would be difficult an error prone.

DJDD wrote:
Any other more elegant solutions?


Depending on what exactly you want to do, you could implement some effects in shaders. For example, you can add noise to the vertex position in the vertex shader. Geometry and tesselation shaders could also be useful.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: regenerating and replacing specific bits of mesh?
PostPosted: Tue Jun 26, 2012 3:43 pm 

Joined: Tue Mar 08, 2011 3:57 am
Posts: 46
David Williams wrote:
In general I would avoid smoothing the mesh as it usually causes artifacts along the region boundaries (as you don't have access to the neighbouring region when smoothing). I have found it is much more effective to smooth the volume data instead.

I imagine that adding noise to the vertex positions look ok, but maybe it is too slow to redo it every time the mesh is regenerated.

What kind of geometry are you adding?

I did actually think of that issue and whilst I have no implementation of it, I thought there could be potential to solve that problem by snapping edge verts to the nearest edge vert of a neighbouring voxel mesh some time after extraction.
I don't know how well that'd work in practice though.

In terms of geometry, I'm basically looking for ways to get more out of the voxel data I have available to me. The resolution of the voxel data is basically 1 voxel is a wall. The wall could be a cave wall, stone cliff, paved wall, etc. The voxel has the wall type and material available as a variable so the information is there, I've just got to find an elegant way to render it.
I had originally thought I'd just create a bunch of tilable 3D models to piece together a scene, but I think that might be a very limiting way to go about it in terms of artistic direction:
How many models would I need to make up all the variations of wall/floor/stairs/ramp/etc?
How do I blend textures between models to create seamless transitions? Is this even possible?

If I render it as a mesh it becomes a lot more procedural. Some code can paint all the textures I want according to the material type I've got on the vertex.

David Williams wrote:
DJDD wrote:
Is there any way to keep the relationship between a voxel and its mesh components? So for example a voxel is turned to air can i cut a hole in my mesh and regenerate the surrounding 15 voxels to create a patch?

No, and I suspect that such an approach would be difficult an error prone.

I had assumed that would be the case. Thought I'd ask anyway. What about improving extraction run time after the first extraction? I would assume the majority of the time is spent iterating over all 4096 voxels in the region. If so, can you think of a way where I can store what I know to be the surface shell of the region as use it as a shortcut on the second+ runs?
This isn't terribly important right now for me - I need to get my solution working before I look at improving efficiency, but just thinking out loud.

David Williams wrote:
DJDD wrote:
Any other more elegant solutions?

Depending on what exactly you want to do, you could implement some effects in shaders. For example, you can add noise to the vertex position in the vertex shader. Geometry and tesselation shaders could also be useful.

This is true. Maybe that is the way forward. Do you have any further reading or existing open-source projects?
As an example, I need to turn a flat wall surface into a cave wall (rocky, and curved at the top to meet the roof).


Top
Offline Profile  
Reply with quote  
 Post subject: Re: regenerating and replacing specific bits of mesh?
PostPosted: Wed Jun 27, 2012 8:25 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
What kind of mesh are you expecting to start from here? A smooth Marching Cubes mesh or a cubic Minecraft-style mesh?

DJDD wrote:
In terms of geometry, I'm basically looking for ways to get more out of the voxel data I have available to me. The resolution of the voxel data is basically 1 voxel is a wall. The wall could be a cave wall, stone cliff, paved wall, etc. The voxel has the wall type and material available as a variable so the information is there, I've just got to find an elegant way to render it.


If you want to create natural geometry (caves, cliffs, terrain, etc) the the Marching Cubes extractor will handle this well. But setting the density values appropriatly and smoothly changing from high density to low density you will be able to have a curved roof to your cave even with the relatively low voxel resolution which you describe. However, the Marching Cubes extractor will not work well if you need sharp corners in you terrain.

DJDD wrote:
I had originally thought I'd just create a bunch of tilable 3D models to piece together a scene, but I think that might be a very limiting way to go about it in terms of artistic direction:
How many models would I need to make up all the variations of wall/floor/stairs/ramp/etc?
How do I blend textures between models to create seamless transitions? Is this even possible?


This approach doesn't really fit with any of the exiting surface extractors. You would need something custom for this approach and even then I'm not clear how it would work.

DJDD wrote:
I would assume the majority of the time is spent iterating over all 4096 voxels in the region. If so, can you think of a way where I can store what I know to be the surface shell of the region as use it as a shortcut on the second+ runs?
This isn't terribly important right now for me - I need to get my solution working before I look at improving efficiency, but just thinking out loud.


I think you'll find the Marching Cubes implementation is pretty fast so I wouldn't worry about re-extracting the whole region. If you want to be able to compare the old and new meshes and only apply your operations on the bits that have changed then I think this would be at a higher level than PolyVox (i.e. you have to do it yourself :-) ) but I wouldn't worry about this until you know you really need it.

DJDD wrote:
This is true. Maybe that is the way forward. Do you have any further reading or existing open-source projects?
As an example, I need to turn a flat wall surface into a cave wall (rocky, and curved at the top to meet the roof).


In order to add detail to a rock face to make it appear more bumpy you could consider normal/parallax/displacement mapping. Are you using Ogre? If so you can have a look at the Ogre samples to get an idea of how these work. They are fairly advanced shader techniques though.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: regenerating and replacing specific bits of mesh?
PostPosted: Wed Jun 27, 2012 11:24 pm 

Joined: Tue Mar 08, 2011 3:57 am
Posts: 46
The problem is I need both sharp and smooth areas in my terrain, so MC smoothing won't do it.
I think vertex displacement mapping is a solid idea, however I think it may still look bad on corner pieces where it cannot displace the edges of two right angled planes.
I'm kind of at a loss.

Maybe I could do a simple MC extraction and supplement the mesh with very displacement maps + detail models.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: regenerating and replacing specific bits of mesh?
PostPosted: Thu Jun 28, 2012 7:21 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
DJDD wrote:
The problem is I need both sharp and smooth areas in my terrain, so MC smoothing won't do it.


PolyVox doesn't really have a good solution here. Displacement maps are great for adding surface detail but aren't enough to reshape the mesh is the way you are describing. Basically I see two options:

1) Investigate an approach like Dual Marching Cubes. There appears to be some work to add a Dual Marching Cubes implementation to Ogre as a Google Summer of code project (see http://www.ogre3d.org/forums/viewtopic.php?f=13&t=69449). Maybe you can start there, but I don't know how well it actually works.

2) Depending on your exact requirements, you could try combining the outputs of the Marching Cubes SurfaceExtractor and the CubicSurfaceExtractor. Then you can use marching cubes for the terrain and cubic for tthe buildings, etc. I'm sure that in practice it will be a little complex though.

You're into an experimental/research area I'm afraid ;-)


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

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