// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "RendererPass.h"
///
/// Eye adaptation effect based on color buffer luminance.
///
class EyeAdaptationPass : public RendererPass
{
private:
AssetReference _shader;
GPUPipelineState* _psManual = nullptr;
GPUPipelineState* _psLuminanceMap = nullptr;
GPUPipelineState* _psBlendLuminance = nullptr;
GPUPipelineState* _psApplyLuminance = nullptr;
GPUPipelineState* _psHistogram = nullptr;
bool _canUseHistogram;
public:
///
/// Performs the eye adaptation effect.
///
/// The rendering context.
/// The input and output color buffer to apply eye adaptation effect to it.
void Render(RenderContext& renderContext, GPUTexture* colorBuffer);
private:
#if COMPILE_WITH_DEV_ENV
void OnShaderReloading(Asset* obj)
{
_psManual->ReleaseGPU();
_psLuminanceMap->ReleaseGPU();
_psBlendLuminance->ReleaseGPU();
_psApplyLuminance->ReleaseGPU();
_psHistogram->ReleaseGPU();
invalidateResources();
}
#endif
public:
// [RendererPass]
String ToString() const override;
bool Init() override;
void Dispose() override;
protected:
// [RendererPass]
bool setupResources() override;
};