1.0f, /* lightmap compensate */\r
0.3f, /* lightgrid scale */\r
0.6f, /* lightgrid ambient scale */\r
+ qfalse, /* light angle attenuation uses half-lambert curve */\r
qtrue, /* disable shader lightstyles hack */\r
qtrue, /* keep light entities on bsp */\r
4, /* default patchMeta subdivisions tolerance */\r
1.0f, /* lightmap compensate */\r
0.3f, /* lightgrid scale */\r
0.6f, /* lightgrid ambient scale */\r
+ qfalse, /* light angle attenuation uses half-lambert curve */\r
qtrue, /* disable shader lightstyles hack */\r
qtrue, /* keep light entities on bsp */\r
4, /* default patchMeta subdivisions tolerance */\r
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qtrue, /* disable shader lightstyles hack */
qtrue, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */\r
0.4f, /* lightgrid scale */\r
0.6f, /* lightgrid ambient scale */\r
+ qfalse, /* light angle attenuation uses half-lambert curve */\r
qtrue, /* disable shader lightstyles hack */\r
qtrue, /* keep light entities on bsp */\r
4, /* default patchMeta subdivisions tolerance */\r
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qtrue, /* light angle attenuation uses half-lambert curve */
qtrue, /* disable shader lightstyles hack */
- qfalse, /* keep light entities on bsp */
+ qtrue, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
- qfalse, /* patch casting enabled */
+ qtrue, /* patch casting enabled */
qtrue, /* compile deluxemaps */
0, /* deluxemaps default mode */
256, /* minimap size */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qtrue, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
dist = 16.0f;
/* angle attenuation */
- angle = (light->flags & LIGHT_ATTEN_ANGLE) ? DotProduct( trace->normal, trace->direction ) : 1.0f;
+ if( light->flags & LIGHT_ATTEN_ANGLE )
+ {
+ /* standard Lambert attenuation */
+ float dot = DotProduct( trace->normal, trace->direction );
+
+ /* twosided lighting */
+ if( trace->twoSided )
+ dot = fabs( dot );
+
+ /* jal: optional half Lambert attenuation (http://developer.valvesoftware.com/wiki/Half_Lambert) */
+ if( lightAngleHL )
+ {
+ if( dot > 0.001f ) // skip coplanar
+ {
+ if( dot > 1.0f ) dot = 1.0f;
+ dot = ( dot * 0.5f ) + 0.5f;
+ dot *= dot;
+ }
+ else
+ dot = 0;
+ }
+
+ angle = dot;
+ }
+ else
+ angle = 1.0f;
+
if( light->angleScale != 0.0f )
{
angle /= light->angleScale;
angle = 1.0f;
}
- /* twosided lighting */
- if( trace->twoSided )
- angle = fabs( angle );
-
/* attenuate */
if( light->flags & LIGHT_ATTEN_LINEAR )
{
/* get origin and direction */
VectorAdd( trace->origin, light->origin, trace->end );
dist = SetupTrace( trace );
-
+
/* angle attenuation */
- angle = (light->flags & LIGHT_ATTEN_ANGLE)
- ? DotProduct( trace->normal, trace->direction )
- : 1.0f;
-
- /* twosided lighting */
- if( trace->twoSided )
- angle = fabs( angle );
+ if( light->flags & LIGHT_ATTEN_ANGLE )
+ {
+ /* standard Lambert attenuation */
+ float dot = DotProduct( trace->normal, trace->direction );
+
+ /* twosided lighting */
+ if( trace->twoSided )
+ dot = fabs( dot );
+
+ /* jal: optional half Lambert attenuation (http://developer.valvesoftware.com/wiki/Half_Lambert) */
+ if( lightAngleHL )
+ {
+ if( dot > 0.001f ) // skip coplanar
+ {
+ if( dot > 1.0f ) dot = 1.0f;
+ dot = ( dot * 0.5f ) + 0.5f;
+ dot *= dot;
+ }
+ else
+ dot = 0;
+ }
+
+ angle = dot;
+ }
+ else
+ angle = 1.0f;
/* attenuate */
add = light->photons * angle;
gridAmbientScale = game->gridAmbientScale;
Sys_Printf( " lightgrid ambient scale: %f\n", gridAmbientScale );
+ lightAngleHL = game->lightAngleHL;
+ if( lightAngleHL )
+ Sys_Printf( " half lambert light angle attenuation enabled \n" );
+
noStyles = game->noStyles;
if (noStyles == qtrue)
Sys_Printf( " shader lightstyles hack: disabled\n" );
loMem = qtrue;
Sys_Printf( "Enabling low-memory (potentially slower) lighting mode\n" );
}
+ else if( !strcmp( argv[ i ], "-lightanglehl" ) )
+ {
+ if( ( atoi( argv[ i + 1 ] ) != 0 ) != lightAngleHL )
+ {
+ lightAngleHL = ( atoi( argv[ i + 1 ] ) != 0 );
+ if( lightAngleHL )
+ Sys_Printf( "Enabling half lambert light angle attenuation\n" );
+ else
+ Sys_Printf( "Disabling half lambert light angle attenuation\n" );
+ }
+ }
else if( !strcmp( argv[ i ], "-nostyle" ) || !strcmp( argv[ i ], "-nostyles" ) )
{
noStyles = qtrue;
float lightmapCompensate; /* default lightmap compensate value */
float gridScale; /* vortex: default lightgrid scale (affects both directional and ambient spectres) */
float gridAmbientScale; /* vortex: default lightgrid ambient spectre scale */
+ qboolean lightAngleHL; /* jal: use half-lambert curve for light angle attenuation */
qboolean noStyles; /* use lightstyles hack or not */
qboolean keepLights; /* keep light entities on bsp */
int patchSubdivisions; /* default patch subdivisions tolerance */
Q_EXTERN float areaScale Q_ASSIGN( 0.25f );
Q_EXTERN float skyScale Q_ASSIGN( 1.0f );
Q_EXTERN float bounceScale Q_ASSIGN( 0.25f );
+
+/* jal: alternative angle attenuation curve */
+Q_EXTERN qboolean lightAngleHL Q_ASSIGN( qfalse );
/* vortex: gridscale and gridambientscale */
Q_EXTERN float gridScale Q_ASSIGN( 1.0f );