Search Unity

Sprites with Z-Buffer data and Sorting Groups

Discussion in '2D' started by GamerXP, May 3, 2019.

  1. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    78
    I'm trying to make sprites work with Unity's postprocessing effects (DOF, SSAO, etc) and my own shaders, that require Camera's depth texture grab.
    The problem is: just enabling ZWrite in shader is not enough for sprite to appear on depth texture. It requires having "ShadowCaster" pass in the shader. But this pass works ONLY if sprite's render queue is <=2500. BUT if I set render queue to <=2500 - sorting groups stop working.

    Question is: is it somehow possible to draw sprite to Unity's _CameraDepthTexture AND have working sorting groups at the same time?

    Or at least the way to grab current ZBuffer texture (not shadow pass one, but the one including sprites) in the shader
     
    Last edited: May 4, 2019
    foxnne likes this.