From bdcd55d604fddbe6548604d919a79bdc2285a2ad Mon Sep 17 00:00:00 2001 From: uis Date: Sat, 23 Dec 2023 00:16:49 +0300 Subject: [PATCH] Small improvements --- tools/quake3/q3map2/light_bounce.c | 11 +++++++---- tools/quake3/q3map2/light_ydnar.c | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/quake3/q3map2/light_bounce.c b/tools/quake3/q3map2/light_bounce.c index d34c6ed2..b0b838b8 100644 --- a/tools/quake3/q3map2/light_bounce.c +++ b/tools/quake3/q3map2/light_bounce.c @@ -263,7 +263,7 @@ qboolean RadSampleImage( byte *pixels, int width, int height, float st[ 2 ], flo #define SAMPLE_GRANULARITY 6 static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si, radWinding_t *rw, vec3_t average, vec3_t gradient, int *style ){ - int i, j, k, l, v, x, y, samples, avgcolor; + int i, j, k, l, v, x, y, samples, avgcolor, f_superSample; vec3_t color, mins, maxs; vec4_t textureColor; float alpha, alphaI, bf; @@ -316,6 +316,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* sample lightmap */ else { + f_superSample = (float)superSample; /* fracture the winding into a fan (including degenerate tris) */ for ( v = 1; v < ( rw->numVerts - 1 ) && samples < MAX_SAMPLES; v++ ) { @@ -335,7 +336,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, blend[ 0 ] = i; blend[ 1 ] = j; blend[ 2 ] = k; - bf = ( 1.0 / ( blend[ 0 ] + blend[ 1 ] + blend[ 2 ] ) ); + bf = ( 1.0f / ( blend[ 0 ] + blend[ 1 ] + blend[ 2 ] ) ); VectorScale( blend, bf, blend ); /* create a blended sample */ @@ -352,8 +353,10 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, } /* get lightmap xy coords */ - x = lightmap[ 0 ] / (float) superSample; - y = lightmap[ 1 ] / (float) superSample; + /* xy = clamp(lightmap/superSample, 0, lm - 1)*/ + x = lightmap[ 0 ] / f_superSample; + y = lightmap[ 1 ] / f_superSample; + if ( x < 0 ) { x = 0; } diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index e244d943..eee4a173 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1258,6 +1258,7 @@ void MapRawLightmap( int rawLightmapNum ){ ----------------------------------------------------------------- */ /* walk the luxels */ + /* FIXME: superSample is int, no need in floor() */ radius = floor( superSample / 2 ); radius = radius > 0 ? radius : 1.0f; radius += 1.0f; -- 2.39.2