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

Get the distance from source to destination in shader

Discussion in 'Shaders' started by vegenarie, Aug 30, 2015.

  1. vegenarie

    vegenarie

    Joined:
    Jan 5, 2011
    Posts:
    287
    I want to get the distance from source to destination in the same shader, for instance the distance from water to something under the water. I could copy what is rendered under water by the camera with Graphics.blitz to the water shader and use the _CameraDepthTexture in the water shader but then i would need to know the distance from camera to the water in tthat water shader too and i do not know how to do that as CameraDepthTexture would already have the value of the distance from another camera to the items under the water and if i use Graphics.blitz again to know the distance from camera to water to the same shader i would overwrite the CameraDepthTexture, so how could this be done?
     
    Last edited: Aug 30, 2015
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    Is everything under the water rendered before the water?
     
  3. jistyles

    jistyles

    Joined:
    Nov 6, 2013
    Posts:
    34