using XCEngine; using XCEngine.Rendering; namespace XCEngine.Rendering.Universal { internal sealed class UniversalPostProcessBlock { public void ConfigureCameraFramePlan( ScriptableRenderPipelinePlanningContext context, CameraFrameColorSource sourceColor) { if (context == null) { return; } bool needsGraphManagedOutputColor = context.HasFinalColorProcessing() || context.IsStageRequested( CameraFrameStage.FinalOutput); EnsurePostProcessStage( context, sourceColor, needsGraphManagedOutputColor); } public CameraFrameColorSource ResolveFinalOutputSource( ScriptableRenderPipelinePlanningContext context) { if (context == null || !context.IsStageRequested( CameraFrameStage.PostProcess)) { return CameraFrameColorSource.MainSceneColor; } CameraFrameColorSource postProcessSource = context.GetStageColorSource( CameraFrameStage.PostProcess); if (postProcessSource == CameraFrameColorSource.ExplicitSurface) { return CameraFrameColorSource.MainSceneColor; } PromoteToGraphManagedOutputColor( context); return CameraFrameColorSource.PostProcessColor; } public void EnqueueRenderPass( ScriptableRenderer renderer, RenderingData renderingData, ScriptableRenderPass renderPass) { if (renderer == null || renderingData == null || renderPass == null || !renderingData.isPostProcessStage) { return; } renderer.EnqueuePass(renderPass); } private static void EnsurePostProcessStage( ScriptableRenderPipelinePlanningContext context, CameraFrameColorSource sourceColor, bool needsGraphManagedOutputColor) { if (!context.IsStageRequested( CameraFrameStage.PostProcess)) { context.RequestFullscreenStage( CameraFrameStage.PostProcess, sourceColor, needsGraphManagedOutputColor); return; } if (!needsGraphManagedOutputColor) { return; } PromoteToGraphManagedOutputColor( context); } private static void PromoteToGraphManagedOutputColor( ScriptableRenderPipelinePlanningContext context) { if (context == null) { return; } CameraFrameColorSource source = context.GetStageColorSource( CameraFrameStage.PostProcess); if (source == CameraFrameColorSource.ExplicitSurface || context.UsesGraphManagedOutputColor( CameraFrameStage.PostProcess)) { return; } context.ClearFullscreenStage( CameraFrameStage.PostProcess); context.RequestFullscreenStage( CameraFrameStage.PostProcess, source, true); } } }