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

Vertex normals swizzle depending on position/orientation of camera and other objects

Discussion in 'Shaders' started by ArConstructor, Sep 19, 2013.

  1. ArConstructor

    ArConstructor

    Joined:
    May 27, 2010
    Posts:
    24
    Hi all,

    When experimenting with a shader that maps local normal and position to UV coordinates, I found that, for some models, the normal's Y and Z components somehow switch places depending on camera position and orientation (and on position of other objects / scene bounds).
    The glitch affects the icosahedron and the cylinder I made in Blender; Unity's default objects don't seem to be affected.

    Does anyone have any idea why this happens (and how to fix it)?

    I've attached a test project with a shader that visualizes normals as colors.
    $A2.png $B2.png

    I've tested it on WinXP workstation and Win7 laptop (shadermodel 3.0- and 2.0-capable GPUs, respectively).
     

    Attached Files:

    Last edited: Sep 19, 2013
  2. ArConstructor

    ArConstructor

    Joined:
    May 27, 2010
    Posts:
    24
    Hmm, after further testing I found that Unity's default meshes are affected too (cube, plane. cylinder).
     
  3. ArConstructor

    ArConstructor

    Joined:
    May 27, 2010
    Posts:
    24
    Submitted a bug report.
     
  4. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    349
    The batching procedure, transform normals to the batched object transform matrix.
    It's not error at all )
     
  5. ArConstructor

    ArConstructor

    Joined:
    May 27, 2010
    Posts:
    24
    Oh! Thanks, that solved the problem. Silly me ^_^"