Added graphics option to make soft shadows optional

This commit is contained in:
Robert Beckebans 2014-05-15 12:14:37 +02:00
parent c300acd507
commit 42874cfd05
6 changed files with 51 additions and 5 deletions

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2014 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -1361,6 +1362,9 @@ public:
SYSTEM_FIELD_VSYNC, SYSTEM_FIELD_VSYNC,
SYSTEM_FIELD_ANTIALIASING, SYSTEM_FIELD_ANTIALIASING,
SYSTEM_FIELD_MOTIONBLUR, SYSTEM_FIELD_MOTIONBLUR,
// RB begin
SYSTEM_FIELD_SHADOWMAPPING,
// RB end
SYSTEM_FIELD_LODBIAS, SYSTEM_FIELD_LODBIAS,
SYSTEM_FIELD_BRIGHTNESS, SYSTEM_FIELD_BRIGHTNESS,
SYSTEM_FIELD_VOLUME, SYSTEM_FIELD_VOLUME,
@ -1393,6 +1397,9 @@ public:
int originalVsync; int originalVsync;
float originalBrightness; float originalBrightness;
float originalVolume; float originalVolume;
// RB begin
int originalShadowMapping;
// RB end
idList<vidMode_t> modeList; idList<vidMode_t> modeList;
}; };

View file

@ -110,6 +110,16 @@ void idMenuScreen_Shell_SystemOptions::Initialize( idMenuHandler* data )
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_MOTIONBLUR ); control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_MOTIONBLUR );
options->AddChild( control ); options->AddChild( control );
// RB begin
control = new( TAG_SWF ) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "Soft Shadows" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_SHADOWMAPPING );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_SHADOWMAPPING );
options->AddChild( control );
// RB end
control = new( TAG_SWF ) idMenuWidget_ControlButton(); control = new( TAG_SWF ) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR ); control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_swf_lodbias" ); control->SetLabel( "#str_swf_lodbias" );
@ -384,6 +394,9 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData
originalVsync = r_swapInterval.GetInteger(); originalVsync = r_swapInterval.GetInteger();
originalBrightness = r_lightScale.GetFloat(); originalBrightness = r_lightScale.GetFloat();
originalVolume = s_volume_dB.GetFloat(); originalVolume = s_volume_dB.GetFloat();
// RB begin
originalShadowMapping = r_useShadowMapping.GetInteger();
// RB end
const int fullscreen = r_fullscreen.GetInteger(); const int fullscreen = r_fullscreen.GetInteger();
if( fullscreen > 0 ) if( fullscreen > 0 )
@ -498,6 +511,15 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustFi
r_motionBlur.SetInteger( AdjustOption( r_motionBlur.GetInteger(), values, numValues, adjustAmount ) ); r_motionBlur.SetInteger( AdjustOption( r_motionBlur.GetInteger(), values, numValues, adjustAmount ) );
break; break;
} }
// RB begin
case SYSTEM_FIELD_SHADOWMAPPING:
{
static const int numValues = 2;
static const int values[numValues] = { 0, 1 };
r_useShadowMapping.SetInteger( AdjustOption( r_useShadowMapping.GetInteger(), values, numValues, adjustAmount ) );
break;
}
// RB end
case SYSTEM_FIELD_LODBIAS: case SYSTEM_FIELD_LODBIAS:
{ {
const float percent = LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f ); const float percent = LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
@ -583,6 +605,17 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
return "#str_swf_disabled"; return "#str_swf_disabled";
} }
return va( "%dx", idMath::IPow( 2, r_motionBlur.GetInteger() ) ); return va( "%dx", idMath::IPow( 2, r_motionBlur.GetInteger() ) );
// RB begin
case SYSTEM_FIELD_SHADOWMAPPING:
if( r_useShadowMapping.GetInteger() == 1 )
{
return "#str_swf_enabled";
}
else
{
return "#str_swf_disabled";
}
// RB end
case SYSTEM_FIELD_LODBIAS: case SYSTEM_FIELD_LODBIAS:
return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f ); return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
case SYSTEM_FIELD_BRIGHTNESS: case SYSTEM_FIELD_BRIGHTNESS:
@ -626,5 +659,11 @@ bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataCh
{ {
return true; return true;
} }
// RB begin
if( originalShadowMapping != r_useShadowMapping.GetInteger() )
{
return true;
}
// RB end
return false; return false;
} }

View file

@ -311,7 +311,7 @@ static void R_CheckCvars()
case GLDRV_OPENGL_ES2: case GLDRV_OPENGL_ES2:
case GLDRV_OPENGL_ES3: case GLDRV_OPENGL_ES3:
case GLDRV_OPENGL_MESA: case GLDRV_OPENGL_MESA:
r_useShadowMapping.SetBool( false ); r_useShadowMapping.SetInteger( 0 );
break; break;
default: default:

View file

@ -213,7 +213,7 @@ idCVar stereoRender_deGhost( "stereoRender_deGhost", "0.05", CVAR_FLOAT | CVAR_A
idCVar r_useVirtualScreenResolution( "r_useVirtualScreenResolution", "1", CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE, "do 2D rendering at 640x480 and stretch to the current resolution" ); idCVar r_useVirtualScreenResolution( "r_useVirtualScreenResolution", "1", CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE, "do 2D rendering at 640x480 and stretch to the current resolution" );
// RB: shadow mapping parameters // RB: shadow mapping parameters
idCVar r_useShadowMapping( "r_useShadowMapping", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use shadow mapping instead of stencil shadows" ); idCVar r_useShadowMapping( "r_useShadowMapping", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, "use shadow mapping instead of stencil shadows" );
idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVAR_FLOAT, "oversize FOV for point light side matching" ); idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVAR_FLOAT, "oversize FOV for point light side matching" );
idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" ); idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" );
idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 ); idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 );

View file

@ -2653,14 +2653,14 @@ static void RB_ShadowMapPass( const drawSurf_t* drawSurfs, const viewLight_t* vL
uint64 surfGLState = 0; uint64 surfGLState = 0;
// set polygon offset if necessary // set polygon offset if necessary
if( shader->TestMaterialFlag( MF_POLYGONOFFSET ) ) if( shader && shader->TestMaterialFlag( MF_POLYGONOFFSET ) )
{ {
surfGLState |= GLS_POLYGON_OFFSET; surfGLState |= GLS_POLYGON_OFFSET;
GL_PolygonOffset( r_offsetFactor.GetFloat(), r_offsetUnits.GetFloat() * shader->GetPolygonOffset() ); GL_PolygonOffset( r_offsetFactor.GetFloat(), r_offsetUnits.GetFloat() * shader->GetPolygonOffset() );
} }
#if 1 #if 1
if( shader->Coverage() == MC_PERFORATED ) if( shader && shader->Coverage() == MC_PERFORATED )
{ {
// perforated surfaces may have multiple alpha tested stages // perforated surfaces may have multiple alpha tested stages
for( int stage = 0; stage < shader->GetNumStages(); stage++ ) for( int stage = 0; stage < shader->GetNumStages(); stage++ )