metaforce/Runtime/Camera/CCameraFilter.hpp

118 lines
2.9 KiB
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2016-04-16 19:50:45 -07:00
#include "zeus/CColor.hpp"
#include "RetroTypes.hpp"
2016-08-19 21:22:13 -07:00
#include "CToken.hpp"
2017-11-16 00:05:10 -08:00
#include "Graphics/Shaders/CCameraBlurFilter.hpp"
#include "Graphics/Shaders/CXRayBlurFilter.hpp"
2016-04-16 19:50:45 -07:00
2018-12-07 21:30:43 -08:00
namespace urde {
2016-08-16 18:58:53 -07:00
class CTexture;
2016-04-16 19:50:45 -07:00
2018-12-07 21:30:43 -08:00
enum class EFilterType {
Passthru,
Multiply,
Invert,
Add,
Subtract,
Blend,
Widescreen,
SceneAdd,
NoColor,
InvDstMultiply
2017-05-31 22:34:24 -07:00
};
2018-12-07 21:30:43 -08:00
enum class EFilterShape {
Fullscreen,
FullscreenHalvesLeftRight,
FullscreenHalvesTopBottom,
FullscreenQuarters,
CinemaBars,
ScanLinesEven,
ScanLinesOdd,
RandomStatic,
CookieCutterDepthRandomStatic
2017-05-31 22:34:24 -07:00
};
2018-12-07 21:30:43 -08:00
class CCameraFilterPassBase {
2017-05-31 22:34:24 -07:00
protected:
2018-12-07 21:30:43 -08:00
EFilterType x0_curType = EFilterType::Passthru;
EFilterType x4_nextType = EFilterType::Passthru;
EFilterShape x8_shape = EFilterShape::Fullscreen;
float xc_duration = 0.f;
float x10_remTime = 0.f;
zeus::CColor x14_prevColor;
zeus::CColor x18_curColor;
zeus::CColor x1c_nextColor;
CAssetId x20_nextTxtr;
TLockedToken<CTexture> x24_texObj; // Used to be auto_ptr
float GetT(bool invert) const;
2017-05-31 22:34:24 -07:00
public:
2018-12-07 21:30:43 -08:00
virtual ~CCameraFilterPassBase() = default;
virtual void Update(float dt) = 0;
virtual void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color,
CAssetId txtr) = 0;
virtual void DisableFilter(float time) = 0;
virtual void Draw() const = 0;
2017-05-31 22:34:24 -07:00
};
template <class S>
2018-12-07 21:30:43 -08:00
class CCameraFilterPass final : public CCameraFilterPassBase {
std::optional<S> m_shader;
2018-12-07 21:30:43 -08:00
2016-04-16 19:50:45 -07:00
public:
2018-12-07 21:30:43 -08:00
void Update(float dt);
void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color, CAssetId txtr);
void DisableFilter(float time);
void Draw() const;
2016-04-16 19:50:45 -07:00
};
2018-12-07 21:30:43 -08:00
class CCameraFilterPassPoly {
EFilterShape m_shape;
std::unique_ptr<CCameraFilterPassBase> m_filter;
2016-08-19 21:22:13 -07:00
public:
2018-12-07 21:30:43 -08:00
void Update(float dt) {
if (m_filter)
m_filter->Update(dt);
}
void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color, CAssetId txtr);
void DisableFilter(float time) {
if (m_filter)
m_filter->DisableFilter(time);
}
void Draw() const {
if (m_filter)
m_filter->Draw();
}
2017-05-31 22:34:24 -07:00
};
2018-12-07 21:30:43 -08:00
enum class EBlurType { NoBlur, LoBlur, HiBlur, Xray };
2017-05-31 22:34:24 -07:00
2018-12-07 21:30:43 -08:00
class CCameraBlurPass {
TLockedToken<CTexture> x0_paletteTex;
EBlurType x10_curType = EBlurType::NoBlur;
EBlurType x14_endType = EBlurType::NoBlur;
float x18_endValue = 0.f;
float x1c_curValue = 0.f;
float x20_startValue = 0.f;
float x24_totalTime = 0.f;
float x28_remainingTime = 0.f;
// bool x2c_usePersistent = false;
// bool x2d_noPersistentCopy = false;
// u32 x30_persistentBuf = 0;
2016-08-19 21:22:13 -07:00
mutable std::optional<CCameraBlurFilter> m_shader;
mutable std::optional<CXRayBlurFilter> m_xrayShader;
2017-11-16 00:05:10 -08:00
2017-03-23 22:30:16 -07:00
public:
2018-12-07 21:30:43 -08:00
void Draw(bool clearDepth = false);
void Update(float dt);
void SetBlur(EBlurType type, float amount, float duration);
void DisableBlur(float duration);
EBlurType GetCurrType() const { return x10_curType; }
2016-04-16 19:50:45 -07:00
};
2018-12-07 21:30:43 -08:00
} // namespace urde