using UnityEngine; using UnityEngine.Rendering.Universal; namespace SicknessReduction.Visual.Rendering { public class BokehFeature : ScriptableRendererFeature { [System.Serializable] public class BokehFeatureSettings { // we're free to put whatever we want here, public fields will be exposed in the inspector public bool IsEnabled = true; public RenderPassEvent WhenToInsert = RenderPassEvent.AfterRendering; public float maxCoc; public float focusDistance; public Material fragMaterial; } // MUST be named "settings" (lowercase) to be shown in the Render Features inspector public BokehFeatureSettings settings = new BokehFeatureSettings(); RenderTargetHandle renderTextureHandle; BokehRenderPass myRenderPass; public override void Create() { myRenderPass = new BokehRenderPass( "Bokeh Render Pass", settings ); } // called every frame once per camera public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) { if (!settings.IsEnabled) { // we can do nothing this frame if we want return; } // Gather up and pass any extra information our pass will need. // In this case we're getting the camera's color buffer target var cameraColorTargetIdent = renderer.cameraColorTarget; myRenderPass.Setup(renderingData.cameraData.cameraTargetDescriptor, cameraColorTargetIdent); // Ask the renderer to add our pass. // Could queue up multiple passes and/or pick passes to use renderer.EnqueuePass(myRenderPass); } } }