Shapes IM and Unity 2023.3

Avatar
  • updated

Is Shapes not compatible with Unity 2023.3 yet? I can't seem to get immediate mode drawing to work. I see nothing in the frame debugger and the console has the following error produced every frame

"RecordRenderGraph is not implemented, the pass Shapes.ShapesRenderPass won't be recorded in the current RenderGraph."

Adding shapes to the scene works. Just immediate mode rendering doesn't seem to work.

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

does the Shapes settings window say anything about a faulty URP install?

Avatar
Patrick Hogan

I did a little digging and found the problem. As of Unity 2023.3.0a18, in new projects, Render Graph in URP is now enabled by default. There is still a compatibility mode that can be turned on in Project Settings > Graphics > Render Graph Settings, which I turned on and that works for the time being.


It comes with a warning: "Unity no longer develops or improves the rendering path that does not use Render Graph API. Use the Render Graph API when developing new graphics features."


So, it seems ShapesRenderPass will require some modification. Execute() is deprecated and there's a new method RecordRenderGraph().


I made a brief foray into writing the modification, but my knowledge of render passes is very limited and it doesn't appear to be a straightforward conversion.

This is what I tried:

class PassData {}
public override void RecordRenderGraph( RenderGraph renderGraph, ContextContainer frameData )
{
using var builder = renderGraph.AddRasterRenderPass<PassData>( "Render Shapes", out _ );
builder.SetRenderFunc( ( PassData _, RasterGraphContext context ) =>
{
drawCommand.AppendToBuffer( context.cmd ); // modified to take a RasterCommandBuffer
} ); }

This compiles, but produces execution errors along the lines of "BeginRenderPass: Already inside a Renderpass ..." at which point I was out of my depth and gave up. ¯\_(ツ)_/¯

Avatar
Scott Daley

I managed to get Shapes working in 2023.3.0b10 with minimal changes:

// Added to ShapesRenderPass.cs

private class PassData { }
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
{
using IUnsafeRenderGraphBuilder builder = renderGraph.AddUnsafePass<PassData>("Render Shapes", out _);
builder.AllowPassCulling(false);
builder.SetRenderFunc(
(PassData _, UnsafeGraphContext context) =>
{
CommandBuffer unsafeCmd = CommandBufferHelpers.GetNativeCommandBuffer(context.cmd);
drawCommand.AppendToBuffer(unsafeCmd);
}
);
}

This is very similar to what Patrick did above, but with the following changes:

  • builder.AllowPassCulling(false) : This fixes the "BeginRenderPass: Already inside a Renderpass ..." error
  • Instead of modifying DrawCommand to work with a RasterCommandBuffer, I added an "unsafe" pass so that it could continue using a normal CommandBuffer. This was only to reduce the amount of code changes needed. But I think adding a raster pass would be the more "correct" way from what I've read in the RenderGraph docs.