diff --git a/include/light/light.hh b/include/light/light.hh index 9a05ccc9..b7897b39 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -443,6 +443,7 @@ public: setting_bool nolights{this, "nolights", false, &output_group, "ignore light entities (only sunlight/minlight)"}; setting_int32 facestyles{this, "facestyles", 4, &output_group, "max amount of styles per face; requires BSPX lump if > 4"}; setting_bool exportobj{this, "exportobj", false, &output_group, "export an .OBJ for inspection"}; + setting_int32 lmshift{this, "lmshift", 4, &output_group, "force a specified lmshift to be applied to the entire map; this is useful if you want to re-light a map with higher quality BSPX lighting without the sources. Will add the LMSHIFT lump to the BSP."}; inline void CheckNoDebugModeSet() { diff --git a/light/bounce.cc b/light/bounce.cc index 3bfda5c5..03ae60ca 100644 --- a/light/bounce.cc +++ b/light/bounce.cc @@ -169,7 +169,9 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m return; } - const vec_t sample_scalar = 1.f / sqrt(area) / (options.extra.value() * options.extra.value()) * (surf.lightmapscale / 16.0); + const vec_t sample_divisor = sqrt(area); + const vec_t extra_divisor = (options.extra.value() * options.extra.value()); + const vec_t lmscale_divisor = (16.0 / surf.lightmapscale); qplane3d faceplane = winding.plane(); @@ -188,7 +190,9 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m qvec3d total = {}; for (auto &styleColor : sum) { - styleColor.second *= sample_scalar; + styleColor.second /= sample_divisor; + styleColor.second /= extra_divisor; + styleColor.second /= lmscale_divisor; styleColor.second *= cfg.bouncescale.value(); total += styleColor.second; } diff --git a/light/light.cc b/light/light.cc index 588d01ac..2bbbbcf7 100644 --- a/light/light.cc +++ b/light/light.cc @@ -527,6 +527,17 @@ static void LightWorld(bspdata_t *bspdata, bool forcedscale) if (forcedscale) { bspdata->bspx.entries.erase("LMSHIFT"); + } else if (options.lmshift.isChanged()) { + // if we forcefully specified an lmshift lump, we have to generate one. + bspdata->bspx.entries.erase("LMSHIFT"); + + std::vector shifts(bsp.dfaces.size()); + + for (auto &shift : shifts) { + shift = options.lmshift.value(); + } + + bspdata->bspx.transfer("LMSHIFT", shifts); } auto lmshift_lump = bspdata->bspx.entries.find("LMSHIFT");