From: Rudolf Polzer Date: Sun, 19 Apr 2020 00:41:25 +0000 (+0200) Subject: Comment ColorToBytesNonZero and fix zero detection in light.c. X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=1b3887abb72be950ba6a39cd7d87b6ba3b20c8c3;p=xonotic%2Fnetradiant.git Comment ColorToBytesNonZero and fix zero detection in light.c. --- diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index b8ad379f..709b2ab9 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1771,7 +1771,7 @@ void TraceGrid( int num ){ } /* vortex: apply gridscale and gridambientscale here */ - if (gp->directed[0] || gp->directed[1] || gp->directed[2]) { + if (gp->directed[i][0] || gp->directed[i][1] || gp->directed[i][2]) { /* * HACK: if there's a non-zero directed component, this * lightgrid cell is useful. However, ioq3 skips grid diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 56539875..b86ff4b2 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -132,6 +132,12 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){ colorBytes[ 2 ] = sample[ 2 ]; } +/* + * Same as ColorToBytes, but if the output color will never contain zero + * components. Used to avoid returning 0 0 0 due to an ioq3 issue. Reason + * to also map 0 0 1 to 1 1 1 is to ensure monotonicity in the color mapping + * to prevent banding-like artifacts on lightmaps. + */ void ColorToBytesNonZero( const float *color, byte *colorBytes, float scale) { int i; ColorToBytes(color, colorBytes, scale);