Unity 6 Scriptable Render Pipeline using RenderGraph

I’m trying to implement an outline shader. I have the full-screen, post-process shader completely working, but I’m trying to implement a ScriptableRenderFeature. This code has changed so many times, I can’t keep up with it.

Anyway, the issue is my ExecutePass function which doesn’t have a “DrawRenderers” method, nor does it have “cullingResults” - which is the older way to do things. But I don’t know how to replace it.

private static void ExecutePass(PassData data, RasterGraphContext context)
{
    var cmd = context.cmd;

    // Set the layer mask and material
    DrawingSettings drawingSettings = new DrawingSettings(new ShaderTagId("UniversalForward"), new SortingSettings())
    {
        overrideMaterial = data.material
    };
    FilteringSettings filteringSettings = new FilteringSettings(RenderQueueRange.all, data.layerMask);

    context.cmd.DrawRenderers(context.cullingResults, ref drawingSettings, ref filteringSettings);

    // Blit to the output texture if necessary (e.g., if using a material)
    if (data.material != null)
    {
        Blitter.BlitTexture(cmd, data.copySourceTexture, new Vector4(1, 1, 0, 0), 0, false);
    }
}

public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
{
    string passName = "Outlines";

    // First Pass: Render objects with the first LayerMask.
    using (IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass<PassData>(passName + "_FirstPass", out PassData firstPassData))
    {
        UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();

        firstPassData.copySourceTexture = resourceData.activeColorTexture;
        firstPassData.layerMask = settings.FirstPassLayerMask;
        firstPassData.material = null; // Use default materials for the first pass.

        builder.UseTexture(firstPassData.copySourceTexture);

        builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context));
    }

    // Second Pass: Render objects with the second LayerMask and OutlineMaterial.
    using (IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass<PassData>(passName + "_SecondPass", out PassData secondPassData))
    {
        UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();

        secondPassData.copySourceTexture = resourceData.activeColorTexture;
        secondPassData.layerMask = settings.SecondPassLayerMask;
        secondPassData.material = settings.OutlineMaterial; // Use the outline material for the second pass.

        builder.UseTexture(secondPassData.copySourceTexture);

        builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context));
    }
}

Hello, did you manage to figure out how to do this in RenderGraph? There are so few working examples out there. I can only get a full screen shader to work, but not one that selectively applies effects to certain objects/layers.

Hi,
From my experience, you can use context.cmd.DrawRendererList() API in your ExecutePass function, this is similar to DrawRenderers

The RenderGraph package samples show some concrete code examples. You can find an overview of the learning materials here.