From ea2fdc939b9eb3912e09a0976488a47bd66c7538 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 9 Aug 2017 21:37:01 -1000 Subject: [PATCH] Create directional light for bump mapped water rendering --- Runtime/Graphics/CLight.hpp | 30 ++++++++++++++++++------------ Runtime/World/CFluidPlaneCPU.cpp | 31 +++---------------------------- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/Runtime/Graphics/CLight.hpp b/Runtime/Graphics/CLight.hpp index f9d95c046..ef4101c6d 100644 --- a/Runtime/Graphics/CLight.hpp +++ b/Runtime/Graphics/CLight.hpp @@ -31,26 +31,32 @@ class CLight friend class CGameLight; zeus::CVector3f x0_pos; - zeus::CVector3f xc_dir; - zeus::CColor x18_color; - ELightType x1c_type; - float x20_spotCutoff; - float x24_distC; - float x28_distL; - float x2c_distQ; - float x30_angleC; - float x34_angleL; - float x38_angleQ; + zeus::CVector3f xc_dir = zeus::CVector3f::skDown; + zeus::CColor x18_color = zeus::CColor::skClear; + ELightType x1c_type = ELightType::Custom; + float x20_spotCutoff = 0.f; + float x24_distC = 1.f; + float x28_distL = 0.f; + float x2c_distQ = 0.f; + float x30_angleC = 1.f; + float x34_angleL = 0.f; + float x38_angleQ = 0.f; u32 x3c_priority = 0; u32 x40_lightId = 0; // Serves as unique key - float x44_cachedRadius; - float x48_cachedIntensity; + float x44_cachedRadius = 0.f; + float x48_cachedIntensity = 0.f; bool x4c_24_intensityDirty : 1; bool x4c_25_radiusDirty : 1; float CalculateLightRadius() const; public: + CLight() + { + x4c_24_intensityDirty = true; + x4c_25_radiusDirty = true; + } + CLight(const zeus::CVector3f& pos, const zeus::CVector3f& dir, const zeus::CColor& color, diff --git a/Runtime/World/CFluidPlaneCPU.cpp b/Runtime/World/CFluidPlaneCPU.cpp index 6173eac55..5f14d305f 100644 --- a/Runtime/World/CFluidPlaneCPU.cpp +++ b/Runtime/World/CFluidPlaneCPU.cpp @@ -132,38 +132,14 @@ CFluidPlaneCPU::RenderSetup(const CStateManager& mgr, float alpha, const zeus::C // Build 50% grey directional light with xf0_bumpLightDir and load into LIGHT_3 // Light 3 in channel 1 // Vertex colors in channel 0 + out.lights.resize(4); + out.lights[3] = CLight::BuildDirectional(xf0_bumpLightDir, zeus::CColor::skGrey); } else { // Normal light mask in channel 1 // Vertex colors in channel 0 - } - - if (x10_texPattern1) - { - // Load into 0 - } - else - { - // Load black tex into 0 - } - - if (x20_texPattern2) - { - // Load into 1 - } - else - { - // Load black tex into 1 - } - - if (x30_texColor) - { - // Load into 2 - } - else - { - // Load black tex into 2 + out.lights = water->GetActorLights()->BuildLightVector(); } int curTex = 3; @@ -298,7 +274,6 @@ CFluidPlaneCPU::RenderSetup(const CStateManager& mgr, float alpha, const zeus::C m_shader.emplace(x44_fluidType, x10_texPattern1, x20_texPattern2, x30_texColor, xb0_bumpMap, xc0_envMap, xd0_envBumpMap, xe0_lightmap, doubleLightmapBlend, mgr.GetParticleFlags() == 0); - out.lights = water->GetActorLights()->BuildLightVector(); return out; }