Opaque Discs Drawing Over Cnavas
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?
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?
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 );
}
}
}
Thanks! I was not using "RenderPassEvent.AfterRenderingOpaques". Seems to have fixed the issue.
Is there any downside to subscribing like this as opposed to using ImmediateModeShapeDrawer:
protected virtual void Awake()
{
RenderPipelineManager.beginCameraRendering += Draw;
}
private void OnDestroy()
{
RenderPipelineManager.beginCameraRendering -= Draw;
}
and then in the Draw function:
private void Draw(ScriptableRenderContext context, Camera camera)
{
using (Shapes.Draw.Command(camera, RenderPassEvent.AfterRenderingOpaques))
{
// Draw stuff here!
}
}
I like to do this for each script that needs to draw. I understand I lose the ability to define draw order, but otherwise it should be fine right? Instancing should work out alright since I am only drawing similar shapes within the same draw function.
Updated to 4.5.0 and this problem still seems to be the case.