half lambert lighting by jal (option: -lightanglehl)
This commit is contained in:
parent
b8839b8771
commit
23a825c1f1
|
|
@ -58,6 +58,7 @@ game_t struct
|
|||
1.0f, /* lightmap compensate */
|
||||
0.3f, /* lightgrid scale */
|
||||
0.6f, /* lightgrid ambient scale */
|
||||
qfalse, /* light angle attenuation uses half-lambert curve */
|
||||
qtrue, /* disable shader lightstyles hack */
|
||||
qtrue, /* keep light entities on bsp */
|
||||
4, /* default patchMeta subdivisions tolerance */
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ game_t struct
|
|||
1.0f, /* lightmap compensate */
|
||||
0.3f, /* lightgrid scale */
|
||||
0.6f, /* lightgrid ambient scale */
|
||||
qfalse, /* light angle attenuation uses half-lambert curve */
|
||||
qtrue, /* disable shader lightstyles hack */
|
||||
qtrue, /* keep light entities on bsp */
|
||||
4, /* default patchMeta subdivisions tolerance */
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ game_t struct
|
|||
1.0f, /* lightmap compensate */
|
||||
0.4f, /* lightgrid scale */
|
||||
0.6f, /* lightgrid ambient scale */
|
||||
qfalse, /* light angle attenuation uses half-lambert curve */
|
||||
qtrue, /* disable shader lightstyles hack */
|
||||
qtrue, /* keep light entities on bsp */
|
||||
4, /* default patchMeta subdivisions tolerance */
|
||||
|
|
|
|||
|
|
@ -119,10 +119,11 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ game_t struct
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -865,7 +865,33 @@ int LightContributionToSample( trace_t *trace )
|
|||
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;
|
||||
|
|
@ -873,10 +899,6 @@ int LightContributionToSample( trace_t *trace )
|
|||
angle = 1.0f;
|
||||
}
|
||||
|
||||
/* twosided lighting */
|
||||
if( trace->twoSided )
|
||||
angle = fabs( angle );
|
||||
|
||||
/* attenuate */
|
||||
if( light->flags & LIGHT_ATTEN_LINEAR )
|
||||
{
|
||||
|
|
@ -918,15 +940,34 @@ int LightContributionToSample( trace_t *trace )
|
|||
/* 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;
|
||||
|
|
@ -1880,6 +1921,10 @@ int LightMain( int argc, char **argv )
|
|||
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" );
|
||||
|
|
@ -2416,6 +2461,17 @@ int LightMain( int argc, char **argv )
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -562,6 +562,7 @@ typedef struct game_s
|
|||
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 */
|
||||
|
|
@ -2217,6 +2218,9 @@ Q_EXTERN float pointScale Q_ASSIGN( 7500.0f );
|
|||
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 );
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user