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


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Mesh semplification with normals
PostPosted: Wed Feb 20, 2013 7:21 am 

Joined: Sat Dec 17, 2011 5:42 pm
Posts: 19
Hi again,
usually I'm using the CubicSurfaceExtractor which does a really great job with mesh semplification, however recently I created some kind of "cubic" model editor and since I had the need to texture the model, I can't have shared vertices on the edges and so I used the CubicSurfaceExtractorWithNormals that gives me the normal from which I calculate the UV.

It works really great, however this extractor has no semplification so with a lot of models the vertex count really adds up.

Would it be hard for me to add the semplification while leaving duplicate vertices on the edges or are there some kind of technical limitations I'm not aware of? Or maybe you can suggest a different way to generate UV while using the normal extractor?

Thanks in advance for the help.

EDIT: (unrelated) I've seen the performance improvement commits on bitbucket, have you benchmarked them? If there's a nice speedup, I will update to the latest version


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Mesh semplification with normals
PostPosted: Thu Feb 21, 2013 9:55 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
You can compute normals in the fragment shader using the trick here: http://www.volumesoffun.com/polyvox/doc ... bic-meshes

There's a similar trick you can use for computing some UV coordinates once you have the normal:

Code:
vec2 texCoord = vec2(dot(position, normal.yzx), dot(position, normal.zxy));


I haven't tested that exact code but used something similar in Voxeliens for the normal mapping.

If you don't want to use shaders then you will have to write code to take the extracted mesh and build a new mesh from it by copying across the triangles and computing normals as you do so. Actually I do intend to add such a utility function at some point (but not soon).

Illidan wrote:
Would it be hard for me to add the semplification while leaving duplicate vertices on the edges or are there some kind of technical limitations I'm not aware of?


It's mostly that I don't want to maintain two CubicSurfacExtractors. The version with normals will probably be removed once I add the utility function mentioned above.

Illidan wrote:
I've seen the performance improvement commits on bitbucket, have you benchmarked them? If there's a nice speedup, I will update to the latest version


I think the CubicSurfaceExtractor is quite a bit faster (maybe 50%) and the whole unit test suite runs about 20% faster. The develop branch currently builds but has a few warnings on Linux. In general we try to keep it stable but don't promise this :-)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Mesh semplification with normals
PostPosted: Thu Feb 21, 2013 10:08 am 

Joined: Sat Dec 17, 2011 5:42 pm
Posts: 19
Hi David,
I use a similar shader for my standard voxels, however will it work if the resulting mesh is moving and rotating? As I use them for creatures and such. I assumed it won't due to it being based on the voxel position, but maybe I'm wrong.

Nice work on the performance, I will update soon :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Mesh semplification with normals
PostPosted: Thu Feb 21, 2013 10:47 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Illidan wrote:
I use a similar shader for my standard voxels, however will it work if the resulting mesh is moving and rotating?


It should be ok as long as you use the model-space position rather than the world-space position (we did this for the moving Voxeliens as well as the terrain). This means you'll probably need to pass you model space position through to your fragment shader as well as your world-space position.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Mesh semplification with normals
PostPosted: Thu Feb 21, 2013 11:30 am 

Joined: Sat Dec 17, 2011 5:42 pm
Posts: 19
I see, I suppose something like that could work (for sure a lot better than my current approach :roll: )

Thanks again for the help, I will post some screenshots if I make it work :)


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

All times are UTC


Who is online

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