[URP] Lacking Render Pass Injection Points

Hi, the current URP render pass events don’t allow rendering before/after motion vectors and TAA.

I remember that this is possible in HDRP, so is there any plan to add this important feature?

1 Like

Bump.

All motion related effects can only access correct motion vectors after rendering post-processing, which will break many things (distortion, TAA).

If it’s technically difficult to add new injection points (RenderPassEvent), I suggest moving the URP motion vectors pass to before rendering post-processing.

Hey!

I double checked the code and the pass is already injected BeforeRenderingPostProcessing, have you tried injecting your pass at RenderPassEvent.BeforeRenderingPostProcessing + 1? In general injection points work like integers in a certain range for priority, so adding N after your RenderPassEvent should allow you to have your pass in between MotionVector and PostProcessing. Not sure if this helps?

 internal MotionVectorRenderPass(Material cameraMaterial)
        {
            renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
            m_CameraMaterial = cameraMaterial;
            m_PassData = new PassData();
            base.profilingSampler = ProfilingSampler.Get(URPProfileId.MotionVectors);

            ConfigureInput(ScriptableRenderPassInput.Depth);
        }

we are also discussing changing some passes RenderPassEvents in the frame so will considering moving motion vectors earlier

Hi, thanks for the reply!

I tried injecting the render pass at RenderPassEvent.BeforeRenderingPostProcessing + 1, but the Blitter complains that renderingData.cameraData.renderer.cameraColorTargetHandle is null.

Assertion failed
UnityEngine.Rendering.Blitter:BlitCameraTexture (UnityEngine.Rendering.CommandBuffer,UnityEngine.Rendering.RTHandle,UnityEngine.Rendering.RTHandle,UnityEngine.Material,int)

...

Should I make a bug report? I used to think that RenderPassEvent.BeforeRenderingPostProcessing + 1 should not be used because of the error.

I did another test and the custom render pass works after removing the use of (empty) renderingData.cameraData.renderer.cameraColorTargetHandle, but it seems that the actual injection point will be the same as RenderPassEvent.AfterRenderingPostProcessing.

Perhaps moving the motion vectors pass earlier is the only solution to this. Is it possible to have this solved in 2023.2, because I believe temporal reprojection is a big usage of motion vectors.

Thanks again!

Bump

I had a look and looks like the postprocessing passes are being queued in BeforeRenderingPostProcessing, so any render feature injected in the same place wouldn’t work as expected. I am making a quick fix moving the postProcessing pass in the correct place so your code should work as expected by using BeforeRenderingPostProcessing + 1

1 Like

(this will already work with the RenderGraph path once we enable it for everyone in 23 as we improved the injection point system for that, this specific fix should make it work as expected also on the old (current) one)

while waiting for the fix you can modify the package locally as a temporary workaround:

In PostProcessPasses.cs, replace the code at the end of the Recreate() function with this:

if (data != null)
            {
                m_ColorGradingLutPass = new ColorGradingLutPass(RenderPassEvent.BeforeRenderingPrePasses, data);
                m_PostProcessPass = new PostProcessPass(RenderPassEvent.AfterRenderingPostProcessing - 2, data, ref ppParams);
                m_FinalPostProcessPass = new PostProcessPass(RenderPassEvent.AfterRenderingPostProcessing - 1, data, ref ppParams);
                m_CurrentPostProcessData = data;
            }
2 Likes