Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

World position from depth buffer in fragment shader, can't figure it out?

Discussion in 'Shaders' started by eXonius, Aug 19, 2017.

  1. eXonius

    eXonius

    Joined:
    Feb 2, 2016
    Posts:
    207
    I've read various forum posts on how to get the world position from a depth buffer but no matter what I tried it just won't work. I don't know if it's because of different versions of Unity or something else. I am using 2017.1 now.

    I am rendering depth to a texture and then reading it in my shader and it works fine for things that doesn't need the world position, but I need to get the true world Y value from my depth buffer (to know how deep my water is at that specific fragment).

    Has anyone got this working in the latest version of Unity?
     
  2. eXonius

    eXonius

    Joined:
    Feb 2, 2016
    Posts:
    207
    I have solved my problem (copied some code from another part of the shader that already gets the depth of the water).