Search Unity

Simple voxel retopology script (CESN)

Discussion in 'Scripting' started by hausmaus, Apr 9, 2013.

  1. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    Hello,

    I just got the motivation to finish an older content tool, and I wanted to share the results here. There are a few scripts in the project, but the main one is a retopology script that is based on Constrained Elastic Surface Nets as presented by Sarah F. F. Gibson (http://www.cs.tufts.edu/~frisken/surfaceNets-Paper.pdf).

    [video=youtube_share;qB-qMp0qMyU]http://youtu.be/qB-qMp0qMyU

    Project Files: adrianswall.com/temp/simplevoxelizer.zip

    This is focused on static mesh retopologizing, not dynamic voxel terrain sculpting. It can be used to assist in generating a game world in a specific way that was useful for us, but is not an in-engine sculpting tool on its own. However, some of the ideas apply, and a lot of topics covered here are important for general in-engine or in-client modeling and creation tools.

    Cheers,
    -Adrian
     
    Last edited: Apr 9, 2013
    jason-fisher likes this.
  2. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    Updated!
     
  3. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    This thread is super awesome! WHY HAS NO ONE COMMENTED ON IT YET!?!

    Anyways, awesome work man, really impressive stuff.
     
  4. Hard target

    Hard target

    Joined:
    Oct 31, 2013
    Posts:
    132
    Maybe they do not understand what he is trying to do?
     
  5. jason-fisher

    jason-fisher

    Joined:
    Mar 19, 2014
    Posts:
    133
    I love this. Thank you so much.

    One question -- it seems there is a rounding error somewhere in initial smoothing step that is causing one of the extreme axis AABB bounds to miss the extreme bounds of points. i.e., if you run CESN against 4-6 tiled planes, one of the edges (the same on each) of each mesh will miss a row/column as it consistently ignores points along the extreme.

    I am assuming this because with smoothing off, the edges do line up. However, now that I think about it, it is more likely that these triangles have been excluded from the hitTest and the smoothing step is simply ignoring them completely as it snaps, giving the missing strip effect.
     
    Last edited: Nov 12, 2014
  6. jason-fisher

    jason-fisher

    Joined:
    Mar 19, 2014
    Posts:
    133
    OK -- I found the issue. It was in the initial smoothing (point-snapping) pass:

    The NearestPointOnTri test is not using all of the triangle vertices, just the first, which is causing the effect to only really show itself on the last row being processed.

    Find this:

    Code (CSharp):
    1.                     testPoint = PolyTestUtils.NearestPointOnTri(
    2.                         nodePoint,
    3.                         triangle.v0.position,
    4.                         triangle.v0.position,
    5.                         triangle.v0.position
    6.                     );
    Replace with this:

    Code (CSharp):
    1.                     testPoint = PolyTestUtils.NearestPointOnTri(
    2.                         nodePoint,
    3.                         triangle.v0.position,
    4.                         triangle.v1.position,
    5.                         triangle.v2.position
    6.                     );
     
  7. bk0606

    bk0606

    Joined:
    Aug 21, 2014
    Posts:
    4
    Hello, guyes!
    Thank you for this great contribution, Hausmaus!

    Can you share a new link? The old one seem to not active now..

    Regards, Albert.