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));
}
}