125 lines
3.5 KiB
C++
125 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/Core/Math/Vector2.h>
|
|
#include <XCEngine/Core/Math/Vector3.h>
|
|
#include <XCEngine/Core/Math/Vector4.h>
|
|
#include <XCEngine/Rendering/FrameData/RenderCameraData.h>
|
|
#include <XCEngine/Rendering/FrameData/RenderEnvironmentData.h>
|
|
#include <XCEngine/Rendering/FrameData/VisibleGaussianSplatItem.h>
|
|
#include <XCEngine/Rendering/FrameData/VisibleRenderItem.h>
|
|
#include <XCEngine/Rendering/FrameData/VisibleVolumeItem.h>
|
|
#include <XCEngine/Resources/Shader/ShaderKeywordTypes.h>
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace Components {
|
|
class CameraComponent;
|
|
} // namespace Components
|
|
|
|
namespace RHI {
|
|
class RHIResourceView;
|
|
} // namespace RHI
|
|
|
|
namespace Rendering {
|
|
|
|
struct RenderDirectionalLightData {
|
|
bool enabled = false;
|
|
bool castsShadows = false;
|
|
Math::Vector3 direction = Math::Vector3::Back();
|
|
float intensity = 1.0f;
|
|
Math::Color color = Math::Color::White();
|
|
};
|
|
|
|
enum class RenderLightType : uint32_t {
|
|
Directional = 0,
|
|
Point = 1,
|
|
Spot = 2
|
|
};
|
|
|
|
struct RenderAdditionalLightData {
|
|
RenderLightType type = RenderLightType::Point;
|
|
bool enabled = false;
|
|
bool castsShadows = false;
|
|
Math::Color color = Math::Color::White();
|
|
float intensity = 1.0f;
|
|
Math::Vector3 position = Math::Vector3::Zero();
|
|
Math::Vector3 direction = Math::Vector3::Back();
|
|
float range = 0.0f;
|
|
float spotAngle = 0.0f;
|
|
};
|
|
|
|
struct RenderDirectionalShadowMapMetrics {
|
|
Math::Vector2 inverseMapSize = Math::Vector2::Zero();
|
|
float worldTexelSize = 0.0f;
|
|
float padding = 0.0f;
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(RenderDirectionalShadowMapMetrics) == sizeof(float) * 4u,
|
|
"RenderDirectionalShadowMapMetrics must stay float4-sized for GPU constant layout");
|
|
|
|
struct RenderDirectionalShadowSamplingData {
|
|
float enabled = 0.0f;
|
|
float receiverDepthBias = 0.0f;
|
|
float normalBiasScale = 0.0f;
|
|
float shadowStrength = 0.0f;
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(RenderDirectionalShadowSamplingData) == sizeof(float) * 4u,
|
|
"RenderDirectionalShadowSamplingData must stay float4-sized for GPU constant layout");
|
|
|
|
struct RenderDirectionalShadowData {
|
|
bool enabled = false;
|
|
Math::Matrix4x4 viewProjection = Math::Matrix4x4::Identity();
|
|
RenderDirectionalShadowMapMetrics mapMetrics = {};
|
|
RenderDirectionalShadowSamplingData sampling = {};
|
|
RHI::RHIResourceView* shadowMap = nullptr;
|
|
|
|
bool IsValid() const {
|
|
return enabled && shadowMap != nullptr;
|
|
}
|
|
};
|
|
|
|
struct RenderLightingData {
|
|
static constexpr uint32_t kMaxAdditionalLightCount = 8u;
|
|
|
|
RenderDirectionalLightData mainDirectionalLight;
|
|
RenderDirectionalShadowData mainDirectionalShadow;
|
|
std::array<RenderAdditionalLightData, kMaxAdditionalLightCount> additionalLights = {};
|
|
uint32_t additionalLightCount = 0u;
|
|
|
|
bool HasMainDirectionalLight() const {
|
|
return mainDirectionalLight.enabled;
|
|
}
|
|
|
|
bool HasMainDirectionalShadow() const {
|
|
return mainDirectionalShadow.IsValid();
|
|
}
|
|
|
|
bool HasAdditionalLights() const {
|
|
return additionalLightCount > 0u;
|
|
}
|
|
};
|
|
|
|
struct RenderSceneData {
|
|
Components::CameraComponent* camera = nullptr;
|
|
RenderCameraData cameraData;
|
|
RenderEnvironmentData environment;
|
|
RenderLightingData lighting;
|
|
Resources::ShaderKeywordSet globalShaderKeywords;
|
|
std::vector<VisibleRenderItem> visibleItems;
|
|
std::vector<VisibleGaussianSplatItem> visibleGaussianSplats;
|
|
std::vector<VisibleVolumeItem> visibleVolumes;
|
|
|
|
bool HasCamera() const {
|
|
return camera != nullptr;
|
|
}
|
|
};
|
|
|
|
} // namespace Rendering
|
|
} // namespace XCEngine
|