new option -extradist to improve lighting a bit, also a light entity field _extradist of the same purpose
This commit is contained in:
parent
5e9d69cd53
commit
99342abdf7
|
|
@ -401,6 +401,10 @@ void CreateEntityLights( void )
|
||||||
else
|
else
|
||||||
light->color[ 0 ] = light->color[ 1 ] = light->color[ 2 ] = 1.0f;
|
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;
|
intensity = intensity * pointScale;
|
||||||
light->photons = intensity;
|
light->photons = intensity;
|
||||||
|
|
||||||
|
|
@ -821,6 +825,12 @@ int LightContributionToSample( trace_t *trace )
|
||||||
else if( angle < 0.0f &&
|
else if( angle < 0.0f &&
|
||||||
(trace->twoSided || (light->flags & LIGHT_TWOSIDED)) )
|
(trace->twoSided || (light->flags & LIGHT_TWOSIDED)) )
|
||||||
angle = -angle;
|
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;
|
add = light->photons / (dist * dist) * angle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -861,6 +871,7 @@ int LightContributionToSample( trace_t *trace )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* clamp the distance to prevent super hot spots */
|
/* clamp the distance to prevent super hot spots */
|
||||||
|
dist = sqrt(dist * dist + light->extraDist * light->extraDist);
|
||||||
if( dist < 16.0f )
|
if( dist < 16.0f )
|
||||||
dist = 16.0f;
|
dist = 16.0f;
|
||||||
|
|
||||||
|
|
@ -907,7 +918,7 @@ int LightContributionToSample( trace_t *trace )
|
||||||
add = 0.0f;
|
add = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
add = light->photons / (dist * dist) * angle;
|
add = (light->photons / (dist * dist)) * angle;
|
||||||
|
|
||||||
/* handle spotlights */
|
/* handle spotlights */
|
||||||
if( light->type == EMIT_SPOT )
|
if( light->type == EMIT_SPOT )
|
||||||
|
|
@ -1156,6 +1167,7 @@ int LightContributionToPoint( trace_t *trace )
|
||||||
if( light->type == EMIT_AREA && faster )
|
if( light->type == EMIT_AREA && faster )
|
||||||
{
|
{
|
||||||
/* clamp the distance to prevent super hot spots */
|
/* clamp the distance to prevent super hot spots */
|
||||||
|
dist = sqrt(dist * dist + light->extraDist * light->extraDist);
|
||||||
if( dist < 16.0f )
|
if( dist < 16.0f )
|
||||||
dist = 16.0f;
|
dist = 16.0f;
|
||||||
|
|
||||||
|
|
@ -1202,6 +1214,7 @@ int LightContributionToPoint( trace_t *trace )
|
||||||
else if( light->type == EMIT_POINT || light->type == EMIT_SPOT )
|
else if( light->type == EMIT_POINT || light->type == EMIT_SPOT )
|
||||||
{
|
{
|
||||||
/* clamp the distance to prevent super hot spots */
|
/* clamp the distance to prevent super hot spots */
|
||||||
|
dist = sqrt(dist * dist + light->extraDist * light->extraDist);
|
||||||
if( dist < 16.0f )
|
if( dist < 16.0f )
|
||||||
dist = 16.0f;
|
dist = 16.0f;
|
||||||
|
|
||||||
|
|
@ -2228,6 +2241,15 @@ int LightMain( int argc, char **argv )
|
||||||
Sys_Printf( "Enabling Quake 3 lighting model (nonlinear default)\n" );
|
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" ) )
|
else if( !strcmp( argv[ i ], "-sunonly" ) )
|
||||||
{
|
{
|
||||||
sunOnly = qtrue;
|
sunOnly = qtrue;
|
||||||
|
|
|
||||||
|
|
@ -1304,6 +1304,7 @@ typedef struct light_s
|
||||||
float radiusByDist; /* for spotlights */
|
float radiusByDist; /* for spotlights */
|
||||||
float fade; /* ydnar: from wolf, for linear lights */
|
float fade; /* ydnar: from wolf, for linear lights */
|
||||||
float angleScale; /* ydnar: stolen from vlight for K */
|
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 add; /* ydnar: used for area lights */
|
||||||
float envelope; /* ydnar: units until falloff < tolerance */
|
float envelope; /* ydnar: units until falloff < tolerance */
|
||||||
|
|
@ -2141,6 +2142,7 @@ light global variables
|
||||||
|
|
||||||
/* commandline arguments */
|
/* commandline arguments */
|
||||||
Q_EXTERN qboolean wolfLight Q_ASSIGN( qfalse );
|
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 loMem Q_ASSIGN( qfalse );
|
||||||
Q_EXTERN qboolean noStyles Q_ASSIGN( qfalse );
|
Q_EXTERN qboolean noStyles Q_ASSIGN( qfalse );
|
||||||
Q_EXTERN qboolean keepLights Q_ASSIGN( qfalse );
|
Q_EXTERN qboolean keepLights Q_ASSIGN( qfalse );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user