feat: add basic forward lighting coverage

This commit is contained in:
2026-04-01 00:41:56 +08:00
parent ac2b7c1fa2
commit 3373119eee
10 changed files with 31741 additions and 7 deletions

View File

@@ -59,6 +59,9 @@ private:
Math::Matrix4x4 projection = Math::Matrix4x4::Identity();
Math::Matrix4x4 view = Math::Matrix4x4::Identity();
Math::Matrix4x4 model = Math::Matrix4x4::Identity();
Math::Matrix4x4 normalMatrix = Math::Matrix4x4::Identity();
Math::Vector4 mainLightDirectionAndIntensity = Math::Vector4::Zero();
Math::Vector4 mainLightColorAndFlags = Math::Vector4::Zero();
};
bool EnsureInitialized(const RenderContext& context);

View File

@@ -16,9 +16,25 @@ class Scene;
namespace Rendering {
struct RenderDirectionalLightData {
bool enabled = false;
Math::Vector3 direction = Math::Vector3::Back();
float intensity = 1.0f;
Math::Color color = Math::Color::White();
};
struct RenderLightingData {
RenderDirectionalLightData mainDirectionalLight;
bool HasMainDirectionalLight() const {
return mainDirectionalLight.enabled;
}
};
struct RenderSceneData {
Components::CameraComponent* camera = nullptr;
RenderCameraData cameraData;
RenderLightingData lighting;
std::vector<VisibleRenderItem> visibleItems;
bool HasCamera() const { return camera != nullptr; }
@@ -45,6 +61,9 @@ private:
const Components::CameraComponent& camera,
uint32_t viewportWidth,
uint32_t viewportHeight) const;
void ExtractLighting(
const Components::Scene& scene,
RenderLightingData& lightingData) const;
void ExtractVisibleItems(
Components::GameObject* gameObject,
const Math::Vector3& cameraPosition,