Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Use both DepthTextureMode.Depth and DepthTextureMode.DepthNormals on camera

Discussion in 'Image Effects' started by Nicolas-Liatti, Mar 1, 2017.

  1. Nicolas-Liatti


    Jun 19, 2013

    I need to use 2 post effects on my camera, one is with DepthTextureMode.Depth and the other with DepthTextureMode.DepthNormals.

    Both scripts are attached to the camera, and it seems I must use either the Depth Mode or the DepthNormals mode, I can't use one mode for each shader (or I didn't find how to do it?).

    I then tried to transform my shader using DepthTextureMode.Depth by using "DecodeDepthNormal", but the restful is still wrong and it still takes into account the normal...

    Any idea how I can combien both effects on the same camera?

  2. bgolus


    Dec 7, 2012
    If one of (or both of) the image effects you're using is using:
    cam.depthTextureMode = DepthTextureMode.Depth;

    Instead of using:
    cam.depthTextureMode |= DepthTextureMode.Depth;

    You'll have the problem you're describing. Using just the equal sign will override the depth texture mode to just use that one type. Using the vertical bar and equal sign will add that mode to the existing modes already enabled allowing multiple modes to be used together.