]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
new option -extradist to improve lighting a bit, also a light entity field _extradist...
authorRudolf Polzer <rpolzer@nb-04.(none)>
Tue, 6 Apr 2010 15:03:50 +0000 (17:03 +0200)
committerRudolf Polzer <rpolzer@nb-04.(none)>
Tue, 6 Apr 2010 15:03:50 +0000 (17:03 +0200)
tools/quake3/q3map2/light.c
tools/quake3/q3map2/q3map2.h

index deff96777d84b699abe112e972f1aaaaee2f182f..6c8eb96a113dcdbe2e2ab46f1428a6b66276b506 100644 (file)
@@ -401,6 +401,10 @@ void CreateEntityLights( void )
                else
                        light->color[ 0 ] = light->color[ 1 ] = light->color[ 2 ] = 1.0f;
 
+               light->extraDist = FloatForKey( e, "_extradist" );
+               if(light->extraDist == 0.0f)
+                       light->extraDist = extraDist;
+               
                intensity = intensity * pointScale;
                light->photons = intensity;
 
@@ -821,6 +825,12 @@ int LightContributionToSample( trace_t *trace )
                        else if( angle < 0.0f &&
                                (trace->twoSided || (light->flags & LIGHT_TWOSIDED)) )
                                angle = -angle;
+
+                       /* clamp the distance to prevent super hot spots */
+                       dist = sqrt(dist * dist + light->extraDist * light->extraDist);
+                       if( dist < 16.0f )
+                               dist = 16.0f;
+
                        add = light->photons / (dist * dist) * angle;
                }
                else
@@ -859,11 +869,12 @@ int LightContributionToSample( trace_t *trace )
                dist = SetupTrace( trace );
                if( dist >= light->envelope )
                        return 0;
-               
+
                /* clamp the distance to prevent super hot spots */
+               dist = sqrt(dist * dist + light->extraDist * light->extraDist);
                if( dist < 16.0f )
                        dist = 16.0f;
-               
+
                /* angle attenuation */
                if( light->flags & LIGHT_ATTEN_ANGLE )
                {
@@ -907,7 +918,7 @@ int LightContributionToSample( trace_t *trace )
                                add = 0.0f;
                }
                else
-                       add = light->photons / (dist * dist) * angle;
+                       add = (light->photons / (dist * dist)) * angle;
                
                /* handle spotlights */
                if( light->type == EMIT_SPOT )
@@ -1156,9 +1167,10 @@ int LightContributionToPoint( trace_t *trace )
        if( light->type == EMIT_AREA && faster )
        {
                /* clamp the distance to prevent super hot spots */
+               dist = sqrt(dist * dist + light->extraDist * light->extraDist);
                if( dist < 16.0f )
                        dist = 16.0f;
-               
+
                /* attenuate */
                add = light->photons / (dist * dist);
        }
@@ -1202,6 +1214,7 @@ int LightContributionToPoint( trace_t *trace )
        else if( light->type == EMIT_POINT || light->type == EMIT_SPOT )
        {
                /* clamp the distance to prevent super hot spots */
+               dist = sqrt(dist * dist + light->extraDist * light->extraDist);
                if( dist < 16.0f )
                        dist = 16.0f;
                
@@ -2227,6 +2240,15 @@ int LightMain( int argc, char **argv )
                        wolfLight = qfalse;
                        Sys_Printf( "Enabling Quake 3 lighting model (nonlinear default)\n" );
                }
+
+               else if( !strcmp( argv[ i ], "-extradist" ) )
+               {
+                       extraDist = atof( argv[ i + 1 ] );
+                       if( extraDist < 0 )
+                               extraDist = 0;
+                       i++;
+                       Sys_Printf( "Default extra radius set to %f units\n", extraDist );
+               }
                
                else if( !strcmp( argv[ i ], "-sunonly" ) )
                {
index 498f656be12c9b7f4043ac8edbc6d347568341d2..5db3b8cd5095056c5abdaa03431244f01df2ee47 100644 (file)
@@ -1304,6 +1304,7 @@ typedef struct light_s
        float                           radiusByDist;   /* for spotlights */
        float                           fade;                   /* ydnar: from wolf, for linear lights */
        float                           angleScale;             /* ydnar: stolen from vlight for K */
+       float                           extraDist;              /* "extra dimension" distance of the light, to kill hot spots */
 
        float                           add;                    /* ydnar: used for area lights */
        float                           envelope;               /* ydnar: units until falloff < tolerance */
@@ -2141,6 +2142,7 @@ light global variables
 
 /* commandline arguments */
 Q_EXTERN qboolean                      wolfLight Q_ASSIGN( qfalse );
+Q_EXTERN float                         extraDist Q_ASSIGN( 0.0f );
 Q_EXTERN qboolean                      loMem Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      noStyles Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      keepLights Q_ASSIGN( qfalse );