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
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.