Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to aviod floating point artifacts when snaping meshes

Discussion in 'General Graphics' started by b4nj0, Dec 6, 2015.

  1. b4nj0

    b4nj0

    Joined:
    Jan 11, 2015
    Posts:
    39
    Hello Community.

    This topic has been discused some times, but somehow i can't find real working solutions.
    I'm trying to create some modular gameassets, but i cannot get them aligned perfectly.
    There is always some artifacts between them, wich only occur at certain camera angles.



    As far as i know this is a floating point precission problem with the verts sharing the same position.
    What i dont understand is, that unitys standart assets like cubes and planes dont suffer from this problem.
    (at least i was not able to create this artifacts with them)

    My assets only align if i completly add no rotation and put them on full value positions.
    Even 90° rotatations cause artifacts to appear.

    I tryed changing import settings, scaling them from 1.1 to 1.0000001 , overlapping the meshes a bit, with and without the outer hidden faces...
    nothing helped.

    Some say its because these meshes are not merged, but that would be the same for 2 unity standart cubes / planes right?

    But there are people having modular assetpacks in the asset store and people giving them good reviewes.
    So i asume there is a solution to this problem?

    - I know i could hide the seams with other objects, but that isn't an option in all cases
    - I know i could merge everything in my 3D software, but thats not an option for assetpacks.
    - I would like to avoid having a script that merges everything together

    Does someone have any informations or solutions for this issue, that i havn't found so far?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    I would point out that same "seam" is showing up on the edges of the arches regardless of if they're next to eachother or not. That makes me think it's a texturing problem of some kind, or you're rounding the mesh corners.
     
  3. b4nj0

    b4nj0

    Joined:
    Jan 11, 2015
    Posts:
    39
    the artifacts also appear without any textures and flat shading
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    Then are the mesh edges beveled?
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    There is a possibility also that your FBX (or other exported mesh) is at some sort of float-precision-breaking scale.

    The model itself could also be at fault, it's more likely that you've given the edge verts some ridiculous value for their positions. (i.e. something like 1.9999999 instead of 2) so check that in Blender also. (I say that because I can see you used blender to make them. ;))

    Also, try beveling as bgolus said, that can help hide errors like this. (Even a small amount of bevel can add a seemingly intentional creased edge at the seam)

    EDIT: One more thing; how big's your draw distance? A huge far clip plane WILL cause issues with camera movement bugging everything out.
     
  6. b4nj0

    b4nj0

    Joined:
    Jan 11, 2015
    Posts:
    39
    Turns out you Guys where absolutly right about the bevel/rounded corners.
    I now tripple checked everything to be flat shaded besides the inner arch and it seems to work



    Now it starts looking like something to work with :D

    Thanks to both of you for the quick help and feedback
     
    theANMATOR2b likes this.
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Heh... being that it fixed I for you, I should probably follow my own advice and fix up a couple of bugs in my own project... :D (My dynamic track generator sometimes slightly displaces pieces, making edges at seams visible)
     
    theANMATOR2b likes this.
  8. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,043
    Hi I am having a similar issue but it only seems (no pun intened ) apparent with Unity 5.x and not older versions. Also these seams, seem to affect physics as well as I have modular golf course pieces and the ball rolled perfectly flat before over the seams and now it trips over these seams.
     
  9. b4nj0

    b4nj0

    Joined:
    Jan 11, 2015
    Posts:
    39
    Well in my case it was a texturing problem.
    If it affects actual physics as you say, then its seems to be an issue with the meshes not fitting perfectly.
    Try placing meshes and the connection verts only on full number coords not something like 1.000003.
    Try using 90° steps of rotations.
    Try to resnap them.
     
  10. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,043
    Hey b4nj0 I believe I tried all those things to no avail.

    Edit: I noticed on one of the parts that has an issue. It somehow ended up with a rotation of -89.98019. So I have it rotated back to -90 and saved it. When I reload the level, the part is returned back to a rotation of -89.98019

    WTF

    Edit2: Damn I thought the bug i reported re:rotations (759115) was fixed but it's not yet.

    Edit3: Please vote for https://issuetracker.unity3d.com/issues/transform-rotation-value-changes-on-play-mode-a-little-bit
     
    Last edited: Feb 6, 2016