From 5e6f2220e82360ae95dc304089cbc5d5aeb1f1e1 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 6 Aug 2016 17:31:39 -0600 Subject: [PATCH] light: quick hack fix of spotlights in bounce mode --- light/ltface.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/light/ltface.cc b/light/ltface.cc index 300c0fbb..47277696 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1321,6 +1321,20 @@ GetDirectLighting(raystream_t *rs, const vec3_t origin, const vec3_t normal, vec // apply anglescale cosangle = (1.0 - entity.anglescale.floatValue()) + entity.anglescale.floatValue() * cosangle; + /* Check spotlight cone */ + float spotscale = 1; + if (entity.spotlight) { + vec_t falloff = DotProduct(entity.spotvec, originLightDir); + if (falloff > entity.spotfalloff) + continue; + if (falloff > entity.spotfalloff2) { + /* Interpolate between the two spotlight falloffs */ + spotscale = falloff - entity.spotfalloff2; + spotscale /= entity.spotfalloff - entity.spotfalloff2; + spotscale = 1.0 - spotscale; + } + } + vec_t lightval = GetLightValue(&entity, dist); if (lightval < 0.25) continue; @@ -1328,7 +1342,7 @@ GetDirectLighting(raystream_t *rs, const vec3_t origin, const vec3_t normal, vec if (!TestLight(*entity.origin.vec3Value(), origin, NULL)) continue; - VectorMA(colorout, lightval * cosangle / 255.0f, *entity.color.vec3Value(), colorout); + VectorMA(colorout, lightval * cosangle * spotscale / 255.0f, *entity.color.vec3Value(), colorout); } for (const sun_t &sun : GetSuns())