fix bounced lighting

This commit is contained in:
Jonathan 2022-07-02 16:59:04 -04:00
parent b43e80911e
commit 0baa788d7e
3 changed files with 14 additions and 12 deletions

View File

@ -71,6 +71,14 @@ static bool Face_ShouldBounce(const mbsp_t *bsp, const mface_t *face)
return false;
}
// don't bounce *from* emission surfaces
// FIXME: better way that works for Q1 too
if (bsp->loadversion->game->id == GAME_QUAKE_II) {
if (bsp->texinfo[face->texinfo].flags.native & Q2_SURF_LIGHT) {
return false;
}
}
return true;
}
@ -163,7 +171,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
return;
}
const vec_t sample_scalar = 1.f / area;
const vec_t sample_scalar = 1.f / sqrt(area);
qplane3d faceplane = winding.plane();
@ -183,7 +191,6 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
for (auto &styleColor : sum) {
styleColor.second *= sample_scalar;
styleColor.second /= 255.0f;
styleColor.second *= cfg.bouncescale.value();
total += styleColor.second;
}

View File

@ -1841,18 +1841,13 @@ static void LightFace_BounceLightsDebug(const lightsurf_t *lightsurf, lightmapdi
// returns color in [0,255]
inline qvec3f BounceLight_ColorAtDist(
const settings::worldspawn_keys &cfg, float area, const qvec3f &bounceLightColor, float dist)
const settings::worldspawn_keys &cfg, float area, const qvec3f &color, float dist)
{
// clamp away hotspots
if (dist < 128.0f) {
dist = 128.0f;
}
const float dist2 = (dist * dist);
const float scale = (1.0f / dist2);
const float d = max(dist, 128.f); // Clamp away hotspots, also avoid division by 0..
const float scale = (1.0f / (d * d));
// get light contribution
return bounceLightColor * area * (255.0f * scale);
return color * area * scale;
}
// mxd. Surface light falloff. Returns color in [0,255]

View File

@ -159,7 +159,7 @@ static void MakeSurfaceLightsThread(const mbsp_t *bsp, const settings::worldspaw
return;
}
MakeSurfaceLight(bsp, cfg, face, std::nullopt, false, (info->flags.native & Q2_SURF_SKY), 0, info->value);
MakeSurfaceLight(bsp, cfg, face, std::nullopt, false/*!(info->flags.native & Q2_SURF_SKY)*/, (info->flags.native & Q2_SURF_SKY), 0, info->value);
}
// check matching templates