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

Question Help me understand Position node in Fullscreen material mode (shader graph)

Discussion in 'Shaders' started by NymThePseudo, Aug 13, 2023.

  1. NymThePseudo

    NymThePseudo

    Joined:
    Oct 12, 2014
    Posts:
    4
    Unity 2023.1.7f1

    When hooking up a Position node (using Object space) directly to an Unlit shader graph's color output, you get a predictable result.
    upload_2023-8-13_11-51-31.png

    Example using a simple test scene with some random objects (ignore the outline effect):
    upload_2023-8-12_19-34-59.png

    However, when doing the exact same thing in a Fullscreen shader graph, I'm not sure what it is that I'm getting as a result:
    upload_2023-8-12_19-36-7.png

    Could someone tell me what it is I'm getting exactly when using the Position node in a Fullscreen shader graph?

    And of course, the data I'd like to have is the one from the first instance. Is there any way to get the same data in a Fullscreen shader graph?

    EDIT: Seems like this is really only an issue in orthographic mode (when combined with fullscreen shader graph material) ... ?
     
    Last edited: Aug 13, 2023
  2. NymThePseudo

    NymThePseudo

    Joined:
    Oct 12, 2014
    Posts:
    4
    After a few hours of fiddling around, I was able to recreate the world space positions by sampling the camera's depth texture
    upload_2023-8-13_11-33-21.png

    Based off of Cyanilux's post on depth (https://www.cyanilux.com/tutorials/depth).

    Still, in case anyone could enlighten me on what exactly we're getting from the Position node (object space) in a Fullscreen graph (orthographic), that'd be appreciated.
     
    Last edited: Aug 13, 2023
    canxerian_ likes this.
  3. flyAgain

    flyAgain

    Joined:
    Jan 7, 2016
    Posts:
    3
    I am also confused about the Position Node in FullScreen Shader. In World mode, the Position Node seems to obtain the world coordinates of each pixel in the current frame buffer. Instead of the world coordinates of the object where this shader is located, as usual. This point is poorly explained in the manual.
     
  4. sevan98t

    sevan98t

    Joined:
    Mar 31, 2020
    Posts:
    6
    @NymThePseudo hello can you share the GetCameraInvProjection Custom Function please ? :)