From 1045505670e5c6a27b80b9de4c11cab6013dfb41 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 19 Sep 2016 12:15:26 -0600 Subject: [PATCH] light: avoid bouncing negative lights --- light/light.cc | 4 +++- light/ltface.cc | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/light/light.cc b/light/light.cc index bd860fdd..b64acdea 100644 --- a/light/light.cc +++ b/light/light.cc @@ -914,7 +914,9 @@ MakeBounceLightsThread (void *arg) static void AddBounceLight(const vec3_t pos, const vec3_t color, const vec3_t surfnormal, vec_t area, const bsp2_t *bsp) { - Q_assert(!isnan(color[0])); + Q_assert(color[0] >= 0); + Q_assert(color[1] >= 0); + Q_assert(color[2] >= 0); Q_assert(area > 0); bouncelight_t l = {0}; diff --git a/light/ltface.cc b/light/ltface.cc index 8967ea64..2fb92f0e 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1250,7 +1250,8 @@ GetDirectLighting(const globalconfig_t &cfg, raystream_t *rs, const vec3_t origi const float dirt = Dirt_GetScaleFactor(cfg, occlusion, &entity, /* FIXME: pass */ nullptr); VectorScale(color, dirt, color); - if (fabs(LightSample_Brightness(color)) <= fadegate) { + // NOTE: Skip negative lights, which would make no sense to bounce! + if (LightSample_Brightness(color) <= fadegate) { continue; } @@ -1262,6 +1263,11 @@ GetDirectLighting(const globalconfig_t &cfg, raystream_t *rs, const vec3_t origi } for (const sun_t &sun : GetSuns()) { + + // NOTE: Skip negative lights, which would make no sense to bounce! + if (sun.sunlight < 0) + continue; + vec3_t originLightDir; VectorCopy(sun.sunvec, originLightDir); VectorNormalize(originLightDir);