I am writing a ScriptableRenderPass using RenderGraph, in order to implement planar reflections, in URP.
Before using RenderGraph, I used
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
to get the ScriptableRenderContext, modify the camera position and viewM and calculate cullingResults.
How can I also implement this in the RecordRenderGraph function?
This is my current code
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext)
{
using var builder = renderGraph.AddRasterRenderPass<PassData>("Planar Ref", out var passData);
var renderingData = frameContext.Get<UniversalRenderingData>();
var cameraData = frameContext.Get<UniversalCameraData>();
var lightData = frameContext.Get<UniversalLightData>();
var sortFlags = cameraData.defaultOpaqueSortFlags;
var renderQueueRange = RenderQueueRange.opaque;
var filterSettings = new FilteringSettings(renderQueueRange, ~0);
var shadersToOverride = new ShaderTagId("UniversalForward");
var drawSettings = RenderingUtils.CreateDrawingSettings(shadersToOverride, renderingData, cameraData, lightData, sortFlags);
var textureProperties = cameraData.cameraTargetDescriptor;
textureProperties.depthBufferBits = 0;
var texture =
UniversalRenderer.CreateRenderGraphTexture(renderGraph, textureProperties, "Mask Texture", false);
var camera = cameraData.camera;
var camTransform = camera.transform;
var rotation = camTransform.rotation;
var mirrorPos = mirrorPlanar.mirrorPos(camTransform.position);
var viewM = mirrorPlanar.GetViewMat(camTransform.position, rotation);
var plane = mirrorPlanar.plane;
var cullMat = Matrix4x4.Frustum(-1, 1, -1, 1, 0.0000001f, 10000000f);
camera.cullingMatrix = cullMat * viewM;
camera.TryGetCullingParameters(out var cullingParameters);
ScriptableRenderContext context = ____________________;
var cullingResults = context.Cull(ref cullingParameters);
var rendererListParameters = new RendererListParams(cullingResults, drawSettings, filterSettings);
passData.rendererList = renderGraph.CreateRendererList(rendererListParameters);