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

[URP MRT] Original Material Displays Corrupted by Multi-Render Targets

Under Audit

graphicsasset pipeline

Unity 2021.3.x - Unity 2023.2.x

Published 25 days ago

Users porting projects from Built-in Render Pipeline (BIRP) to Universal Render Pipeline (URP) face challenges implementing multiple render targets (MRT) while preserving individual object materials.

Issue

 Porting projects from the Built-in Render Pipeline (BIRP) to the Universal Render Pipeline (URP) presents challenges, specifically regarding the implementation of multiple render targets (MRT), which lacks out-of-the-box support in URP. Custom render passes within URP and the Scriptable Render Pipeline (SRP) are often predicated on the assumption that a single material will be used for all rendering operations within that pass. However, the requirement is to enable multiple render targets for a scene containing numerous objects with diverse materials—all utilizing compatible shaders—without mandating a single material across the entire render pass. The straightforward Camera method for specifying multiple render targets and a separate depth target, which was available in BIRP, does not have an immediate or obvious equivalent in URP. The primary concern is whether enabling multiple render targets in URP necessitates a complete rewrite of the existing batching and sorting systems.

Experimental Fixes
  • Implement a custom RendererFeature to inject your own ScriptableRenderPass and explicitly manage RenderTexture attachments for multiple render targets.
  • Investigate using CommandBuffer to explicitly set RenderBuffer targets and draw individual Renderer objects with their original materials, potentially iterating through Renderers in the scene.
  • Ensure your shaders are correctly configured to write to multiple render targets using SV_Target0, SV_Target1, etc., and that they are compatible with URP.

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.