SleakEngine 0.1.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
LightManager.cpp
Go to the documentation of this file.
1#include <Camera/Camera.hpp>
4#include <Core/Logger.hpp>
5#include <Core/SceneBase.hpp>
6#include <Core/Timer.hpp>
7#include <Core/Window.hpp>
14#include <Lighting/Light.hpp>
16#include <Math/Matrix.hpp>
17#include <cmath>
18#include <cstring>
19
20namespace {
21/// 4x4 row-major matrix inverse via cofactors (Cramer's rule).
22/// Returns false if matrix is singular.
23static bool Invert4x4(const float m[16], float inv[16]) {
24 float inv0 = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15] + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
25 float inv4 = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15] - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
26 float inv8 = m[4]*m[9] *m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15] + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
27 float inv12 = -m[4]*m[9] *m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14] - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
28
29 float det = m[0]*inv0 + m[1]*inv4 + m[2]*inv8 + m[3]*inv12;
30 if (std::fabs(det) < 1e-8f) return false;
31 float id = 1.0f / det;
32
33 inv[0] = inv0 * id;
34 inv[4] = inv4 * id;
35 inv[8] = inv8 * id;
36 inv[12] = inv12 * id;
37
38 inv[1] = (-m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15] - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10]) * id;
39 inv[5] = ( m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15] + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10]) * id;
40 inv[9] = (-m[0]*m[9] *m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15] - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9] ) * id;
41 inv[13] = ( m[0]*m[9] *m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14] + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9] ) * id;
42
43 inv[2] = ( m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15] + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6]) * id;
44 inv[6] = (-m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15] - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6]) * id;
45 inv[10] = ( m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15] + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5]) * id;
46 inv[14] = (-m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14] - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5]) * id;
47
48 inv[3] = (-m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11] - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6]) * id;
49 inv[7] = ( m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11] + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6]) * id;
50 inv[11] = (-m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11] - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5]) * id;
51 inv[15] = ( m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10] + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5]) * id;
52
53 return true;
54}
55} // namespace
56
57namespace Sleak {
58
60
62
64 if (!m_lightBuffer) {
69 nullptr));
70 m_lightBuffer->SetSlot(2);
71 }
72}
73
75 if (!light) return;
76 if (m_lights.indexOf(light) != -1) return;
77
78 if (m_lights.GetSize() >= RenderEngine::MAX_LIGHTS) {
80 "Maximum light count ({}) reached, cannot register "
81 "light '{}'",
82 RenderEngine::MAX_LIGHTS, light->GetName());
83 return;
84 }
85
86 m_lights.add(light);
87}
88
90 if (!light) return;
91 int index = m_lights.indexOf(light);
92 if (index != -1) {
93 m_lights.erase(index);
94 }
95}
96
98 if (!m_lightBuffer) return;
99
101
102 // Camera position
103 const auto& camPos = Camera::GetMainCameraPosition();
104 cbData.CameraPosX = camPos.GetX();
105 cbData.CameraPosY = camPos.GetY();
106 cbData.CameraPosZ = camPos.GetZ();
107
108 // Ambient
109 cbData.AmbientR = m_ambientR;
110 cbData.AmbientG = m_ambientG;
111 cbData.AmbientB = m_ambientB;
112 cbData.AmbientIntensity = m_ambientIntensity;
113
114 // Fog — horizon color + sky-zenith blend + exponential height fog.
115 // OpenGL deferred lighting reads its fog parameters from this LightCBData
116 // (binding 2). Vulkan/forward shaders read the same data from
117 // ShadowLightUBO. Keep both blocks in sync.
118 if (m_fogEnabled) {
119 cbData.FogColorR = m_fogR;
120 cbData.FogColorG = m_fogG;
121 cbData.FogColorB = m_fogB;
122 cbData.FogColorA = 1.0f;
123 cbData.FogStart = m_fogStart;
124 cbData.FogEnd = m_fogEnd;
125
126 cbData.FogColorZenith[0] = m_fogZenithR;
127 cbData.FogColorZenith[1] = m_fogZenithG;
128 cbData.FogColorZenith[2] = m_fogZenithB;
129 cbData.FogColorZenith[3] = 1.0f;
130
131 cbData.HeightFogTop = m_heightFogTop;
132 cbData.HeightFogDensity = m_heightFogDensity;
133 cbData.HeightFogFalloff = m_heightFogFalloff;
134 cbData.HeightFogEnabled = m_heightFogEnabled ? 1.0f : 0.0f;
135 } else {
136 cbData.FogStart = 0.0f;
137 cbData.FogEnd = 0.0f;
138 cbData.HeightFogEnabled = 0.0f;
139 }
140
141 // Collect active lights
142 uint32_t count = 0;
143 for (size_t i = 0;
144 i < m_lights.GetSize() && count < RenderEngine::MAX_LIGHTS;
145 ++i) {
146 Light* light = m_lights[i];
147 if (!light || !light->IsEnabled()) continue;
148
149 cbData.Lights[count] = light->BuildGPUData();
150 ++count;
151 }
152 cbData.NumActiveLights = count;
153
154 // Update and bind at slot 2
155 m_lightBuffer->Update(&cbData, sizeof(cbData));
156 m_lightBuffer->Update();
157
158 // Update shadow data for Vulkan renderer
160
161 // Update deferred CB (InvViewProj + screen size) for the lighting pass
163}
164
166 auto* app = Application::GetInstance();
167 if (!app) return;
168 auto* renderer = app->GetRenderer();
169 if (!renderer) return;
170
171 // Find first shadow-casting directional light
172 DirectionalLight* shadowLight = nullptr;
173 for (size_t i = 0; i < m_lights.GetSize(); ++i) {
174 Light* light = m_lights[i];
175 if (!light || !light->IsEnabled() || !light->GetCastShadows()) continue;
176
177 auto* dirLight = dynamic_cast<DirectionalLight*>(light);
178 if (dirLight) {
179 shadowLight = dirLight;
180 break;
181 }
182 }
183
184 // Find first enabled directional light (regardless of shadow casting)
185 // for populating light/ambient data in the UBO
186 DirectionalLight* anyDirLight = nullptr;
187 if (!shadowLight) {
188 for (size_t i = 0; i < m_lights.GetSize(); ++i) {
189 Light* light = m_lights[i];
190 if (!light || !light->IsEnabled()) continue;
191 auto* dirLight = dynamic_cast<DirectionalLight*>(light);
192 if (dirLight) {
193 anyDirLight = dirLight;
194 break;
195 }
196 }
197 }
198
199 // Tell the renderer whether the shadow pass should run
200 renderer->SetShadowPassEnabled(shadowLight != nullptr);
201
202 // Use shadow light if available, otherwise fall back to any directional light
203 DirectionalLight* activeLight = shadowLight ? shadowLight : anyDirLight;
204
205 if (!activeLight) {
206 m_hasShadowLightVP = false;
207 static bool warned = false;
208 if (!warned) { SLEAK_WARN("UpdateShadowData: No directional light found!"); warned = true; }
209 return;
210 }
211
212 auto dir = activeLight->GetDirection();
213 auto color = activeLight->GetColor();
214 float intensity = activeLight->GetIntensity();
215
217
218 if (shadowLight) {
219 // Compute light view-projection matrix from shadow configuration
220 float frustumSize = shadowLight->GetShadowFrustumSize();
221 float shadowDist = shadowLight->GetShadowDistance();
222 float nearP = shadowLight->GetShadowNearPlane();
223 float farP = shadowLight->GetShadowFarPlane();
224
225 // Light position: follow camera XZ but fix Y at world origin.
226 // Anchoring Y prevents the shadow frustum from shifting vertically
227 // when the player jumps/flies, which causes hard Z-plane cutoff flicker.
228 const auto& camPos = Camera::GetMainCameraPosition();
229 Math::Vector3D lightPos = Math::Vector3D(camPos.GetX(), 0.0f, camPos.GetZ())
230 + dir * (-shadowDist);
231
232 // Convert to Vector<float,3> for Matrix methods
233 Math::Vector<float, 3> lp({lightPos.GetX(), lightPos.GetY(), lightPos.GetZ()});
234 Math::Vector<float, 3> ld({dir.GetX(), dir.GetY(), dir.GetZ()});
235
236 // Avoid degenerate LookTo when light direction is nearly vertical
237 // (cross product with (0,1,0) would be zero → NaN matrix)
238 Math::Vector<float, 3> up = (fabsf(dir.GetY()) > 0.999f)
239 ? Math::Vector<float, 3>({0.0f, 0.0f, 1.0f})
240 : Math::Vector<float, 3>({0.0f, 1.0f, 0.0f});
241
242 Math::Matrix4 lightView = Math::Matrix4::LookTo(lp, ld, up);
243
244 // Build Vulkan-compatible orthographic projection (LH, [0,1] depth range)
245 // Engine stores row-major, GLSL reads column-major (transposed) —
246 // translations go in ROW 3 so they end up in GLSL column 3.
247 float left = -frustumSize, right = frustumSize;
248 float bottom = -frustumSize, top = frustumSize;
250 lightProj(0, 0) = 2.0f / (right - left);
251 lightProj(1, 1) = 2.0f / (top - bottom);
252 lightProj(2, 2) = 1.0f / (farP - nearP);
253 lightProj(3, 0) = -(right + left) / (right - left);
254 lightProj(3, 1) = -(top + bottom) / (top - bottom);
255 lightProj(3, 2) = -nearP / (farP - nearP);
256
257 // ---- Texel snap (DirectX SDK standard technique) ----
258 // Project world origin through the raw lightVP, measure its XY in
259 // shadow-map texel space, snap to nearest texel, apply the delta
260 // back to the projection matrix. This guarantees the sampling grid
261 // is aligned to world-space texel cells so sub-texel camera motion
262 // never shifts which texel a world point lands on → no shimmer.
263 //
264 // Using round() (not floor) — floor flips by a full texel when
265 // the fractional part crosses 0 due to float noise.
266 const float shadowMapSize =
267 static_cast<float>(renderer->GetShadowMapResolution());
268 const float halfShadow = shadowMapSize * 0.5f;
269
270 Math::Matrix4 lightVP_raw = lightView * lightProj;
271 // Anchor the snap on the WORLD ORIGIN (fixed point). The camera is a
272 // constant offset from the light frustum (lightPos follows camXZ), so
273 // projecting the camera yields the SAME texel coords every frame —
274 // constant delta, snap no-ops, world texels crawl while moving. The
275 // origin's projected texel position drifts as the frustum follows the
276 // camera; rounding it quantizes frustum motion to whole texels.
277 // Row-vector convention: (0,0,0,1) * M = row 3.
278 float clipX = lightVP_raw(3, 0);
279 float clipY = lightVP_raw(3, 1);
280 float clipW = lightVP_raw(3, 3);
281 if (clipW != 0.0f) {
282 float ndcX = clipX / clipW;
283 float ndcY = clipY / clipW;
284 float texX = ndcX * halfShadow;
285 float texY = ndcY * halfShadow;
286 float roundedX = std::round(texX);
287 float roundedY = std::round(texY);
288 float offsetNdcX = (roundedX - texX) / halfShadow;
289 float offsetNdcY = (roundedY - texY) / halfShadow;
290 lightProj(3, 0) += offsetNdcX;
291 lightProj(3, 1) += offsetNdcY;
292 }
293
294 // LightVP = View * Projection (row-major convention)
295 lightVP = lightView * lightProj;
296 }
297
298 // DIAG --shadowfreeze: latch the first lightVP forever. If shadows still
299 // shimmer with a frozen frustum, the cause is screen-space, not the
300 // frustum-follow chain.
301 {
302 static const bool s_freeze = CommandLine::HasFlag("--shadowfreeze");
303 static bool s_latched = false;
304 static float s_frozenVP[16];
305 if (s_freeze && shadowLight) {
306 if (!s_latched) {
307 std::memcpy(s_frozenVP, &lightVP(0, 0), sizeof(s_frozenVP));
308 s_latched = true;
309 SLEAK_WARN("shadowfreeze: light frustum latched");
310 } else {
311 std::memcpy(&lightVP(0, 0), s_frozenVP, sizeof(s_frozenVP));
312 }
313 }
314 }
315
316 // Set the light VP matrix on the renderer
317 renderer->SetLightVP(&lightVP(0, 0));
318 std::memcpy(m_shadowLightVP, &lightVP(0, 0), sizeof(m_shadowLightVP));
319 m_hasShadowLightVP = shadowLight != nullptr;
320
321 // Build shadow light UBO
322 const auto& camPos = Camera::GetMainCameraPosition();
324
325 ubo.LightDir[0] = dir.GetX();
326 ubo.LightDir[1] = dir.GetY();
327 ubo.LightDir[2] = dir.GetZ();
328 ubo.LightDir[3] = shadowLight ? shadowLight->GetShadowNormalBias() : 0.0f;
329
330 ubo.LightColor[0] = color.GetX();
331 ubo.LightColor[1] = color.GetY();
332 ubo.LightColor[2] = color.GetZ();
333 ubo.LightColor[3] = intensity;
334
335 ubo.Ambient[0] = m_ambientR;
336 ubo.Ambient[1] = m_ambientG;
337 ubo.Ambient[2] = m_ambientB;
338 ubo.Ambient[3] = m_ambientIntensity;
339
340 // CameraPos.w carries a monotonic scene clock, consumed by shaders that
341 // need animation time (e.g. water waves on the Vulkan backend — the engine
342 // has no MaterialUBO slot in its Vulkan pipeline layout, so there is
343 // nowhere else to stash time). Using a static Timer keeps this
344 // self-contained and independent of Application state.
345 static Sleak::Timer s_sceneClock;
346 static const bool s_fixedStep = !CommandLine::GetValue("-capture").empty();
347 static uint64_t s_sceneFrames = 0;
348 ubo.CameraPos[0] = camPos.GetX();
349 ubo.CameraPos[1] = camPos.GetY();
350 ubo.CameraPos[2] = camPos.GetZ();
351 // Capture: frame-driven clock
352 ubo.CameraPos[3] = s_fixedStep ? static_cast<float>(s_sceneFrames++) / 60.0f
353 : s_sceneClock.Elapsed();
354
355 // CURRENT lightVP — renderers stage SetLightVP and commit at BeginRender,
356 // so this frame's shadow map IS rendered with this matrix. The old
357 // prev-frame copy lagged sampling one frame behind the map (shadow shake
358 // while the camera moved).
359 std::memcpy(ubo.LightVP, &lightVP(0, 0), sizeof(float) * 16);
360
361 // NdcToShadow = InvViewProj * LightVP composed once on CPU so shadow
362 // coords never round-trip through reconstructed world position (that
363 // per-fragment path shimmers under camera rotation). Uses the same
364 // LightVP the UBO carries (prev frame — matches the bound shadow map).
365 {
368 Math::Matrix4 camVP = camV * camP;
369 float invVP[16];
370 if (Invert4x4(&camVP(0, 0), invVP)) {
371 Math::Matrix4 invVPm, lightVPm;
372 std::memcpy(&invVPm(0, 0), invVP, sizeof(float) * 16);
373 std::memcpy(&lightVPm(0, 0), ubo.LightVP, sizeof(float) * 16);
374 Math::Matrix4 comp = invVPm * lightVPm;
375 std::memcpy(ubo.NdcToShadow, &comp(0, 0), sizeof(float) * 16);
376 } else {
377 std::memcpy(ubo.NdcToShadow, ubo.LightVP, sizeof(float) * 16);
378 }
379 }
380
381 ubo.ShadowBias = shadowLight ? shadowLight->GetShadowBias() : 0.0f;
382 ubo.ShadowStrength = shadowLight ? shadowLight->GetShadowStrength() : 0.0f;
383 ubo.ShadowTexelSize =
384 1.0f / static_cast<float>(renderer->GetShadowMapResolution());
385 ubo.LightSize = shadowLight ? shadowLight->GetLightSize() : 0.0f;
386
387 // Fog — distance gradient (horizon + zenith) and exponential height fog
388 if (m_fogEnabled) {
389 ubo.FogColor[0] = m_fogR;
390 ubo.FogColor[1] = m_fogG;
391 ubo.FogColor[2] = m_fogB;
392 ubo.FogColor[3] = 1.0f;
393 ubo.FogStart = m_fogStart;
394 ubo.FogEnd = m_fogEnd;
395
396 ubo.FogColorZenith[0] = m_fogZenithR;
397 ubo.FogColorZenith[1] = m_fogZenithG;
398 ubo.FogColorZenith[2] = m_fogZenithB;
399 ubo.FogColorZenith[3] = 1.0f;
400
401 ubo.HeightFogTop = m_heightFogTop;
402 ubo.HeightFogDensity = m_heightFogDensity;
403 ubo.HeightFogFalloff = m_heightFogFalloff;
404 ubo.HeightFogEnabled = m_heightFogEnabled ? 1.0f : 0.0f;
405 } else {
406 ubo.FogStart = 0.0f;
407 ubo.FogEnd = 0.0f;
408 ubo.HeightFogEnabled = 0.0f;
409 }
410
411 // Populate extra lights (fill, rim — non-shadow directional lights)
412 ubo.NumExtraLights = 0;
413 for (size_t i = 0; i < m_lights.GetSize() && ubo.NumExtraLights < 3; ++i) {
414 Light* light = m_lights[i];
415 if (!light || !light->IsEnabled()) continue;
416 if (light == activeLight) continue; // already in primary slot
417 auto* dlight = dynamic_cast<DirectionalLight*>(light);
418 if (!dlight) continue;
419 auto eDir = dlight->GetDirection();
420 auto eColor = dlight->GetColor();
421 uint32_t idx = ubo.NumExtraLights;
422 ubo.ExtraLightDir[idx][0] = eDir.GetX();
423 ubo.ExtraLightDir[idx][1] = eDir.GetY();
424 ubo.ExtraLightDir[idx][2] = eDir.GetZ();
425 ubo.ExtraLightDir[idx][3] = 0.0f;
426 ubo.ExtraLightColor[idx][0] = eColor.GetX();
427 ubo.ExtraLightColor[idx][1] = eColor.GetY();
428 ubo.ExtraLightColor[idx][2] = eColor.GetZ();
429 ubo.ExtraLightColor[idx][3] = dlight->GetIntensity();
430 ++ubo.NumExtraLights;
431 }
432
433 renderer->UpdateShadowLightUBO(&ubo, sizeof(ubo));
434}
435
436void LightManager::SetAmbientColor(float r, float g, float b) {
437 m_ambientR = r;
438 m_ambientG = g;
439 m_ambientB = b;
440}
441
443 auto* app = Application::GetInstance();
444 if (!app) return;
445 auto* renderer = app->GetRenderer();
446 if (!renderer) return;
447 auto* ctx = renderer->GetContext();
448 if (!ctx || !ctx->IsDeferredEnabled()) return;
449
450 // ViewProj = View * Proj (row-major engine convention)
453 Math::Matrix4 VP = V * P;
454
456 if (!Invert4x4(&VP(0, 0), cb.InvViewProj)) {
457 // Singular matrix — skip update (can happen during initialization)
458 return;
459 }
460
461 // Screen size from Window static state
462 cb.ScreenWidth = static_cast<float>(app->GetWindow().GetWidth());
463 cb.ScreenHeight = static_cast<float>(app->GetWindow().GetHeight());
464 cb.NearPlane = 0.1f;
465 cb.FarPlane = 2000.0f;
466 if (auto* game = app->GetGame(); game && game->GetActiveScene()) {
467 if (auto* cam = game->GetActiveScene()->GetActiveCamera()) {
468 cb.NearPlane = cam->GetNearPlane();
469 cb.FarPlane = cam->GetFarPlane();
470 }
471 }
472
473 ctx->UpdateDeferredCB(&cb, sizeof(cb));
474}
475
476} // namespace Sleak
#define SLEAK_WARN(...)
Definition Logger.hpp:21
static Application * GetInstance()
The one Application for this process, or null before construction.
static const Math::Matrix4 & GetMainProjectionMatrix()
Definition Camera.hpp:107
static const Math::Vector3D & GetMainCameraPosition()
Definition Camera.hpp:111
static const Math::Matrix4 & GetMainViewMatrix()
Definition Camera.hpp:103
static std::string GetValue(const std::string &flag, const std::string &defaultVal="")
Returns the raw string value stored for -flag, or defaultVal if it was not passed.
static bool HasFlag(const std::string &flag)
True if --flag was present on the command line.
Math::Vector3D GetDirection() const
void SetAmbientColor(float r, float g, float b)
void RegisterLight(Light *light)
void UpdateDeferredCB()
Refreshes the deferred-pass constant buffer (fog, ambient) independent of the per-light data.
void Initialize()
Allocates the GPU light buffer; call once before the first UpdateAndBind.
void UpdateShadowData()
Picks the active shadow-casting light and refreshes its shadow-space matrices.
void UpdateAndBind()
Packs every registered light and the fog/ambient parameters into the light buffer and binds it.
void UnregisterLight(Light *light)
virtual RenderEngine::LightGPUEntry BuildGPUData() const =0
Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
bool GetCastShadows() const
Definition Light.hpp:40
bool IsEnabled() const
Definition Light.hpp:37
float GetIntensity() const
Definition Light.hpp:34
float GetShadowStrength() const
Definition Light.hpp:48
Math::Vector3D GetColor() const
Definition Light.hpp:29
float GetShadowBias() const
Definition Light.hpp:43
float GetShadowNormalBias() const
Definition Light.hpp:51
float GetLightSize() const
Definition Light.hpp:54
static Matrix< float, Rows, Rows > Identity()
Definition Matrix.hpp:194
static Matrix< float, 4, 4 > LookTo(const Vector< float, 3 > &eye, const Vector< float, 3 > &direction, const Vector< float, 3 > &up)
Definition Matrix.hpp:306
float GetY() const
Definition Vector.hpp:362
float GetX() const
Definition Vector.hpp:361
float GetZ() const
Definition Vector.hpp:363
const std::string & GetName() const
Definition Object.hpp:22
static BufferBase * CreateBuffer(BufferType Type, uint32_t Size, void *Data)
Creates a buffer via the currently registered backend factory.
float Elapsed() const
Seconds since construction or the last Reset().
Definition Timer.cpp:13
Matrix< float, 4, 4 > Matrix4
Definition Matrix.hpp:404
Root namespace for everything the engine exposes.
Definition Camera.hpp:10
Per-frame deferred lighting pass CB: inverse view-projection plus screen/near-far metrics.
Full per-frame lighting UBO: camera, ambient, fog, and the packed light array.
LightGPUEntry Lights[MAX_LIGHTS]
Shadow-pass UBO: light/shadow parameters, fog, and extra fill lights (set 2, binding 0).