Formalize camera post-process descriptors
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <XCEngine/Core/Math/Color.h>
|
||||
#include <XCEngine/Core/Math/Rect.h>
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
#include <XCEngine/Rendering/Planning/CameraPostProcessDesc.h>
|
||||
#include <XCEngine/Resources/Material/Material.h>
|
||||
|
||||
#include <string>
|
||||
@@ -91,16 +92,21 @@ public:
|
||||
const Math::Color& GetSkyboxBottomColor() const { return m_skyboxBottomColor; }
|
||||
void SetSkyboxBottomColor(const Math::Color& value) { m_skyboxBottomColor = value; }
|
||||
|
||||
const Rendering::CameraPostProcessStack& GetPostProcessPasses() const { return m_postProcessPasses; }
|
||||
void SetPostProcessPasses(const Rendering::CameraPostProcessStack& values);
|
||||
void AddPostProcessPass(const Rendering::CameraPostProcessPassDesc& value);
|
||||
void ClearPostProcessPasses() { m_postProcessPasses.clear(); }
|
||||
|
||||
bool IsColorScalePostProcessEnabled() const;
|
||||
void SetColorScalePostProcessEnabled(bool value);
|
||||
|
||||
const Math::Vector4& GetColorScalePostProcessScale() const;
|
||||
void SetColorScalePostProcessScale(const Math::Vector4& value);
|
||||
|
||||
const std::vector<Math::Vector4>& GetColorScalePostProcessPasses() const { return m_colorScalePostProcessPasses; }
|
||||
std::vector<Math::Vector4> GetColorScalePostProcessPasses() const;
|
||||
void SetColorScalePostProcessPasses(const std::vector<Math::Vector4>& values);
|
||||
void AddColorScalePostProcessPass(const Math::Vector4& value);
|
||||
void ClearColorScalePostProcessPasses() { m_colorScalePostProcessPasses.clear(); }
|
||||
void ClearColorScalePostProcessPasses();
|
||||
|
||||
void Serialize(std::ostream& os) const override;
|
||||
void Deserialize(std::istream& is) override;
|
||||
@@ -126,7 +132,7 @@ private:
|
||||
Math::Color m_skyboxHorizonColor = Math::Color(0.78f, 0.84f, 0.92f, 1.0f);
|
||||
Math::Color m_skyboxBottomColor = Math::Color(0.92f, 0.93f, 0.95f, 1.0f);
|
||||
Math::Vector4 m_colorScalePostProcessDefaultScale = Math::Vector4::One();
|
||||
std::vector<Math::Vector4> m_colorScalePostProcessPasses;
|
||||
Rendering::CameraPostProcessStack m_postProcessPasses;
|
||||
};
|
||||
|
||||
} // namespace Components
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
enum class CameraPostProcessPassType : uint8_t {
|
||||
ColorScale = 0
|
||||
};
|
||||
|
||||
struct CameraColorScalePostProcessDesc {
|
||||
Math::Vector4 scale = Math::Vector4::One();
|
||||
};
|
||||
|
||||
struct CameraPostProcessPassDesc {
|
||||
CameraPostProcessPassType type = CameraPostProcessPassType::ColorScale;
|
||||
CameraColorScalePostProcessDesc colorScale = {};
|
||||
|
||||
static CameraPostProcessPassDesc MakeColorScale(const Math::Vector4& scale) {
|
||||
CameraPostProcessPassDesc desc = {};
|
||||
desc.type = CameraPostProcessPassType::ColorScale;
|
||||
desc.colorScale.scale = scale;
|
||||
return desc;
|
||||
}
|
||||
|
||||
bool IsValid() const {
|
||||
switch (type) {
|
||||
case CameraPostProcessPassType::ColorScale:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using CameraPostProcessStack = std::vector<CameraPostProcessPassDesc>;
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Rendering/Passes/BuiltinColorScalePostProcessPass.h>
|
||||
#include <XCEngine/Rendering/Planning/CameraPostProcessDesc.h>
|
||||
#include <XCEngine/Rendering/RenderPass.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
inline std::unique_ptr<RenderPassSequence> BuildCameraPostProcessPassSequence(
|
||||
const CameraPostProcessStack& postProcessStack) {
|
||||
if (postProcessStack.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderPassSequence> sequence = std::make_unique<RenderPassSequence>();
|
||||
for (const CameraPostProcessPassDesc& passDesc : postProcessStack) {
|
||||
if (!passDesc.IsValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (passDesc.type) {
|
||||
case CameraPostProcessPassType::ColorScale:
|
||||
sequence->AddPass(std::make_unique<Passes::BuiltinColorScalePostProcessPass>(
|
||||
passDesc.colorScale.scale));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sequence->GetPassCount() == 0u) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user