Opaque Discs Drawing Over Cnavas

Avatar
  • updated

I am drawing opaque discs in immediate mode using "beginCameraRendering" but they draw on top of world space canvases. Is there anything I can do to fix this?

Reporting a bug? please specify Unity version:
2022.3.27f1
Reporting a bug? please specify Shapes version:
4.3.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator

What do you mean by using "beginCameraRendering" specifically?

Shapes is very sensitive to the exact moment to render in, I generally recommend using the ImmediateModeShapeDrawer helper class for this.

For example, this will draw opaque shapes properly together with world space canvases:

using Shapes;
using UnityEngine;
using UnityEngine.Rendering.Universal;

[ExecuteAlways] // <-- just to make it draw in the scene view as well
public class OpaqueOrderTest : ImmediateModeShapeDrawer {
public override void DrawShapes( Camera cam ) {
using( Draw.Command( cam, RenderPassEvent.AfterRenderingOpaques ) ) {
Draw.BlendMode = ShapesBlendMode.Opaque;
Draw.Disc( Vector3.zero, 100, Color.red );
}
}
}

Image 885

Avatar
Harper Rhett

Updated to 4.5.0 and this problem still seems to be the case.