Skip to content

Commit 50e699c

Browse files
amsXYZEvergreen
authored andcommitted
Fixed URP RG wireframe overlay rendering
This PR aims to fix Shaded-Wireframe rendering mode in URP when using RenderGraph, by introducing a "WireOverlay" `RasterRenderPass` that re-renders the scene for scene-view cameras if the mode is enabled. Since RenderGraph is now enabled by default, this was impacting the majority of our URP users using the latest betas. Jira: https://jira.unity3d.com/browse/UUM-67686
1 parent c214ad4 commit 50e699c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

Packages/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private static partial class Profiling
3939
public static readonly ProfilingSampler internalStartRendering = new ProfilingSampler($"{k_Name}.{nameof(InternalStartRendering)}");
4040
public static readonly ProfilingSampler internalFinishRenderingCommon = new ProfilingSampler($"{k_Name}.{nameof(InternalFinishRenderingCommon)}");
4141
public static readonly ProfilingSampler drawGizmos = new ProfilingSampler($"{nameof(DrawGizmos)}");
42+
public static readonly ProfilingSampler drawWireOverlay = new ProfilingSampler($"{nameof(DrawWireOverlay)}");
4243
internal static readonly ProfilingSampler beginXRRendering = new ProfilingSampler($"Begin XR Rendering");
4344
internal static readonly ProfilingSampler endXRRendering = new ProfilingSampler($"End XR Rendering");
4445
internal static readonly ProfilingSampler initRenderGraphFrame = new ProfilingSampler($"Initialize Render Graph frame settings");
@@ -992,6 +993,39 @@ internal void DrawRenderGraphGizmos(RenderGraph renderGraph, ContextContainer fr
992993
#endif
993994
}
994995

996+
private class DrawWireOverlayPassData
997+
{
998+
public RendererListHandle wireOverlayList;
999+
};
1000+
1001+
internal void DrawRenderGraphWireOverlay(RenderGraph renderGraph, ContextContainer frameData, TextureHandle color)
1002+
{
1003+
#if UNITY_EDITOR
1004+
UniversalCameraData cameraData = frameData.Get<UniversalCameraData>();
1005+
1006+
if (!cameraData.isSceneViewCamera)
1007+
return;
1008+
1009+
using (var builder = renderGraph.AddRasterRenderPass<DrawWireOverlayPassData>("Wire Overlay", out var passData,
1010+
Profiling.drawWireOverlay))
1011+
{
1012+
builder.SetRenderAttachment(color, 0, AccessFlags.Write);
1013+
1014+
passData.wireOverlayList = renderGraph.CreateWireOverlayRendererList(cameraData.camera);
1015+
builder.UseRendererList(passData.wireOverlayList);
1016+
builder.AllowPassCulling(false);
1017+
1018+
builder.SetRenderFunc(static (DrawWireOverlayPassData data, RasterGraphContext rgContext) =>
1019+
{
1020+
using (new ProfilingScope(rgContext.cmd, Profiling.drawWireOverlay))
1021+
{
1022+
rgContext.cmd.DrawRendererList(data.wireOverlayList);
1023+
}
1024+
});
1025+
}
1026+
#endif
1027+
}
1028+
9951029
private class BeginXRPassData
9961030
{
9971031
internal UniversalCameraData cameraData;

Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,9 @@ private void OnAfterRendering(RenderGraph renderGraph)
14411441
m_FinalDepthCopyPass.Render(renderGraph, frameData, resourceData.activeDepthTexture, cameraDepthTexture, false, "Final Depth Copy");
14421442
}
14431443
#endif
1444+
if (cameraData.isSceneViewCamera)
1445+
DrawRenderGraphWireOverlay(renderGraph, frameData, resourceData.backBufferColor);
1446+
14441447
if (drawGizmos)
14451448
DrawRenderGraphGizmos(renderGraph, frameData, resourceData.backBufferColor, resourceData.activeDepthTexture, GizmoSubset.PostImageEffects);
14461449
}

0 commit comments

Comments
 (0)