Search Unity

Use both DepthTextureMode.Depth and DepthTextureMode.DepthNormals on camera

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

  1. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    Hi,

    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?

    Cheers,
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    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.