#if MODULE_RENDER_PIPELINES_UNIVERSAL using UnityEngine; using UnityEngine.Rendering; #if MODULE_RENDER_PIPELINES_UNIVERSAL_17_0_0_OR_NEWER using UnityEngine.Rendering.RenderGraphModule; #endif using UnityEngine.Rendering.Universal; namespace Pathfinding.Drawing { /// Custom Universal Render Pipeline Render Pass for ALINE public class AlineURPRenderPassFeature : ScriptableRendererFeature { /// Custom Universal Render Pipeline Render Pass for ALINE public class AlineURPRenderPass : ScriptableRenderPass { /// This method is called before executing the render pass #if MODULE_RENDER_PIPELINES_UNIVERSAL_17_0_0_OR_NEWER [System.Obsolete] #endif public override void Configure (CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) { } #if MODULE_RENDER_PIPELINES_UNIVERSAL_17_0_0_OR_NEWER [System.Obsolete] #endif public override void Execute (ScriptableRenderContext context, ref RenderingData renderingData) { DrawingManager.instance.ExecuteCustomRenderPass(context, renderingData.cameraData.camera); } public AlineURPRenderPass() : base() { profilingSampler = new ProfilingSampler("ALINE"); } #if MODULE_RENDER_PIPELINES_UNIVERSAL_17_0_0_OR_NEWER private class PassData { public Camera camera; } public override void RecordRenderGraph (RenderGraph renderGraph, ContextContainer frameData) { var cameraData = frameData.Get(); var resourceData = frameData.Get(); using (IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass("ALINE", out PassData passData, profilingSampler)) { bool allowDisablingWireframe = false; if (Application.isEditor && (cameraData.cameraType & (CameraType.SceneView | CameraType.Preview)) != 0) { // We need this to be able to disable wireframe rendering in the scene view builder.AllowGlobalStateModification(true); allowDisablingWireframe = true; } builder.SetRenderAttachment(resourceData.activeColorTexture, 0); builder.SetRenderAttachmentDepth(resourceData.activeDepthTexture); passData.camera = cameraData.camera; builder.SetRenderFunc( (PassData data, RasterGraphContext context) => { DrawingManager.instance.ExecuteCustomRenderGraphPass(new DrawingData.CommandBufferWrapper { cmd2 = context.cmd, allowDisablingWireframe = allowDisablingWireframe }, data.camera); } ); } } #endif public override void FrameCleanup (CommandBuffer cmd) { } } AlineURPRenderPass m_ScriptablePass; public override void Create () { m_ScriptablePass = new AlineURPRenderPass(); // Configures where the render pass should be injected. // URP's post processing actually happens in BeforeRenderingPostProcessing, not after BeforeRenderingPostProcessing as one would expect. // Use BeforeRenderingPostProcessing-1 to ensure this pass gets executed before post processing effects. m_ScriptablePass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing-1; } /// This method is called when setting up the renderer once per-camera public override void AddRenderPasses (ScriptableRenderer renderer, ref RenderingData renderingData) { AddRenderPasses(renderer); } public void AddRenderPasses (ScriptableRenderer renderer) { renderer.EnqueuePass(m_ScriptablePass); } } } #endif