Search Unity

Feedback Post Processing 3.2.1 and Single Pass Instanced rendering support

Discussion in 'Image Effects' started by StaggartCreations, Apr 11, 2022.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,266
    I've been diving into using SPI with custom effects, but it appears this is held back by limitations imposed by the Post Processing API and shader libraries.

    In the PostProcessLayer.Render() function:
    Code (CSharp):
    1. public void Render(PostProcessRenderContext context)
    2. {
    3.     for (int eye = 0; eye < context.numberOfEyes; eye++)
    4.     {
    5.         //Copy color target slice
    6.    
    7.         // Right before the builtin stack
    8.         if (hasBeforeStackEffects)
    9.             lastTarget = RenderInjectionPoint(PostProcessEvent.BeforeStack, context, "BeforeStack", lastTarget);
    10.  
    11.         // Builtin stack
    12.         lastTarget = RenderBuiltins(context, !needsFinalPass, lastTarget, eye);
    13.  
    14.         // After the builtin stack but before the final pass (before FXAA & Dithering)
    15.         if (hasAfterStackEffects)
    16.             lastTarget = RenderInjectionPoint(PostProcessEvent.AfterStack, context, "AfterStack", lastTarget);
    17.     }
    18. }
    As you can see here, custom effects aren't provided with the "eye" index.

    Meaning the global "_DepthSlice" uniform can't be set up like it is in the RenderBuiltins function, nor can the BlitFullscreenTriangleFromTexArray function be used properly.

    In turn the stereoTargetEyeIndex value in the vertex shader is never set up. The eye index will always be 0 in shaders because of this.

    As a result, the depth texture array can't be sampled correctly for the right eye. Which appears the be the same reason why the Ambient Occlusion and Depth of Field effects don't work in VR.

    There aren't any macros for texture arrays, but that's another issue...

    Proposed solution:
    Setup the context.xrActiveEye parameter with the "eye" index value. Currently this is only set up with
    Camera.stereoActiveEye, which is only relevant for Multi-pass VR rendering.

    Tagging @Chman in case this is still under your wing
     
    Last edited: Apr 11, 2022
  2. unity01_unity785

    unity01_unity785

    Joined:
    Jan 4, 2019
    Posts:
    2
    Hello there, do you know if there is an official solution for this? I'm having the exact same problem.
     
  3. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156