Skip to content

Commit

Permalink
Fix Wireframe not rendering when using Vulkan API.
Browse files Browse the repository at this point in the history
Jira ticket: https://jira.unity3d.com/browse/UUM-36914

Initial context + initial fix + explanation: https://github.cds.internal.unity3d.com/unity/unity/pull/25910
More context for the Vulkan Terrain edge case: https://ono.unity3d.com/unity/unity/pull-request/111240/_/graphics/vulkan/case-1205332

It looks like the fix was not working for Vulkan (Scene View + URP + Wireframe mode), due to the `UseGfxDeviceWireframeShader(device)` if statement. 
Basically, the wireframe was not rendering at all. Removing it and using the normal path (`BeginWireframeWithShader`) fixes it.

`Before vs After`:
![image](https://media.github.cds.internal.unity3d.com/user/1911/files/41435df5-1bcb-4fda-99c1-21b894e30910)
  • Loading branch information
YohannVaastUnity authored and Evergreen committed Jun 5, 2024
1 parent b4333e2 commit c55bd46
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,19 @@ internal static void FinalBlit(
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget,
loadAction, storeAction, // color
RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); // depth
cmd.Blit(source.nameID, destination.nameID);

// Necessary to disable the wireframe here, since Vulkan is handling the wireframe differently
// to handle the Terrain "Draw Instanced" scenario (Ono: case-1205332).
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan)
{
cmd.SetWireframe(false);
cmd.Blit(source, destination);
cmd.SetWireframe(true);
}
else
{
cmd.Blit(source, destination);
}
}
else if (source.rt == null)
Blitter.BlitTexture(cmd, source.nameID, scaleBias, material, passIndex); // Obsolete usage of RTHandle aliasing a RenderTargetIdentifier
Expand Down

0 comments on commit c55bd46

Please sign in to comment.