Don't scale shadow multipliers by overbrightbits, and improve documentation.

This commit is contained in:
SmileTheory 2013-04-22 21:52:16 -07:00
parent feb012152c
commit 8270d54a25
6 changed files with 52 additions and 26 deletions

View file

@ -3278,6 +3278,7 @@ void RE_LoadWorldMap( const char *name ) {
// set default map light scale // set default map light scale
tr.mapLightScale = 1.0f; tr.mapLightScale = 1.0f;
tr.sunShadowScale = 0.5f;
// set default sun direction to be used if it isn't // set default sun direction to be used if it isn't
// overridden by a shader // overridden by a shader

View file

@ -1198,7 +1198,7 @@ void R_Register( void )
r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT ); r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT );
r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT ); r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT );
r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT ); r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT );
r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.75", CVAR_CHEAT ); r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT );
r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH );

View file

@ -1789,10 +1789,10 @@ typedef struct {
int viewCluster; int viewCluster;
float mapLightScale; float mapLightScale;
float sunShadowScale;
qboolean sunShadows; qboolean sunShadows;
vec3_t sunLight; // from the sky shader for this level vec3_t sunLight; // from the sky shader for this level
vec3_t sunAmbient;
vec3_t sunDirection; vec3_t sunDirection;
frontEndCounters_t pc; frontEndCounters_t pc;

View file

@ -360,19 +360,34 @@ void RE_RenderScene( const refdef_t *fd ) {
VectorSet(tr.refdef.sunCol, 0, 0, 0); VectorSet(tr.refdef.sunCol, 0, 0, 0);
VectorSet(tr.refdef.sunAmbCol, 0, 0, 0); VectorSet(tr.refdef.sunAmbCol, 0, 0, 0);
} }
else if (r_forceSun->integer == 1) else
{
tr.refdef.colorScale = r_forceSun->integer ? r_forceSunMapLightScale->value : tr.mapLightScale;
if (r_sunlightMode->integer == 1)
{
tr.refdef.sunCol[0] =
tr.refdef.sunCol[1] =
tr.refdef.sunCol[2] = 1.0f;
tr.refdef.sunAmbCol[0] =
tr.refdef.sunAmbCol[1] =
tr.refdef.sunAmbCol[2] = r_forceSun->integer ? r_forceSunAmbientScale->value : tr.sunShadowScale;
}
else
{ {
float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8);
tr.refdef.colorScale = r_forceSunMapLightScale->value; if (r_forceSun->integer)
{
VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol);
VectorScale(tr.sunLight, scale * r_forceSunAmbientScale->value, tr.refdef.sunAmbCol); VectorScale(tr.sunLight, scale * r_forceSunAmbientScale->value, tr.refdef.sunAmbCol);
} }
else else
{ {
float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8);
tr.refdef.colorScale = tr.mapLightScale;
VectorScale(tr.sunLight, scale, tr.refdef.sunCol); VectorScale(tr.sunLight, scale, tr.refdef.sunCol);
VectorScale(tr.sunAmbient, scale, tr.refdef.sunAmbCol); VectorScale(tr.sunLight, scale * tr.sunShadowScale, tr.refdef.sunAmbCol);
}
}
} }
if (r_forceAutoExposure->integer) if (r_forceAutoExposure->integer)

View file

@ -1636,8 +1636,6 @@ static qboolean ParseShader( char **text )
a = atof( token ); a = atof( token );
VectorScale( tr.sunLight, a, tr.sunLight); VectorScale( tr.sunLight, a, tr.sunLight);
VectorSet( tr.sunAmbient, 0.0f, 0.0f, 0.0f);
token = COM_ParseExt( text, qfalse ); token = COM_ParseExt( text, qfalse );
a = atof( token ); a = atof( token );
a = a / 180 * M_PI; a = a / 180 * M_PI;
@ -1656,7 +1654,7 @@ static qboolean ParseShader( char **text )
tr.mapLightScale = atof(token); tr.mapLightScale = atof(token);
token = COM_ParseExt( text, qfalse ); token = COM_ParseExt( text, qfalse );
VectorScale( tr.sunLight, atof(token), tr.sunAmbient ); tr.sunShadowScale = atof(token);
} }
SkipRestOfLine( text ); SkipRestOfLine( text );

View file

@ -240,21 +240,31 @@ Cvars for the sunlight and cascaded shadow maps:
r_forceSunMapLightScale - Cheat. Scale map brightness by this factor r_forceSunMapLightScale - Cheat. Scale map brightness by this factor
when r_forceSun 1. when r_forceSun 1.
0.5 - Default 1.0 - Default
r_forceSunLightScale - Cheat. Scale sun brightness by this factor r_forceSunLightScale - Cheat. Scale sun brightness by this factor
when r_forceSun 1. when r_forceSun 1.
0.5 - Default 1.0 - Default
r_forceSunAmbientScale - Cheat. Scale sun ambient brightness by this r_forceSunAmbientScale - Cheat. Scale sun ambient brightness by this
factor when r_forceSun 1. factor when r_forceSun 1.
0.2 - Default 0.5 - Default
r_sunShadows - Enable sunlight and cascaded shadow maps for r_sunShadows - Enable sunlight and cascaded shadow maps for
it on maps that support it. it on maps that support it.
0 - No. 0 - No.
1 - Yes. (default) 1 - Yes. (default)
r_sunlightMode - Specify the method used to add sunlight to
the scene.
0 - No.
1 - Multiply lit areas by light scale, and
shadowed areas by ambient scale.
(default)
2 - Add light. Looks better, but is slower
and doesn't integrate well with existing
maps.
r_shadowFilter - Enable filtering shadows for a smoother r_shadowFilter - Enable filtering shadows for a smoother
look. look.
0 - No. 0 - No.
@ -468,8 +478,8 @@ and is the equivalent for 'exactVertex'.
This adds a new keyword to sky materials, q3gl2_sun. The syntax is: This adds a new keyword to sky materials, q3gl2_sun. The syntax is:
q3gl2_sun <red> <green> <blue> <intensity> <degrees> <mapLightScale> q3gl2_sun <red> <green> <blue> <intensity> <degrees> <elevation>
<ambientLightScale> <mapLightScale> <ambientLightScale>
Note the first six parameters are the same as in q3map_sun or q3map_sunExt, Note the first six parameters are the same as in q3map_sun or q3map_sunExt,
and the last two indicate scaling factors for the map brightness and an ambient and the last two indicate scaling factors for the map brightness and an ambient
@ -477,8 +487,9 @@ light of the same color as the sun.
There are currently two ways to use this in your own (and other people's) maps. There are currently two ways to use this in your own (and other people's) maps.
1. Create your map as normal and add a 'q3gl2_sun' line after your 1. Create your map as normal, set r_sunlightMode to 1, and add a
'q3map_sun' line in your sky material, like so: 'q3gl2_sun' line after your 'q3map_sun' line in your sky material, like
so:
textures/skies/bluesky textures/skies/bluesky
{ {
@ -489,7 +500,7 @@ There are currently two ways to use this in your own (and other people's) maps.
surfaceparm nolightmap surfaceparm nolightmap
surfaceparm sky surfaceparm sky
q3map_sunExt 240 238 200 100 195 35 3 16 q3map_sunExt 240 238 200 100 195 35 3 16
q3gl2_sun 240 238 200 50 195 35 3 0.5 0.2 q3gl2_sun 240 238 200 50 195 35 3 1.0 0.2
q3map_skylight 50 16 q3map_skylight 50 16
q3map_lightimage $whiteimage q3map_lightimage $whiteimage
@ -501,7 +512,8 @@ There are currently two ways to use this in your own (and other people's) maps.
can be used with existing maps without recompilation. The downside is can be used with existing maps without recompilation. The downside is
artifacts like doubled shadows and uneven shadow edges. artifacts like doubled shadows and uneven shadow edges.
2. Use 'q3gl2_sun' instead of 'q3map_sun' or 'q3map_sunExt', like so: 2. Set r_sunlightMode to 2 and use 'q3gl2_sun' instead of 'q3map_sun' or
'q3map_sunExt', like so:
textures/skies/bluesky textures/skies/bluesky
{ {