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


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Voxel Smoothness
PostPosted: Sun Feb 26, 2012 1:19 am 

Joined: Thu Sep 01, 2011 2:36 pm
Posts: 27
hi there

After quite a few months of experience with polyvox and extensive testing I am sure of it now that for the amount of polygons the surface extractor generates for a given mesh the level of smoothness of the final mesh could be higher.

Now I know David said quite a few times that this depends on how smooth the voxel blend weight data is and also what bitsize was used.However the problem of smoothing the blendweights is that you lose a lot of geometric detail and of course a bigger blendweight bitsize demands more memory.

Now after some testing I saw that with some internal mesh-vertex interpolation the result can be smoother without the need of using a bigger volume or a higher bitsize for the blendweights and while also maintainig all the geometric details.

I used the 3DS Max "relax" function on the vertices of the final mesh which basically moves all the vertices of the mesh a little bit closer to each other and the result was much smoother than what I could achieve by just smoothing the voxel data of a 64x64x64 volume.

so maybe some "relax" function would be cool for polyvox?

best regards
syphorlate


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel Smoothness
PostPosted: Sun Feb 26, 2012 10:06 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
For reference, can you show some screenshots of how smooth the terrain looks with/without smoothing in 3DS Max?

At any rate, while smoothing the volume data is easy (just blur it) I do agree that it is difficult to further edit the blurred volume data without destroying the smooth edges. And geometric detail can be a problem (algorithms other than Marching Cubes can handle this better). So there is an argument that post-processing of the mesh can be useful.

However, I'm not currently planning on adding such support to PolyVox, mostly because it is outside my area of expertise. I did implement the mesh decimation (and a little smoothing) previously but overall I'm still not happy with the quality/speed of that code. For rendering PolyVox can just generate an index/vertex buffer (which is easy) but for more advanced tasks you need a half-edge or winged-edge data structure with adjacency information and this gets more complex.

That said, in the future I may be interested in adding some kind of support or compatibility layer for a third-party mesh library such as OpenMesh or VCGLib. I'm pretty sure these libraries supprt smoothing, decimation, etc better than I would implement it myself, and that way I can focus on the parts of PolyVox which directly relate to volume data.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel Smoothness
PostPosted: Sun Feb 26, 2012 11:20 am 

Joined: Thu Sep 01, 2011 2:36 pm
Posts: 27
ok sure. this is a 64x64x64 voxel volume. on first look the difference between the voxel smoothed mesh and the vertex-smoothed mesh might not be that apparent but if you look closer at the finer details you see that the voxel smoothing mesh tends to omit details while the vertex-smoothed mes keeps the profile of the original mesh without losing any of its details.

I should also mention that for the voxel-smoothed mesh I only locally brush-smoothed those areas which were really asking for smoothing. If I applied a uniform smooth more details would have been lost.

But generally I would say it would make sense to implement some sort of interpolation since it might even allow you to use smaller volumes to achieve the same level of detail. Also you could think about generating more polygons using some sort of subdivision.

Attachment:
smooth.jpg
smooth.jpg [ 153.3 KiB | Viewed 3439 times ]


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel Smoothness
PostPosted: Mon Feb 27, 2012 9:43 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Ok, great, I can see there is a noticable difference between the vertex-smoothed and voxel-smoothed versions.

Starting with your input data (the non-smoothed version) I can see that you are already writting fairly smooth data into the volume. If you were writing binary data (such that each voxel was either solid or not) then the resulting mesh would have more jagged 45 degree angles. Can you elaborate on how your editing tool actually works? For example, does it add a constant value to each voxel within a given range from the mouse cursor? Or does the amount added depend on the distance from the mouse cursor to the voxel? Perhaps you multiply the underlying data by a value rather than adding to it?

The reason I ask about this is that I usually suggest voxel smoothing (bluring the volume) as a quick and easy solution for people who have binary input data. E.g. they have generated their voxel terrain from a heightmap and have the kind of 45 degree angles mentioned earlier. But in your case your editing tools are already creating (fairly) continuous data (in that the non-smoothed version is already fairly smooth) so you may be better off modifying the behaviour of your editing tools rather than using voxel smoothing.

That said, I do think the quality of the voxel-smoothed version can be improved. I suspect the main problem is that the data is being blurred too much, and that less blurring would still improve the smoothness of the surface without losing so much detail. But you have probably hit a problem in PolyVox here - assuming you are using the LowPassFilter class and the smallest possible kernel size of '3', then PolyVox doesn't actually let you blur by a smaller amount.

When using this small kernel PolyVox will average each voxel with it's 26 neighbours, giving an equal weighting to each of the 27 voxels. A better approach (which would allow less blurring) would be to take (for example) 80% of the value from the current voxel and the remaining 20% from the average of the neighbours. More generally, we could allow user-specified filter kernels and provide some standard ones like the Gaussian.

A couple more questions - to my eye the non-smoothed version doesn't look quite like the raw output of PolyVox. Have you applied any other algorithms such as decimation to the data? Also, how are your normals computed? Are you using the normals from PolyVox or ones generated from 3DS Max? PolyVox does have some options for different normal quality if that helps.

Syphorlate wrote:
But generally I would say it would make sense to implement some sort of interpolation since it might even allow you to use smaller volumes to achieve the same level of detail.


PolyVox does perform interpolation when running the Marching Cubes algorithm. That is, if two voxels have values 0 and 200 and the threshold is 150, then the resulting vertex will be placed 3/4 of the way along the edge. Is this what you meant, or something else?

Syphorlate wrote:
Also you could think about generating more polygons using some sort of subdivision.


This would be possible, but again I think it could be better handled by a mesh library like the ones I mentioed above. On modern GPUs it should probably be performed by the tesselation hardware.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel Smoothness
PostPosted: Mon Feb 27, 2012 1:05 pm 

Joined: Thu Sep 01, 2011 2:36 pm
Posts: 27
You posed a lot of questions in your response. So I hope you don't mind if I pick them one by one :mrgreen:

Quote:
Can you elaborate on how your editing tool actually works?

Sure. :mrgreen:

Quote:
For example, does it add a constant value to each voxel within a given range from the mouse cursor?

No. :o

Quote:
Or does the amount added depend on the distance from the mouse cursor to the voxel?
Yes. The distance to the "brush-source-position" is used to calculate the voxel density. ;)

Quote:
Perhaps you multiply the underlying data by a value rather than adding to it?
No. :o
Quote:
so you may be better off modifying the behaviour of your editing tools rather than using voxel smoothing.
I don't think that it is possible for the editing tools to output smoother data than they already do.For example if I create say a voxel sphere with radius 5 the voxel sphere density is already as smooth as it can be(depending on the distance) yet if I apply the 3ds max relax modifier on top of that mesh it generates a much smoother mesh.

Quote:
That said, I do think the quality of the voxel-smoothed version can be improved. I suspect the main problem is that the data is being blurred too much, and that less blurring would still improve the smoothness of the surface without losing so much detail.

Yeah could be. For now I am happy with the smooth function( I mainly use it to get rid of "too much detail"). I automatically apply the 3ds max relax function to the mesh after each brush stroke which is fast enough and yields good results.

Quote:
When using this small kernel PolyVox will average each voxel with it's 26 neighbours, giving an equal weighting to each of the 27 voxels. A better approach (which would allow less blurring) would be to take (for example) 80% of the value from the current voxel and the remaining 20% from the average of the neighbours. More generally, we could allow user-specified filter kernels and provide some standard ones like the Gaussian.

yes that seems like a good idea. Having more control over the amount of smoothing would be great especially since as you already stated the current smoothing functionality is way too agressive.


Quote:
A couple more questions - to my eye the non-smoothed version doesn't look quite like the raw output of PolyVox. Have you applied any other algorithms such as decimation to the data?Also, how are your normals computed?

Ah yes.This is a vertex normal issue. Couldn't help that. This automatically happens when I convert my plugin-mesh to the 3ds max editable-mesh object. I guess it recomputes the normals or something. On that image all meshes were converted to editable-mesh except the "voxel-smoothed mesh". But still even before conversion it didn't look much better.

Quote:
Also, how are your normals computed? Are you using the normals from PolyVox or ones generated from 3DS Max? PolyVox does have some options for different normal quality if that helps.

When I convert to 3ds max' editable mesh I usually apply vertex weld modifier and then apply the Smooth-Modifier(which just calculates normals based on the geometry). during editing I use the normals which are generated by polyvox(they are as good as the ones generated by 3ds max and sometimes even much better).

If you look at the new pictures I posted in the showroom you see how it looks during the editing process(without mesh vertex relaxation).


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel Smoothness
PostPosted: Tue Feb 28, 2012 9:31 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Syphorlate wrote:
Quote:
For example, does it add a constant value to each voxel within a given range from the mouse cursor?

No. :o

Quote:
Or does the amount added depend on the distance from the mouse cursor to the voxel?
Yes. The distance to the "brush-source-position" is used to calculate the voxel density. ;)

Quote:
Perhaps you multiply the underlying data by a value rather than adding to it?
No. :o
Quote:
so you may be better off modifying the behaviour of your editing tools rather than using voxel smoothing.
I don't think that it is possible for the editing tools to output smoother data than they already do.For example if I create say a voxel sphere with radius 5 the voxel sphere density is already as smooth as it can be(depending on the distance) yet if I apply the 3ds max relax modifier on top of that mesh it generates a much smoother mesh.


Ok, it sounds like your editing tool is doing something reasonable. I don't actually know what the best approach is because I've never implemented something like this, but if I did I imagine I would do something similar to you.

Syphorlate wrote:
yes that seems like a good idea. Having more control over the amount of smoothing would be great especially since as you already stated the current smoothing functionality is way too agressive.


I think this is the main improvement which can be made to PolyVox. I've been wanting to add custom filters anyway so I've put it on the todo list.

Syphorlate wrote:
during editing I use the normals which are generated by polyvox(they are as good as the ones generated by 3ds max and sometimes even much better).


Yep, usually the PolyVox normals should look quite nice because they are computed from directly from the volume data rather than from the mesh.


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 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