From a0349922804f34b83e6d3546a5f49049e9bae0a4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Nov 2018 00:25:42 +0100 Subject: [PATCH] - make the closest sample still decide the distance --- src/lightmap/lightsurface.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lightmap/lightsurface.cpp b/src/lightmap/lightsurface.cpp index a135b8a..167f6e4 100644 --- a/src/lightmap/lightsurface.cpp +++ b/src/lightmap/lightsurface.cpp @@ -269,7 +269,10 @@ float kexLightSurface::TraceSurface(FLevel *doomMap, kexTrace &trace, const surf normal = kexVec3::vecUp; } + float gzdoomRadiusScale = 2.0f; // 2.0 because gzdoom's dynlights do this and we want them to match + float total = 0.0f; + float closestDistance = distance * gzdoomRadiusScale; for (unsigned int i = 0; i < origins.Length(); ++i) { kexVec3 center = origins[i]; @@ -310,10 +313,11 @@ float kexLightSurface::TraceSurface(FLevel *doomMap, kexTrace &trace, const surf } float d = origin.Distance(center); - attenuation *= 1.0f - d / (distance * 2.0f); // 2.0 because gzdoom's dynlights do this and we want them to match - if (attenuation > 0.0f) - total += attenuation; + if (d < closestDistance) + closestDistance = d; + total += attenuation; } - return total / origins.Length(); + float attenuation = 1.0f - closestDistance / (distance * gzdoomRadiusScale); + return attenuation * total / origins.Length(); }