light: bounce: handle 0 dist between bounce light and surface point
This commit is contained in:
parent
f446ba1ddf
commit
d3b6adb955
|
|
@ -1563,7 +1563,7 @@ BounceLight_ColorAtDist(const bouncelight_t *vpl, vec_t dist, vec3_t color)
|
|||
|
||||
// returns color in [0,255]
|
||||
void
|
||||
GetIndirectLighting (const bsp2_t *bsp, const bouncelight_t *vpl, const bsp2_dface_t *face, const byte *pvs, const vec3_t origin, const vec3_t normal, vec3_t color)
|
||||
GetIndirectLighting (const bouncelight_t *vpl, const vec3_t origin, const vec3_t normal, vec3_t color)
|
||||
{
|
||||
VectorSet(color, 0, 0, 0);
|
||||
|
||||
|
|
@ -1571,22 +1571,27 @@ GetIndirectLighting (const bsp2_t *bsp, const bouncelight_t *vpl, const bsp2_dfa
|
|||
VectorSubtract(origin, vpl->pos, dir); // vpl -> sample point
|
||||
vec_t dist = VectorNormalize(dir);
|
||||
|
||||
const vec_t dp1 = DotProduct(vpl->surfnormal, dir);
|
||||
if (dp1 < 0)
|
||||
return; // sample point behind vpl
|
||||
|
||||
vec3_t sp_vpl;
|
||||
VectorScale(dir, -1, sp_vpl);
|
||||
|
||||
const vec_t dp2 = DotProduct(sp_vpl, normal);
|
||||
if (dp2 < 0)
|
||||
return; // vpl behind sample face
|
||||
vec_t anglescale = 1;
|
||||
if (dist != 0) {
|
||||
const vec_t dp1 = DotProduct(vpl->surfnormal, dir);
|
||||
if (dp1 < 0)
|
||||
return; // sample point behind vpl
|
||||
|
||||
vec3_t sp_vpl;
|
||||
VectorScale(dir, -1, sp_vpl);
|
||||
|
||||
const vec_t dp2 = DotProduct(sp_vpl, normal);
|
||||
if (dp2 < 0)
|
||||
return; // vpl behind sample face
|
||||
|
||||
anglescale = dp1 * dp2;
|
||||
}
|
||||
|
||||
// get light contribution
|
||||
BounceLight_ColorAtDist(vpl, dist, color);
|
||||
|
||||
// apply angle scale
|
||||
VectorScale(color, dp1 * dp2, color);
|
||||
VectorScale(color, anglescale, color);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -1600,8 +1605,6 @@ BounceLight_SphereCull(const bsp2_t *bsp, const bouncelight_t *vpl, const lights
|
|||
vec_t dist = VectorNormalize(dir) + lightsurf->radius;
|
||||
|
||||
// get light contribution
|
||||
|
||||
VectorScale(vpl->color, vpl->area, color);
|
||||
BounceLight_ColorAtDist(vpl, dist, color);
|
||||
|
||||
if (((color[0] + color[1] + color[2]) / 3) < 0.25)
|
||||
|
|
@ -1633,7 +1636,7 @@ LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t
|
|||
|
||||
for (int i = 0; i < lightsurf->numpoints; i++) {
|
||||
vec3_t indirect = {0};
|
||||
GetIndirectLighting(bsp, vpl, face, lightsurf->pvs, lightsurf->points[i], lightsurf->normals[i], indirect);
|
||||
GetIndirectLighting(vpl, lightsurf->points[i], lightsurf->normals[i], indirect);
|
||||
|
||||
if (((indirect[0] + indirect[1] + indirect[2]) / 3) < 0.25)
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Reference in New Issue