Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Pixel artifacts

Discussion in 'Scripting' started by barz00n, May 23, 2011.

  1. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    Hi

    I'm noticing some pixel artifacts where meshes meet.
    http://i.imgur.com/wqQ0G.png
    What could be the reason? Mesh positioning is not a problem, they should be perfectly aligned :(
     
  2. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    Nobody? Anything I can do to prevent this from happening?
     
  3. callahan.44

    callahan.44

    Joined:
    Jan 9, 2010
    Posts:
    694
    I assume they're individual meshes. The "tears" are caused by the final position of the vertex not being in the same place due to floating point errors.

    I'd try the mesh combine utility, so that all the meshes are transformed as one mesh.
     
  4. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    I can't use combine mesh as these pieces can be destroyed at runtime.
    I basically have a map of cubes that make up some walls. I can destroy those cubes. I previously made my cubes from unity planes, and that showed up fine, no tears. But now I moved to maya cubes with 6 materials for all sides, but I get those mesh gaps.

    Is this something that happens often? Is there a solution? I instantiate and place my cubes in scripts, so I'd need a script solution.
     
  5. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    618
    Forgive me for not wanting to go in depth as to why this happens but...

    Are these objects going to be on a bright white background all the time?
     
  6. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    Nope, the background will actually be dark. But having gaps harder to spot does not really fix the fact that they do indeed appear :) Black dots show pretty well on brown surfaces too.
     
  7. GisleAune

    GisleAune

    Joined:
    May 16, 2011
    Posts:
    88
    The directional light illumiates all faces in that direction. The face in your wall is lit and cause this. The easiest sollution is to make three meshes for the wall segment, one for start, one for center and one for end. So that there's no faces between two segments.

    Think of your wall as three blocks aligned like this [_][_][_]. The between faces will be lit. if you create three segments instead. the one to the left end with the left side face there and right side face taken away. along the wall have a mesh without these side faces. At the end have one with only a face in the right side of it.

    I hope this is somewhat comprehendable...
     
  8. callahan.44

    callahan.44

    Joined:
    Jan 9, 2010
    Posts:
    694
    Don't dismiss the merging blocks so quickly, it can be done real-time for dynamic tiling blocks.
    I'm not sure how big you're going to make the level, but each object is at least 1 draw call, so an 8x8 is going to be 64 draw calls minimum (more per object depending on the lighting used and number of materials)

    @gisleaune -The background is showing through the tears, not interior polygons.
     
  9. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    @gisleaune - Yes, the gaps actually show the background white plane and space, the "cubes" in that picture actually have no common full plane sides.
    @callahan.44 - I need to be able to destroy even a few cubes per second, so there is no way a mesh combine can be run that often with no performance issues.
     
    Last edited: May 24, 2011
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Are the verts snapped to integer boundaries and is mesh compression off? both are required if you really want to minimise this effect due to floating point inaccuracies sneaking in. Actually sometimes mesh compression can solve this. Have a play around anyway but I think there's probably a tiny bit of floating point difference between the two verts sneaking in.

    The only way to be sure is that in the modelling package verts lie along integer bounds in coordinates and you snap with interger bounds. Otherwise one vert is always going to be 0.004f off or something. Unless at runtime you can access their meshes and snap their verts (again) to the nearest integer.
     
    Last edited: May 24, 2011
  11. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    I just checked the imported mesh and mesh compression is off.
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's likely they are actually not aligned perfectly. Attached is a shot of two separate objects, where the vertices do match up exactly. As you can see, there is no visible seam. Check in your 3D app that the verts are aligned properly, and that the objects are positioned properly in Unity. It's important to be exact; the objects should be precisely 1.0 units wide, for example, not 1.00000001. I don't know what app you're using, but if you can, try typing in the positions of the verts instead of positioning them visually.

    --Eric
     

    Attached Files:

  13. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    My artist uses maya and says he's using cubes of exactly size 1/1/1 which then scales up at export by 100. Unity seems to scale maya exports down a bit.
     
  14. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
  15. barz00n

    barz00n

    Joined:
    Apr 7, 2011
    Posts:
    27
    What do you mean. He exports to fbx but scales it up at export so I don't have to at import.
     
  16. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    The double conversion is extra complication, and probably is at least part of your problem.