remove fastbounce, add emissivequality

emissivequality affects both emissives
This commit is contained in:
Jonathan 2023-06-19 09:54:25 -04:00
parent aeece2a730
commit 08db6e9bf9
7 changed files with 43 additions and 22 deletions

View File

@ -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;
}

View File

@ -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
---------------------

View File

@ -319,7 +319,7 @@ template<typename T>
class setting_enum : public setting_value<T>
{
private:
std::map<std::string, T, natural_less> _values;
std::map<std::string, T, natural_case_insensitive_less> _values;
public:
inline setting_enum(setting_container *dictionary, const nameset &names, T v,

View File

@ -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_t> emissivequality;
setting_enum<visapprox_t> visapprox;
setting_func lit;
setting_func lit2;

View File

@ -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<qvec3f> points{facemidpoint};
for (auto &style : emitcolors) {

View File

@ -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}},

View File

@ -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;