diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index bb1e208e..1825b19c 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -3277,7 +3277,8 @@ void RE_LoadWorldMap( const char *name ) { } // 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 // overridden by a shader diff --git a/code/renderergl2/tr_init.c b/code/renderergl2/tr_init.c index 7dce181e..d5330248 100644 --- a/code/renderergl2/tr_init.c +++ b/code/renderergl2/tr_init.c @@ -1198,7 +1198,7 @@ void R_Register( void ) r_forceSun = ri.Cvar_Get( "r_forceSun", "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_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_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/code/renderergl2/tr_local.h b/code/renderergl2/tr_local.h index 45ff337b..b615cc07 100644 --- a/code/renderergl2/tr_local.h +++ b/code/renderergl2/tr_local.h @@ -1789,10 +1789,10 @@ typedef struct { int viewCluster; float mapLightScale; + float sunShadowScale; qboolean sunShadows; vec3_t sunLight; // from the sky shader for this level - vec3_t sunAmbient; vec3_t sunDirection; frontEndCounters_t pc; diff --git a/code/renderergl2/tr_scene.c b/code/renderergl2/tr_scene.c index a22c3934..7e774185 100644 --- a/code/renderergl2/tr_scene.c +++ b/code/renderergl2/tr_scene.c @@ -360,19 +360,34 @@ void RE_RenderScene( const refdef_t *fd ) { VectorSet(tr.refdef.sunCol, 0, 0, 0); VectorSet(tr.refdef.sunAmbCol, 0, 0, 0); } - else if (r_forceSun->integer == 1) - { - float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); - tr.refdef.colorScale = r_forceSunMapLightScale->value; - VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); - VectorScale(tr.sunLight, scale * r_forceSunAmbientScale->value, tr.refdef.sunAmbCol); - } 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.sunAmbient, scale, tr.refdef.sunAmbCol); + 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); + if (r_forceSun->integer) + { + VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); + VectorScale(tr.sunLight, scale * r_forceSunAmbientScale->value, tr.refdef.sunAmbCol); + } + else + { + VectorScale(tr.sunLight, scale, tr.refdef.sunCol); + VectorScale(tr.sunLight, scale * tr.sunShadowScale, tr.refdef.sunAmbCol); + } + } } if (r_forceAutoExposure->integer) diff --git a/code/renderergl2/tr_shader.c b/code/renderergl2/tr_shader.c index 75755df8..2cb86684 100644 --- a/code/renderergl2/tr_shader.c +++ b/code/renderergl2/tr_shader.c @@ -1636,8 +1636,6 @@ static qboolean ParseShader( char **text ) a = atof( token ); VectorScale( tr.sunLight, a, tr.sunLight); - VectorSet( tr.sunAmbient, 0.0f, 0.0f, 0.0f); - token = COM_ParseExt( text, qfalse ); a = atof( token ); a = a / 180 * M_PI; @@ -1656,7 +1654,7 @@ static qboolean ParseShader( char **text ) tr.mapLightScale = atof(token); token = COM_ParseExt( text, qfalse ); - VectorScale( tr.sunLight, atof(token), tr.sunAmbient ); + tr.sunShadowScale = atof(token); } SkipRestOfLine( text ); diff --git a/opengl2-readme.txt b/opengl2-readme.txt index 2a1c5f3b..999fd385 100644 --- a/opengl2-readme.txt +++ b/opengl2-readme.txt @@ -240,21 +240,31 @@ Cvars for the sunlight and cascaded shadow maps: r_forceSunMapLightScale - Cheat. Scale map brightness by this factor when r_forceSun 1. - 0.5 - Default + 1.0 - Default r_forceSunLightScale - Cheat. Scale sun brightness by this factor when r_forceSun 1. - 0.5 - Default + 1.0 - Default r_forceSunAmbientScale - Cheat. Scale sun ambient brightness by this factor when r_forceSun 1. - 0.2 - Default + 0.5 - Default r_sunShadows - Enable sunlight and cascaded shadow maps for it on maps that support it. 0 - No. 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 look. 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: - q3gl2_sun - + q3gl2_sun + 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 @@ -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. - 1. Create your map as normal and add a 'q3gl2_sun' line after your - 'q3map_sun' line in your sky material, like so: + 1. Create your map as normal, set r_sunlightMode to 1, and add a + 'q3gl2_sun' line after your 'q3map_sun' line in your sky material, like + so: 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 sky 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_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 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 {