Blitter.BlitCameraTexture seems to fail on VR devices when SPI.

I modified a blurring RendererFeature from the official manual.
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@14.0/manual/containers/create-custom-renderer-feature-1.html

Here is my code and capture video.
https://github.com/emptybraces/Unity-URP_Stackable-UI-Blur

9523333--1343461--upload_2023-12-12_5-41-32.png
It is fine on the editor, but when I check it in quest through OculusLink, it is instantly grayed out.
I saw in the manual that cmd.Blit is not working, but is Blitter.BlitCameraTexture also same? I would like to know if there is a workaround. Or is there something wrong with the code…
I’m use Unity 2022.3, 2023.2, SinglePassInstanced, XR Interaction Toolkit.

public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
    if (renderingData.cameraData.camera.cameraType != CameraType.Game)
        return;

    //Get a CommandBuffer from pool.
    var cmd = CommandBufferPool.Get(nameof(ScreenBlurRenderPass));
    using (new ProfilingScope(cmd, _profilingSampler))
    {
        var camera_target_handle = renderingData.cameraData.renderer.cameraColorTargetHandle;
        Blitter.BlitCameraTexture(cmd, camera_target_handle, _grabRTHandle);

        cmd.SetGlobalTexture(_grabTexID, _grabRTHandle);

        UpdateBlurSettings();

        Blitter.BlitCameraTexture(cmd, camera_target_handle, _blurRTHandle1, _material, 0);

        Blitter.BlitCameraTexture(cmd, _blurRTHandle1, _blurRTHandle2, _material, 1);
        cmd.SetGlobalTexture(_grabBlurTexID, _blurRTHandle2);

        if (param.IsApplyScreen)
        {
            Blitter.BlitCameraTexture(cmd, _blurRTHandle2, camera_target_handle);
        }
        else
        {
            CoreUtils.SetRenderTarget(cmd, camera_target_handle);
        }
    }

    //Execute the command buffer and release it back to the pool.
    context.ExecuteCommandBuffer(cmd);
    // cmd.Clear();
    CommandBufferPool.Release(cmd);
}

UPDATE:
Apparently cannot Blit to RTHandle unless the injection timing is set BeforeRenderingSkybox or less.

9523333--1343461--upload_2023-12-12_5-41-32.png

@maximilianahead Try the experimental Acrylic layer feature from the Mixed Reality Toolkit. It’s designed for VR and AR, so hopefully it should work for you.

Thank you for info! I see Acylic sample on v0.5.0 latest, left side of camera Acrylic sample is don’t working, but right side Acrylic Fast sample is working. I’ll dive into their code.

In Acrylic scene, processing on the right side was textures were pre-blurred and then just clipped so it’s not that real-time background blurred.
But left side sample seems perfectly fine in Multi-pass mode, and even in my sample is working if Multi-pass.
It seems that transparent objects cannot be grabbed in SPI mode. I changed thread title…

SPI requires the following information in RenderTextureDescription.
Now working.

_blurTextureDescriptor.dimension = TextureDimension.Tex2DArray;```
1 Like

v0.5.0 is the latest release, but you can also access v0.6.5 using:
https://github.com/microsoft/MixedReality-GraphicsTools-Unity.git?path=/com.microsoft.mrtk.graphicstools.unity#v0.6.5

1 Like