From 0a8a25b95cae727dfb534386615392a7833abd07 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 30 Sep 2017 20:07:27 -0600 Subject: [PATCH] Revert "light: for curved surfaces, don't reject hits when the dot product of the surface point normal and surface-point-to-light vector is < 0, since "anglescale" will typically boost the angle factor to 0.5" This reverts commit 26c5f65f4eb97ba5730443002196ec0a4aed8941. --- light/ltface.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/light/ltface.cc b/light/ltface.cc index bf15fb6c..b7b92e50 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -912,7 +912,7 @@ GetLightValue(const globalconfig_t &cfg, const light_t *entity, vec_t dist) } float -GetLightValueWithAngle(const globalconfig_t &cfg, const light_t *entity, const vec3_t surfnorm, const vec3_t surfpointToLightDir, float dist, bool twosided, bool curved) +GetLightValueWithAngle(const globalconfig_t &cfg, const light_t *entity, const vec3_t surfnorm, const vec3_t surfpointToLightDir, float dist, bool twosided) { float angle = DotProduct(surfpointToLightDir, surfnorm); if (entity->bleed.boolValue() || twosided) { @@ -921,21 +921,12 @@ GetLightValueWithAngle(const globalconfig_t &cfg, const light_t *entity, const v } } - /* Clamp negative angle factor to 0 */ + /* Light behind sample point? Zero contribution, period. */ if (angle < 0) { - angle = 0; - } - - /* If the angle scale factor is 0, and it's a planar surface, make the final contribution 0. - e.g. this stops light leaking around corners. - For curved surfaces, we relax this restriction. - e.g. for https://github.com/ericwa/tyrutils-ericw/issues/172 - */ - if (angle == 0 && !curved) { return 0; } - /* Apply anglescale. Note: by default, will boost angle=0 to angle=0.5 */ + /* Apply anglescale */ angle = (1.0 - entity->anglescale.floatValue()) + (entity->anglescale.floatValue() * angle); /* Check spotlight cone */ @@ -961,11 +952,10 @@ static void LightFace_SampleMipTex(miptex_t *tex, const float *projectionmatrix, void GetLightContrib(const globalconfig_t &cfg, const light_t *entity, const vec3_t surfnorm, const vec3_t surfpoint, bool twosided, - bool curved, vec3_t color_out, vec3_t surfpointToLightDir_out, vec3_t normalmap_addition_out, float *dist_out) { float dist = GetDir(surfpoint, *entity->origin.vec3Value(), surfpointToLightDir_out); - float add = GetLightValueWithAngle(cfg, entity, surfnorm, surfpointToLightDir_out, dist, twosided, curved); + float add = GetLightValueWithAngle(cfg, entity, surfnorm, surfpointToLightDir_out, dist, twosided); /* write out the final color */ if (entity->projectedmip) { @@ -1273,7 +1263,7 @@ GetDirectLighting(const globalconfig_t &cfg, raystream_t *rs, const vec3_t origi continue; } - GetLightContrib(cfg, &entity, normal, origin, false, false, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist); + GetLightContrib(cfg, &entity, normal, origin, false, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist); const float dirt = Dirt_GetScaleFactor(cfg, occlusion, &entity, surfpointToLightDist, /* FIXME: pass */ nullptr); VectorScale(color, dirt, color); @@ -1376,7 +1366,7 @@ LightFace_Entity(const bsp2_t *bsp, float surfpointToLightDist; vec3_t color, normalcontrib; - GetLightContrib(cfg, entity, surfnorm, surfpoint, lightsurf->twosided, lightsurf->curved, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist); + GetLightContrib(cfg, entity, surfnorm, surfpoint, lightsurf->twosided, color, surfpointToLightDir, normalcontrib, &surfpointToLightDist); const float occlusion = Dirt_GetScaleFactor(cfg, lightsurf->occlusion[i], entity, surfpointToLightDist, lightsurf); VectorScale(color, occlusion, color);