]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
q3map2: do not use the new area light backsplash algorithm by Jelvan by default,... illwieckz/backsplash 210/head
authorThomas Debesse <dev@illwieckz.net>
Fri, 25 Oct 2024 20:18:02 +0000 (22:18 +0200)
committerThomas Debesse <dev@illwieckz.net>
Fri, 25 Oct 2024 20:18:02 +0000 (22:18 +0200)
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

tools/quake3/q3map2/help.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_bounce.c
tools/quake3/q3map2/q3map2.h

index 4f5b2b5f39e3e559e5cbf9b1bd009f020a8b69ab..c39800569e99c2d9c89a54a97fb8e5d3e973c3a8 100644 (file)
@@ -181,6 +181,8 @@ void HelpLight()
                {"-vlight [options] <filename.map>", "Deprecated alias for `-light -fast` ... filename.map"},
                {"-approx <N>", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"},
                {"-areascale <F, `-area` F>", "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"},
index 26b2a347bfc9d335acd3a6dc50bfbdb495ca46c4..378747f63ebb01cb3e96b1fd7b26598587514d0a 100644 (file)
@@ -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;
index b0b838b8ccea11094e34b50f3dc1745e0dc64384..caa8dceff1fc7b8172bf26fcefa4a9b771fe5ae9 100644 (file)
@@ -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
        {
index 40b13c1d7f1b1d37f7f058491f96946e5ec51b4d..f2de1d04d6af6ec5a840eb7d7e02e8fc48837b12 100644 (file)
@@ -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 );