From 08db6e9bf927fd5a18f6a34ff5de36b982f8a175 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 19 Jun 2023 09:54:25 -0400 Subject: [PATCH] remove fastbounce, add emissivequality emissivequality affects both emissives --- common/bspfile.cc | 7 ++++++- docs/light.rst | 12 ++++++++---- include/common/settings.hh | 2 +- include/light/light.hh | 8 +++++++- light/bounce.cc | 2 +- light/light.cc | 4 ++-- light/surflight.cc | 30 ++++++++++++++++++------------ 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/common/bspfile.cc b/common/bspfile.cc index 425d7f2e..28641cec 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -977,7 +977,12 @@ struct gamedef_q2_t : public gamedef_t } bool surf_is_lightmapped(const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const override - { // Q2RTX should light nodraw faces + { + /* don't save lightmaps for "trigger" texture even if light_nodraw is set */ + if (std::string_view(texname).ends_with("/trigger")) + return false; + + // Q2RTX should light nodraw faces if (light_nodraw && (flags.native & Q2_SURF_NODRAW)) { return true; } diff --git a/docs/light.rst b/docs/light.rst index 5e35a9b0..8f75f608 100644 --- a/docs/light.rst +++ b/docs/light.rst @@ -138,13 +138,17 @@ Performance .. option:: -surflight_subdivide [n] - Configure spacing of all surface lights. Default 128 units. Minimum - setting: 64 / max 2048. In the future I'd like to make this + Configure spacing of all surface lights. Default 16 units. Value must be between 1 + and 8192. In the future I'd like to make this configurable per-surface-light. -.. option:: -fastbounce +.. option:: -emissivequality low | high - Use one bounce point in the middle of each face. For fast compilation. + For emissive surfaces (both direct light and bounced light), use a single + point in the middle of the face (low) or subdivide the face into multiple + points, which provides anti-aliased results and more shadows, at the cost + of compile time. When using "high", you can use `surflight_subdivide` + to control the point spacing for better anti-aliasing. Default is low. Output format options --------------------- diff --git a/include/common/settings.hh b/include/common/settings.hh index 245d1e6d..243f728f 100644 --- a/include/common/settings.hh +++ b/include/common/settings.hh @@ -319,7 +319,7 @@ template class setting_enum : public setting_value { private: - std::map _values; + std::map _values; public: inline setting_enum(setting_container *dictionary, const nameset &names, T v, diff --git a/include/light/light.hh b/include/light/light.hh index dd66d570..c8e6ef1e 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -250,6 +250,12 @@ enum class visapprox_t RAYS }; +enum class emissivequality_t +{ + LOW, + HIGH +}; + enum class lightgrid_format_t { OCTREE @@ -386,7 +392,7 @@ public: setting_set radlights; setting_int32 lightmap_scale; setting_extra extra; - setting_bool fastbounce; + setting_enum emissivequality; setting_enum visapprox; setting_func lit; setting_func lit2; diff --git a/light/bounce.cc b/light/bounce.cc index e3bcdde5..651381c3 100644 --- a/light/bounce.cc +++ b/light/bounce.cc @@ -223,7 +223,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m qvec3d facenormal = faceplane.normal; qvec3d facemidpoint = winding.center() + facenormal; // Lift 1 unit - if (light_options.fastbounce.value()) { + if (light_options.emissivequality.value() == emissivequality_t::LOW) { vector points{facemidpoint}; for (auto &style : emitcolors) { diff --git a/light/light.cc b/light/light.cc index 308619b1..302f92d8 100644 --- a/light/light.cc +++ b/light/light.cc @@ -300,8 +300,8 @@ light_settings::light_settings() this, "lightmap_scale", 0, &experimental_group, "force change lightmap scale; vanilla engines only allow 16"}, extra{ this, {"extra", "extra4"}, 1, &performance_group, "supersampling; 2x2 (extra) or 4x4 (extra4) respectively"}, - fastbounce{this, "fastbounce", false, &performance_group, - "use one bounce point in the middle of each face. for fast compilation."}, + emissivequality{this, "emissivequality", emissivequality_t::LOW, { { "LOW", emissivequality_t::LOW }, { "HIGH", emissivequality_t::HIGH } }, &performance_group, + "low = one point in the center of the face, high = spread points out for antialiasing"}, 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/surflight.cc b/light/surflight.cc index 7ff8bea0..a35de87f 100644 --- a/light/surflight.cc +++ b/light/surflight.cc @@ -123,21 +123,27 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys // Dice winding... l->points_before_culling = 0; - winding.dice(cfg.surflightsubdivision.value(), [&](winding_t &w) { - ++l->points_before_culling; + if (light_options.emissivequality.value() == emissivequality_t::LOW) { + l->points = { l->pos }; + l->points_before_culling++; + total_surflight_points++; + } else { + winding.dice(cfg.surflightsubdivision.value(), [&](winding_t &w) { + ++l->points_before_culling; - qvec3f point = w.center() + l->surfnormal; + qvec3f point = w.center() + l->surfnormal; - // optimization - cull surface lights in the void - // also try to move them if they're slightly inside a wall - auto [fixed_point, success] = FixLightOnFace(bsp, point, false, 0.5f); - if (!success) { - return; - } + // optimization - cull surface lights in the void + // also try to move them if they're slightly inside a wall + auto [fixed_point, success] = FixLightOnFace(bsp, point, false, 0.5f); + if (!success) { + return; + } - l->points.push_back(fixed_point); - ++total_surflight_points; - }); + l->points.push_back(fixed_point); + ++total_surflight_points; + }); + } l->minlight_scale = extended_flags.surflight_minlight_scale;