UnityRef is currently in early development. Some features may be incomplete and/or not functioning.

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

graphics

Denoiser and URP Render Graph Context

Under Audit

renderingshaderspost-processing

Unity 2022.3.x - Unity 6.0.x

Published 2 days ago

Integrating the Unity Denoiser with URP's Render Graph is challenging as the denoiser requires access to ScriptableRenderContext, which the Render Graph does not directly expose. Additionally, the input texture's GraphicsFormat must be R32G32B32A32_SFloat to avoid crashes.

Issue

 When attempting to utilize the Unity Denoiser within a custom rendering pipeline integrated with URP's Render Graph, a dependency on ScriptableRenderContext is encountered. Specifically, the CommandBufferDenoiser.WaitForCompletion() method mandates a ScriptableRenderContext parameter, which is not directly accessible or exposed through the Render Graph API. Initial attempts to retrieve this context via reflection led to crashes, which were later identified to be caused by an incorrect GraphicsFormat of the input texture. The Unity Denoiser explicitly requires the input image to be in GraphicsFormat.R32G32B32A32_SFloat. While correcting the GraphicsFormat resolves the crashes, the fundamental problem of properly obtaining and supplying ScriptableRenderContext to the denoiser method within the Render Graph execution flow persists.

Experimental Fixes
  • Ensure the input texture used for denoising is explicitly set to GraphicsFormat.R32G32B32A32_SFloat.
  • Consider refactoring your custom rendering pipeline to utilize ScriptableRenderPass within your Render Graph passes, which might offer more direct avenues to access or manage rendering context.
  • Investigate official Render Graph APIs in newer URP versions for utility methods designed to safely provide ScriptableRenderContext for CommandBuffer operations.

Editor's Note:

The above fixes have not been verified by our audit team yet. They are provided exclusively for your own technical research. We recommend creating a backup of your project before proceeding with any attempts. Utilize at your own discretion!

Related Posts Haven't quite found a solution to your problem? We think these posts might help you.

Content inspired by a Unity discussion post.