// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "RendererPass.h" #include "Engine/Graphics/PostProcessSettings.h" /// /// Depth of Field rendering /// class DepthOfFieldPass : public RendererPass { private: // Structure used for outputting bokeh points to an AppendStructuredBuffer struct BokehPoint { Float3 Position; float Blur; Float3 Color; }; bool _platformSupportsDoF = false; bool _platformSupportsBokeh = false; GPUBuffer* _bokehBuffer = nullptr; GPUBuffer* _bokehIndirectArgsBuffer = nullptr; AssetReference _shader; GPUPipelineState* _psDofDepthBlurGeneration = nullptr; GPUPipelineState* _psBokehGeneration = nullptr; GPUPipelineState* _psDoNotGenerateBokeh = nullptr; GPUPipelineState* _psBokeh = nullptr; GPUPipelineState* _psBokehComposite = nullptr; AssetReference _defaultBokehHexagon; AssetReference _defaultBokehOctagon; AssetReference _defaultBokehCircle; AssetReference _defaultBokehCross; public: DepthOfFieldPass(); public: /// /// Perform Depth Of Field rendering for the input task /// /// The rendering context. /// Input and output frame (leave unchanged when not using this effect). /// Temporary frame (the same format as frame) void Render(RenderContext& renderContext, GPUTexture*& frame, GPUTexture*& tmp); private: GPUTexture* getDofBokehShape(DepthOfFieldSettings& dofSettings); #if COMPILE_WITH_DEV_ENV void OnShaderReloading(Asset* obj) { _psDofDepthBlurGeneration->ReleaseGPU(); _psBokehGeneration->ReleaseGPU(); _psBokeh->ReleaseGPU(); _psBokehComposite->ReleaseGPU(); invalidateResources(); } #endif public: // [RendererPass] String ToString() const override; bool Init() override; void Dispose() override; protected: // [RendererPass] bool setupResources() override; };