Search Unity

Post process Stack Stencil

Discussion in 'Image Effects' started by j_pedrero, Mar 5, 2019.

  1. j_pedrero

    j_pedrero

    Joined:
    Jan 7, 2019
    Posts:
    10
    Hello,
    I created a custom PostProcess effect using the post process stack but I need to apply it only to some objects.

    I think that I can achieve it using a stencil but so far my shader just ignores the stencil...

    Post Process Effect Code:
    Code (CSharp):
    1.     SubShader
    2.     {
    3.        
    4.         Cull Off
    5.             ZWrite Off
    6.             ZTest Always
    7.            
    8.             Pass
    9.         {
    10.             Stencil{
    11.                     Ref    2
    12.                     Comp always
    13.                     Pass replace
    14.         }
    15.             HLSLPROGRAM
    16.  
    17.                 #pragma vertex VertDefault
    18.                 #pragma fragment Frag
    19.  
    20.             ENDHLSL
    21.         }
    22.     }
     
  2. tangwilliam

    tangwilliam

    Joined:
    May 4, 2016
    Posts:
    22
    Maybe you can try unchecking 'Allow HDR' , 'Allow MSAA' and 'Allow Dynamic Resolution' on your camera component.
     
  3. j_pedrero

    j_pedrero

    Joined:
    Jan 7, 2019
    Posts:
    10
    If anyone stumbles upon this

    I solved It by Rendering the things I wanted to affect in the Queue Geometry and the unaffected things on Geometry+1.
    Unity actually has 2 Depth Textures:

    *_CameraDepthAttachment
    *_CameraDepthTexture

    The _CameraDepthTexture is created before Geometry+1.
    so for my PostProcessing Effects, I just used the _CameraDepthTexture to make this calculation.
     
    Atrixx likes this.