From: Thomas Debesse Date: Fri, 25 Oct 2024 20:18:02 +0000 (+0200) Subject: q3map2: do not use the new area light backsplash algorithm by Jelvan by default,... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2Fillwieckz%2Fbacksplash;p=xonotic%2Fnetradiant.git q3map2: do not use the new area light backsplash algorithm by Jelvan by default, make it optional NRC commit ed4c8c204443726e852a4c8927b3f8d2571cc522 replaced the historic Quake 3 backsplash algorithm with an alternate one by Jelvan: > new area lights backsplash algorithm ( by Jelvan ), > hijacking temp area lights ( to simulate volumetric > behavior of source ones ) It suffers from many bugs and then only a few maps may benefit from it, see: https://gitlab.com/xonotic/netradiant/-/merge_requests/210 --- diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c index 4f5b2b5f..c3980056 100644 --- a/tools/quake3/q3map2/help.c +++ b/tools/quake3/q3map2/help.c @@ -181,6 +181,8 @@ void HelpLight() {"-vlight [options] ", "Deprecated alias for `-light -fast` ... filename.map"}, {"-approx ", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"}, {"-areascale ", "Scaling factor for area lights (surfacelight)"}, + {"-backsplashmode 0", "Use point light as backsplash light"}, + {"-backsplashmode 1", "Use area light as backsplash light (experimental)"}, {"-border", "Add a red border to lightmaps for debugging"}, {"-bouncegrid", "Also compute radiosity on the light grid"}, {"-bounceonly", "Only compute radiosity"}, diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 26b2a347..378747f6 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -3033,6 +3033,11 @@ int LightMain( int argc, char **argv ){ argv[ i ] = NULL; Sys_Printf( "Use %s as surface file\n", surfaceFilePath ); } + else if ( !strcmp( argv[ i ], "-backsplashMode" ) ) + { + backsplashMode = ( atoi( argv[ i + 1 ] ) != 0 ); + i++; + } /* unhandled args */ else { @@ -3041,6 +3046,15 @@ int LightMain( int argc, char **argv ){ } + if ( backsplashMode ) + { + Sys_Printf( "Using area light as backsplash light (experimental)\n" ); + } + else + { + Sys_Printf( "Using point light as backsplash light\n" ); + } + /* fix up falloff tolerance for sRGB */ if ( lightmapsRGB ) { falloffTolerance = Image_LinearFloatFromsRGBFloat( falloffTolerance * ( 1.0 / 255.0 ) ) * 255.0; diff --git a/tools/quake3/q3map2/light_bounce.c b/tools/quake3/q3map2/light_bounce.c index b0b838b8..caa8dcef 100644 --- a/tools/quake3/q3map2/light_bounce.c +++ b/tools/quake3/q3map2/light_bounce.c @@ -598,77 +598,84 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw VectorMA( light->origin, 1.0f, light->normal, light->origin ); light->dist = DotProduct( light->origin, normal ); -#if 0 - /* optionally create a point backsplash light */ - if ( si->backsplashFraction > 0 ) { - - /* allocate a new point light */ - splash = safe_malloc0( sizeof( *splash ) ); - - splash->next = lights; - lights = splash; + if ( si->backsplashFraction > 0 && !( si->compileFlags & C_SKY ) ) { + /* optionally create a backsplash light */ + if ( !backsplashMode ) { + /* allocate a new point light */ + splash = safe_malloc0( sizeof( *splash ) ); - /* set it up */ - splash->flags = LIGHT_Q3A_DEFAULT; - splash->type = EMIT_POINT; - splash->photons = light->photons * si->backsplashFraction; + splash->next = lights; + lights = splash; - splash->fade = 1.0f; - splash->si = si; - VectorMA( light->origin, si->backsplashDistance, normal, splash->origin ); - VectorCopy( si->color, splash->color ); + /* set it up */ + splash->flags = LIGHT_Q3A_DEFAULT; + splash->type = EMIT_POINT; + splash->photons = light->photons * si->backsplashFraction; - splash->falloffTolerance = falloffTolerance; - splash->style = noStyles ? LS_NORMAL : light->style; + splash->fade = 1.0f; + splash->si = si; + VectorMA( light->origin, si->backsplashDistance, normal, splash->origin ); + VectorCopy( si->color, splash->color ); - /* add to counts */ - numPointLights++; - } -#endif + splash->falloffTolerance = falloffTolerance; + splash->style = noStyles ? LS_NORMAL : light->style; -#if 1 - /* optionally create area backsplash light */ - //if ( original && si->backsplashFraction > 0 ) { - if ( si->backsplashFraction > 0 && !( si->compileFlags & C_SKY ) ) { - /* allocate a new area light */ - splash = safe_malloc( sizeof( *splash ) ); - memset( splash, 0, sizeof( *splash ) ); - ThreadLock(); - splash->next = lights; - lights = splash; - ThreadUnlock(); - - /* set it up */ - splash->flags = LIGHT_AREA_DEFAULT; - splash->type = EMIT_AREA; - splash->photons = light->photons * 7.0f * si->backsplashFraction; - splash->add = light->add * 7.0f * si->backsplashFraction; - splash->fade = 1.0f; - splash->si = si; - VectorCopy( si->color, splash->color ); - VectorScale( splash->color, splash->add, splash->emitColor ); - splash->falloffTolerance = falloffTolerance; - splash->style = noStyles ? LS_NORMAL : si->lightStyle; - if ( splash->style < LS_NORMAL || splash->style >= LS_NONE ) { - splash->style = LS_NORMAL; + /* add to counts */ + numPointLights++; } + else + { + /* Alternate experimental backsplash implementation by Jelvan, + commit ed4c8c204443726e852a4c8927b3f8d2571cc522: + + > new area lights backsplash algorithm ( by Jelvan ), + > hijacking temp area lights ( to simulate volumetric + > behavior of source ones ) + + This implementation suffers from many bugs + and only a few maps may benefit from it, + see: https://gitlab.com/xonotic/netradiant/-/merge_requests/210 */ + + /* allocate a new area light */ + splash = safe_malloc( sizeof( *splash ) ); + memset( splash, 0, sizeof( *splash ) ); + ThreadLock(); + splash->next = lights; + lights = splash; + ThreadUnlock(); + + /* set it up */ + splash->flags = LIGHT_AREA_DEFAULT; + splash->type = EMIT_AREA; + splash->photons = light->photons * 7.0f * si->backsplashFraction; + splash->add = light->add * 7.0f * si->backsplashFraction; + splash->fade = 1.0f; + splash->si = si; + VectorCopy( si->color, splash->color ); + VectorScale( splash->color, splash->add, splash->emitColor ); + splash->falloffTolerance = falloffTolerance; + splash->style = noStyles ? LS_NORMAL : si->lightStyle; + + if ( splash->style < LS_NORMAL || splash->style >= LS_NONE ) { + splash->style = LS_NORMAL; + } - /* create a regular winding */ - splash_w = AllocWinding( rw->numVerts ); - splash_w->numpoints = rw->numVerts; - for ( i = 0; i < rw->numVerts; i++ ) - VectorMA( rw->verts[rw->numVerts - 1 - i].xyz, si->backsplashDistance, normal, splash_w->p[ i ] ); - splash->w = splash_w; + /* create a regular winding */ + splash_w = AllocWinding( rw->numVerts ); + splash_w->numpoints = rw->numVerts; + for ( i = 0; i < rw->numVerts; i++ ) + { + VectorMA( rw->verts[rw->numVerts - 1 - i].xyz, si->backsplashDistance, normal, splash_w->p[ i ] ); + } - VectorMA( light->origin, si->backsplashDistance, normal, splash->origin ); - VectorNegate( normal, splash->normal ); - splash->dist = DotProduct( splash->origin, splash->normal ); + splash->w = splash_w; -// splash->flags |= LIGHT_TWOSIDED; + VectorMA( light->origin, si->backsplashDistance, normal, splash->origin ); + VectorNegate( normal, splash->normal ); + splash->dist = DotProduct( splash->origin, splash->normal ); + } } -#endif - } else { diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 40b13c1d..f2de1d04 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -2107,6 +2107,7 @@ Q_EXTERN float clipDepthGlobal Q_ASSIGN( 2.0f ); Q_EXTERN qboolean lightmapTriangleCheck Q_ASSIGN( qfalse ); Q_EXTERN qboolean lightmapExtraVisClusterNudge Q_ASSIGN( qfalse ); Q_EXTERN qboolean lightmapFill Q_ASSIGN( qfalse ); +Q_EXTERN qboolean backsplashMode Q_ASSIGN( qfalse ); Q_EXTERN int metaAdequateScore Q_ASSIGN( -1 ); Q_EXTERN int metaGoodScore Q_ASSIGN( -1 ); Q_EXTERN float metaMaxBBoxDistance Q_ASSIGN( -1 );