Search Unity

[LWRP] [Android] [Single pass stereo] Custom image effect sample without PPSV2

Discussion in 'AR/VR (XR) Discussion' started by Azirell, Jul 19, 2019.

  1. Azirell

    Azirell

    Joined:
    Oct 16, 2015
    Posts:
    29
    Hi everyone. I'm wondering if there any way to make any image effect for LWRP that would work on Android single pass stereo (multi pass performance is unacceptable), target devices Oculus GO/Quest.

    At the moment LWRP internally hardcoded disables PostProcessings for mobile VR in Stereo mode.
    Which is quite ironically as the LW targeted to low-middle hardware (which mobiles are). I'm sure there are reasons why Unity didn't add support for it at the moment and it might be added in future. But platform released now and games should be made now. Unfortunately builtin AA almost has no effect, FXAA at least must have. Hence picture on builtin resources is garbage for this platform.

    So, I'm asking for a tip/clue/guide on how to setup any image effect for LWRP in avoid of PPSV2.

    All my attempts in doing it in tech specs in spoilers below.

    That can be done. I've managed to adjust one asset to work. Bloom/Blur work. But I also want to benefit from LWRP performance, so that is plan B.
    htt ps://docs.unity3d.com/Manual/Android-SinglePassStereoRendering.html

    LWRP asset 5.7.2 -> [Project window] -> Packages -> Lightweight RP -> Runtime -> LightweightRenderPipeline.cs -> line: 216-218
    Code (CSharp):
    1. // Disables postprocessing in mobile VR. It's stable on mobile yet.
    2.             if (cameraData.isStereoEnabled && Application.isMobilePlatform)
    3.                 cameraData.postProcessEnabled = false;
    setting value to true makes image effect corrupt whole image - left eye white and right eye is black, it seems like shaders work with texture2d instead of texture2darray,
    other manipulations with LightweightRenderPipeline.cs produce various errors.

    At the moment I trying to inject render step into ScriptableRenderPass.cs line: 138, seems like PostProcessing launched from there. But no matter what commands I add to a CommandBuffer there is no effect at all (even extension commands like BlitFullTriangle, BlitFullTriangleFromTextureArray, BlitFullTriangleFromTexture array and so on).
    I've also tried to add commands via Camera.AddCommandBuffer, tried to subscribe to RenderPipeline.beginCameraRendering, but no luck. I, probably, missing something.

    P.S. really hope this would not be one of those themes where author answers it by himself in one eternity later.
     
    Last edited: Jul 19, 2019
    anishAus likes this.