diff --git a/include/light/light.hh b/include/light/light.hh index 1d5b9d87..5c508314 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -417,6 +417,7 @@ public: this, {"extra", "extra4"}, 1, &performance_group, "supersampling; 2x2 (extra) or 4x4 (extra4) respectively"}; setting_extra bounceextra{ this, {"bounceextra", "bounceextra4"}, 1, &performance_group, "bounce light supersampling; 2x2 (bounceextra) or 4x4 (bounceextra4) respectively"}; + setting_bool fastbounce{this, "fastbounce", false, &performance_group, "use one bounce point in the middle of each face. for fast compilation."}; setting_enum visapprox{this, "visapprox", visapprox_t::AUTO, {{"auto", visapprox_t::AUTO}, {"none", visapprox_t::NONE}, {"vis", visapprox_t::VIS}, {"rays", visapprox_t::RAYS}}, diff --git a/light/bounce.cc b/light/bounce.cc index 1fef82fe..c202ce75 100644 --- a/light/bounce.cc +++ b/light/bounce.cc @@ -179,10 +179,10 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m const vec_t bounce_step = light_options.extra.value() / light_options.bounceextra.value(); // color divisor; // extra4 + (no bounce extra) = 16, since surf.points is 16x larger than vanilla - const vec_t bounce_divisor = bounce_step * bounce_step; + const vec_t bounce_divisor = light_options.fastbounce.value() ? 1 : (bounce_step * bounce_step); const vec_t area_divisor = sqrt(area); - const vec_t sample_divisor = (surf.points.size() / bounce_divisor) / (surf.vanilla_extents.width() * surf.vanilla_extents.height()); + const vec_t sample_divisor = (light_options.fastbounce.value() ? 1 : (surf.points.size() / bounce_divisor)) / (surf.vanilla_extents.width() * surf.vanilla_extents.height()); // average them, area weighted std::unordered_map sum; @@ -221,13 +221,19 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m qplane3d faceplane = winding.plane(); - area /= surf.points.size() / bounce_divisor; + if (!light_options.fastbounce.value()) { + area /= surf.points.size() / bounce_divisor; - for (vec_t x = 0; x < surf.width; x += bounce_step) { - for (vec_t y = 0; y < surf.height; y += bounce_step) { - auto &pt = surf.points[(y * surf.width) + x]; - AddBounceLight(pt, emitcolors, faceplane.normal, area, &face, bsp); + for (vec_t x = 0; x < surf.width; x += bounce_step) { + for (vec_t y = 0; y < surf.height; y += bounce_step) { + auto &pt = surf.points[(y * surf.width) + x]; + AddBounceLight(pt, emitcolors, faceplane.normal, area, &face, bsp); + } } + } else { + area /= surf.points.size(); + + AddBounceLight(surf.extents.origin, emitcolors, faceplane.normal, area, &face, bsp); } }