From b8070e01412497984cb0e255cbd567c4191c6224 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 31 May 2022 12:56:59 +0900 Subject: [PATCH] [vulkan] Check for ambient lights Ambient lights are represented by a point at infinity and a zero direction vector (spherical lights have a non-zero direction vector but the cone angle is 360 degrees). This fixes what appeared to be mangled light renderers (it was actually just an ambient light being treated as a directional light (point at infinity, but non-zero direction vector). --- libs/video/renderer/vulkan/vulkan_lighting.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index 6696e5db8..09145ae25 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -702,10 +702,12 @@ build_shadow_maps (lightingctx_t *lctx, vulkan_ctx_t *ctx) int layers = 1; int li = lightMap[i]; __auto_type lr = &lctx->light_renderers.a[li]; + *lr = (light_renderer_t) {}; - lr->mode = ST_NONE; if (!lights[li].position[3]) { - lr->mode = ST_CASCADE; + if (!VectorIsZero (lights[li].direction)) { + lr->mode = ST_CASCADE; + } } else { if (lights[li].direction[3] > -0.5) { lr->mode = ST_CUBE; @@ -791,7 +793,6 @@ build_shadow_maps (lightingctx_t *lctx, vulkan_ctx_t *ctx) __auto_type lr = &lctx->light_renderers.a[li]; if (imageMap[li] == -1) { - *lr = (light_renderer_t) {}; continue; }