[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).
This commit is contained in:
Bill Currie 2022-05-31 12:56:59 +09:00
parent 8e7474f614
commit b8070e0141

View file

@ -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]) {
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;
}