// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "RendererPass.h" /// /// Anti aliasing rendering service /// class MotionBlurPass : public RendererPass { private: PixelFormat _motionVectorsFormat; AssetReference _shader; GPUPipelineState* _psCameraMotionVectors = nullptr; GPUPipelineState* _psMotionVectorsDebug = nullptr; GPUPipelineState* _psTileMax = nullptr; GPUPipelineState* _psTileMaxVariable = nullptr; GPUPipelineState* _psNeighborMax = nullptr; GPUPipelineState* _psMotionBlur = nullptr; public: /// /// Init /// MotionBlurPass(); public: /// /// Renders the motion vectors texture for the current task. Skips if motion blur is disabled or no need to render motion vectors. /// /// The rendering context. void RenderMotionVectors(RenderContext& renderContext); /// /// Renders the motion vectors debug view. /// /// The rendering context. /// The source frame. void RenderDebug(RenderContext& renderContext, GPUTextureView* frame); /// /// Renders the motion blur. Swaps the input with output if rendering is performed. Does nothing if rendering is not performed. /// /// 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: #if COMPILE_WITH_DEV_ENV void OnShaderReloading(Asset* obj) { _psCameraMotionVectors->ReleaseGPU(); _psMotionVectorsDebug->ReleaseGPU(); _psTileMax->ReleaseGPU(); _psTileMaxVariable->ReleaseGPU(); _psNeighborMax->ReleaseGPU(); _psMotionBlur->ReleaseGPU(); invalidateResources(); } #endif public: // [RendererPass] String ToString() const override; bool Init() override; void Dispose() override; protected: // [RendererPass] bool setupResources() override; };