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. Dismiss Notice

An issue with normals

Discussion in 'General Graphics' started by GixG17, Jan 14, 2019.

  1. GixG17

    GixG17

    Joined:
    Aug 18, 2013
    Posts:
    105

    The screenshot is the viewport displaying normals.

    I have 3 elements:
    • A cube.
    • A generated geometry (marching cubes).
    • A tri-planar shader (with normal maps).
    Judging by the cube, the shader seems to be working fine. The generated geometry (that is also using the exact same material as the cube) seems to not display bumps on any of the surfaces displayed in pink.

    The part of the pink surface that does display bumps is actually a copy of the same geometry but rotated 90 degrees... at which point you see the dark purple surface missing the bumps. That dark purple surface is the exact same surface as the pink surface (just rotated 90 degrees). So the issue isn't the angle of the surface in world space but the surface itself.

    The only tangible difference I can think of between the cube and the generated geometry is that I ran .RecalculateNormals() on the generated geometry.

    I'm wracking my brain trying to figure out how to solve this... the only thing I can think of is that RecalculateNormals() might have made normals of that surface perpendicular to how they should be but I found no way of rectifying it. Flipping the normals on the X axis obviously just makes the entire surface dark. I haven't found a way to rotate it either.. but I don't think it's an issue with rotated normals either because, otherwise, wouldn't the surface be a different color the those displayed on the cube?

    If anyone has any ideas on what's causing it and/or how to fix this, I would greatly appreciate it.
     
  2. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    Hi, just guessing but how does your mesh data look? Does your per vertex normals looks sane, and do you have good UVs?
     
  3. GixG17

    GixG17

    Joined:
    Aug 18, 2013
    Posts:
    105
    The UVs are handled by the tri-planar shader.

    Considering that I currently have my viewport set to render in "normals" and that the colors of my surfaces match the cube, I'd assume that my normals look sane. Is there another way to verify this?

    I'm not sure what you mean by "how does my mesh data look". The quads in the mesh itself looks clean and light sources lit up the surface as expected. The data has arrays of vertices, tris, vertex color and normals (established by RecalculateNormals()) as typically found in most meshes.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    What does the triplanar shader look like?
     
  5. GixG17

    GixG17

    Joined:
    Aug 18, 2013
    Posts:
    105
    It's actually based off of your work. I have a direct copy of your shader as a test shader and I'm getting similar results on my generated geometry. Considering that it works perfectly fine with the cube, it's reasonable to believe that there's a mistake somewhere in how I'm generating the mesh... I just don't know what.

    Any ideas of what could be the culprit? The phenomenon only seems to happen on the polygons that are facing the local X axis of the mesh.
     
  6. bart_the_13th

    bart_the_13th

    Joined:
    Jan 16, 2012
    Posts:
    485
    Maybe this missing tangent stuff... I dont know how to provide one though...
     
  7. GixG17

    GixG17

    Joined:
    Aug 18, 2013
    Posts:
    105

    There's still a small corner that's problematic but generating tangents effectively solved my issue!

     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    Ah, you're using the surface shader version. I'm not super pleased with that version, but yes, that needs tangents.

    I might need to do another pass on that one, I have a suspicion there's still a bug with it.