Extract bounded additional scene lights
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <XCEngine/Rendering/RenderCameraData.h>
|
||||
#include <XCEngine/Rendering/VisibleRenderObject.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
@@ -29,6 +30,24 @@ struct RenderDirectionalLightData {
|
||||
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 RenderDirectionalShadowData {
|
||||
bool enabled = false;
|
||||
Math::Matrix4x4 viewProjection = Math::Matrix4x4::Identity();
|
||||
@@ -41,8 +60,12 @@ struct RenderDirectionalShadowData {
|
||||
};
|
||||
|
||||
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;
|
||||
@@ -51,6 +74,10 @@ struct RenderLightingData {
|
||||
bool HasMainDirectionalShadow() const {
|
||||
return mainDirectionalShadow.IsValid();
|
||||
}
|
||||
|
||||
bool HasAdditionalLights() const {
|
||||
return additionalLightCount > 0u;
|
||||
}
|
||||
};
|
||||
|
||||
struct RenderSceneData {
|
||||
@@ -81,6 +108,8 @@ public:
|
||||
private:
|
||||
void ExtractLighting(
|
||||
const Components::Scene& scene,
|
||||
const Math::Vector3& cameraPosition,
|
||||
uint32_t cullingMask,
|
||||
RenderLightingData& lightingData) const;
|
||||
void ExtractVisibleItems(
|
||||
Components::GameObject* gameObject,
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace XCEngine {
|
||||
namespace Components {
|
||||
class CameraComponent;
|
||||
class GameObject;
|
||||
class LightComponent;
|
||||
class Scene;
|
||||
} // namespace Components
|
||||
|
||||
@@ -31,5 +32,18 @@ std::vector<VisibleRenderItem> CollectRenderItemsForEntityIds(
|
||||
const std::vector<uint64_t>& entityIds,
|
||||
const Math::Vector3& cameraPosition);
|
||||
|
||||
bool IsUsableLight(const Components::LightComponent* light);
|
||||
|
||||
bool IsLightVisibleForCullingMask(
|
||||
const Components::LightComponent& light,
|
||||
uint32_t cullingMask);
|
||||
|
||||
Math::Vector3 BuildRenderLightDirection(
|
||||
const Components::LightComponent& light);
|
||||
|
||||
Components::LightComponent* FindMainDirectionalLight(
|
||||
const Components::Scene& scene,
|
||||
uint32_t cullingMask = 0xFFFFFFFFu);
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
|
||||
Reference in New Issue
Block a user