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

View space z-direction

Discussion in 'Shaders' started by Wompipomp, Oct 26, 2015.

  1. Wompipomp

    Wompipomp

    Joined:
    Aug 31, 2014
    Posts:
    24
    Hi,

    in what direction in view space (after applying UNITY_MATRIX_MV) is z pointing.
    Is it from camera positive into the screen or is it negative so z is pointing towards the camera (out of the screen)

    I couldn't find any site with an answer. :(
    With try and error I found out that it seems to be like openGL -> so camera is facing negative z value.

    Is this correct?

    Thank you very much
    Mark
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    View space (or camera space) and clip space (or projection space) are different things. OpenGL and D3D differ in projection space direction, and there are helper variables for that, but I believe view space is the same. It also matches what you see in the editor. If you place a game object as a child of the camera, that should match the coordinates of an object transformed by the UNITY_MATRIX_MV.
     
  3. Wompipomp

    Wompipomp

    Joined:
    Aug 31, 2014
    Posts:
    24
    Thanky you :)