Search Unity

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:
    472
    Is everything under the water rendered before the water?
     
  3. jistyles

    jistyles

    Joined:
    Nov 6, 2013
    Posts:
    34