fix bounced lighting
This commit is contained in:
parent
b43e80911e
commit
0baa788d7e
|
|
@ -71,6 +71,14 @@ static bool Face_ShouldBounce(const mbsp_t *bsp, const mface_t *face)
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,7 +171,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vec_t sample_scalar = 1.f / area;
|
const vec_t sample_scalar = 1.f / sqrt(area);
|
||||||
|
|
||||||
qplane3d faceplane = winding.plane();
|
qplane3d faceplane = winding.plane();
|
||||||
|
|
||||||
|
|
@ -183,7 +191,6 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
|
||||||
|
|
||||||
for (auto &styleColor : sum) {
|
for (auto &styleColor : sum) {
|
||||||
styleColor.second *= sample_scalar;
|
styleColor.second *= sample_scalar;
|
||||||
styleColor.second /= 255.0f;
|
|
||||||
styleColor.second *= cfg.bouncescale.value();
|
styleColor.second *= cfg.bouncescale.value();
|
||||||
total += styleColor.second;
|
total += styleColor.second;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1841,18 +1841,13 @@ static void LightFace_BounceLightsDebug(const lightsurf_t *lightsurf, lightmapdi
|
||||||
|
|
||||||
// returns color in [0,255]
|
// returns color in [0,255]
|
||||||
inline qvec3f BounceLight_ColorAtDist(
|
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
|
const float d = max(dist, 128.f); // Clamp away hotspots, also avoid division by 0..
|
||||||
if (dist < 128.0f) {
|
const float scale = (1.0f / (d * d));
|
||||||
dist = 128.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float dist2 = (dist * dist);
|
|
||||||
const float scale = (1.0f / dist2);
|
|
||||||
|
|
||||||
// get light contribution
|
// get light contribution
|
||||||
return bounceLightColor * area * (255.0f * scale);
|
return color * area * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mxd. Surface light falloff. Returns color in [0,255]
|
// mxd. Surface light falloff. Returns color in [0,255]
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ static void MakeSurfaceLightsThread(const mbsp_t *bsp, const settings::worldspaw
|
||||||
return;
|
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
|
// check matching templates
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue