mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Replaced r_multiSamples with r_antiAliasing to switch between SMAA, MSAA ( and TXAA future)
This commit is contained in:
parent
08f28edfb0
commit
e2e4295556
7 changed files with 124 additions and 59 deletions
|
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
const static int NUM_SYSTEM_OPTIONS_OPTIONS = 8;
|
||||
|
||||
extern idCVar r_multiSamples;
|
||||
extern idCVar r_antiAliasing;
|
||||
extern idCVar r_motionBlur;
|
||||
extern idCVar r_swapInterval;
|
||||
extern idCVar s_volume_dB;
|
||||
|
@ -389,7 +389,7 @@ idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData
|
|||
void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData()
|
||||
{
|
||||
originalFramerate = com_engineHz.GetInteger();
|
||||
originalAntialias = r_multiSamples.GetInteger();
|
||||
originalAntialias = r_antiAliasing.GetInteger();
|
||||
originalMotionBlur = r_motionBlur.GetInteger();
|
||||
originalVsync = r_swapInterval.GetInteger();
|
||||
originalBrightness = r_lightScale.GetFloat();
|
||||
|
@ -416,14 +416,16 @@ idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsRestartRequ
|
|||
*/
|
||||
bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsRestartRequired() const
|
||||
{
|
||||
if( originalAntialias != r_multiSamples.GetInteger() )
|
||||
if( originalAntialias != r_antiAliasing.GetInteger() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( originalFramerate != com_engineHz.GetInteger() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -500,10 +502,17 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustFi
|
|||
case SYSTEM_FIELD_ANTIALIASING:
|
||||
{
|
||||
// RB: disabled 16x MSAA
|
||||
static const int numValues = 4;
|
||||
static const int values[numValues] = { 0, 2, 4, 8 };
|
||||
static const int numValues = 5;
|
||||
static const int values[numValues] =
|
||||
{
|
||||
ANTI_ALIASING_NONE,
|
||||
ANTI_ALIASING_SMAA_1X,
|
||||
ANTI_ALIASING_MSAA_2X,
|
||||
ANTI_ALIASING_MSAA_4X,
|
||||
ANTI_ALIASING_MSAA_8X
|
||||
};
|
||||
// RB end
|
||||
r_multiSamples.SetInteger( AdjustOption( r_multiSamples.GetInteger(), values, numValues, adjustAmount ) );
|
||||
r_antiAliasing.SetInteger( AdjustOption( r_antiAliasing.GetInteger(), values, numValues, adjustAmount ) );
|
||||
break;
|
||||
}
|
||||
case SYSTEM_FIELD_MOTIONBLUR:
|
||||
|
@ -596,11 +605,26 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
|
|||
return "#str_swf_disabled";
|
||||
}
|
||||
case SYSTEM_FIELD_ANTIALIASING:
|
||||
if( r_multiSamples.GetInteger() == 0 )
|
||||
{
|
||||
if( r_antiAliasing.GetInteger() == 0 )
|
||||
{
|
||||
return "#str_swf_disabled";
|
||||
}
|
||||
return va( "%dx", r_multiSamples.GetInteger() );
|
||||
|
||||
static const int numValues = 5;
|
||||
static const const char* values[numValues] =
|
||||
{
|
||||
"None",
|
||||
"SMAA 1X",
|
||||
"MSAA 2X",
|
||||
"MSAA 4X",
|
||||
"MSAA 8X"
|
||||
};
|
||||
|
||||
compile_time_assert( numValues == ( ANTI_ALIASING_MSAA_8X + 1 ) );
|
||||
|
||||
return values[ r_antiAliasing.GetInteger() ];
|
||||
}
|
||||
case SYSTEM_FIELD_MOTIONBLUR:
|
||||
if( r_motionBlur.GetInteger() == 0 )
|
||||
{
|
||||
|
@ -641,7 +665,7 @@ bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataCh
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if( originalAntialias != r_multiSamples.GetInteger() )
|
||||
if( originalAntialias != r_antiAliasing.GetInteger() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,7 @@ bool idPlayerProfile::Serialize( idSerializer& ser )
|
|||
cvarDict.Delete( "r_fullscreen" );
|
||||
cvarDict.Delete( "r_vidMode" );
|
||||
cvarDict.Delete( "r_multisamples" );
|
||||
cvarDict.Delete( "r_antiAliasing" );
|
||||
cvarDict.Delete( "com_engineHz" );
|
||||
cvarSystem->SetCVarsFromDict( cvarDict );
|
||||
common->StartupVariable( NULL );
|
||||
|
|
|
@ -295,15 +295,22 @@ static void R_CheckCvars()
|
|||
}
|
||||
}
|
||||
|
||||
if( r_multiSamples.IsModified() )
|
||||
if( r_antiAliasing.IsModified() )
|
||||
{
|
||||
if( r_multiSamples.GetInteger() > 0 )
|
||||
switch( r_antiAliasing.GetInteger() )
|
||||
{
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable( GL_MULTISAMPLE );
|
||||
case ANTI_ALIASING_MSAA_2X:
|
||||
case ANTI_ALIASING_MSAA_4X:
|
||||
case ANTI_ALIASING_MSAA_8X:
|
||||
if( r_antiAliasing.GetInteger() > 0 )
|
||||
{
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
glDisable( GL_MULTISAMPLE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,15 @@ enum graphicsDriverType_t
|
|||
GLDRV_OPENGL_MESA, // fear this, it is probably the best to disable GPU skinning and run shaders in GLSL ES 1.0
|
||||
GLDRV_OPENGL_MESA_CORE_PROFILE
|
||||
};
|
||||
|
||||
enum antiAliasingMode_t
|
||||
{
|
||||
ANTI_ALIASING_NONE,
|
||||
ANTI_ALIASING_SMAA_1X,
|
||||
ANTI_ALIASING_MSAA_2X,
|
||||
ANTI_ALIASING_MSAA_4X,
|
||||
ANTI_ALIASING_MSAA_8X
|
||||
};
|
||||
// RB end
|
||||
|
||||
// Contains variables specific to the OpenGL configuration being run right now.
|
||||
|
|
|
@ -51,7 +51,7 @@ idCVar r_debugContext( "r_debugContext", "0", CVAR_RENDERER, "Enable various lev
|
|||
idCVar r_glDriver( "r_glDriver", "", CVAR_RENDERER, "\"opengl32\", etc." );
|
||||
idCVar r_skipIntelWorkarounds( "r_skipIntelWorkarounds", "0", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for Intel driver bugs" );
|
||||
// RB: disabled 16x MSAA
|
||||
idCVar r_multiSamples( "r_multiSamples", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, "number of antialiasing samples", 0, 8 );
|
||||
idCVar r_antiAliasing( "r_antiAliasing", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, " 0 = None\n 1 = SMAA 1x\n 2 = MSAA 2x\n 3 = MSAA 4x\n 4 = MSAA 8x\n", 0, ANTI_ALIASING_MSAA_8X );
|
||||
// RB end
|
||||
idCVar r_vidMode( "r_vidMode", "0", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_INTEGER, "fullscreen video mode number" );
|
||||
idCVar r_displayRefresh( "r_displayRefresh", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_NOCHEAT, "optional display refresh rate option for vid mode", 0.0f, 240.0f );
|
||||
|
@ -730,7 +730,22 @@ void R_SetNewMode( const bool fullInit )
|
|||
}
|
||||
}
|
||||
|
||||
parms.multiSamples = r_multiSamples.GetInteger();
|
||||
switch( r_antiAliasing.GetInteger() )
|
||||
{
|
||||
case ANTI_ALIASING_MSAA_2X:
|
||||
parms.multiSamples = 2;
|
||||
break;
|
||||
case ANTI_ALIASING_MSAA_4X:
|
||||
parms.multiSamples = 4;
|
||||
break;
|
||||
case ANTI_ALIASING_MSAA_8X:
|
||||
parms.multiSamples = 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == 0 )
|
||||
{
|
||||
parms.stereo = ( stereoRender_enable.GetInteger() == STEREO3D_QUAD_BUFFER );
|
||||
|
@ -776,7 +791,7 @@ safeMode:
|
|||
r_vidMode.SetInteger( 0 );
|
||||
r_fullscreen.SetInteger( 1 );
|
||||
r_displayRefresh.SetInteger( 0 );
|
||||
r_multiSamples.SetInteger( 0 );
|
||||
r_antiAliasing.SetInteger( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4948,7 +4948,7 @@ void RB_PostProcess( const void* data )
|
|||
|
||||
// only do the post process step if resolution scaling is enabled. Prevents the unnecessary copying of the framebuffer and
|
||||
// corresponding full screen quad pass.
|
||||
if( rs_enable.GetInteger() == 0 && !r_useFilmicPostProcessEffects.GetBool() ) //&& !r_useSMAA.GetInteger() )
|
||||
if( rs_enable.GetInteger() == 0 && !r_useFilmicPostProcessEffects.GetBool() && r_antiAliasing.GetInteger() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -4958,8 +4958,6 @@ void RB_PostProcess( const void* data )
|
|||
// resolve the scaled rendering to a temporary texture
|
||||
postProcessCommand_t* cmd = ( postProcessCommand_t* )data;
|
||||
const idScreenRect& viewport = cmd->viewDef->viewport;
|
||||
//globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
globalImages->smaaInputImage->CopyFramebuffer( 0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
GL_Cull( CT_TWO_SIDED );
|
||||
|
@ -4971,10 +4969,9 @@ void RB_PostProcess( const void* data )
|
|||
GL_Viewport( 0, 0, screenWidth, screenHeight );
|
||||
GL_Scissor( 0, 0, screenWidth, screenHeight );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->smaaInputImage->Bind();
|
||||
|
||||
// SMAA
|
||||
int aaMode = r_antiAliasing.GetInteger();
|
||||
if( aaMode == ANTI_ALIASING_SMAA_1X )
|
||||
{
|
||||
/*
|
||||
* The shader has three passes, chained together as follows:
|
||||
|
@ -4994,6 +4991,8 @@ void RB_PostProcess( const void* data )
|
|||
* |output|
|
||||
*/
|
||||
|
||||
globalImages->smaaInputImage->CopyFramebuffer( 0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
||||
// set SMAA_RT_METRICS = rpScreenCorrectionFactor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / glConfig.nativeScreenWidth;
|
||||
|
@ -5007,6 +5006,9 @@ void RB_PostProcess( const void* data )
|
|||
glClearColor( 0, 0, 0, 0 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->smaaInputImage->Bind();
|
||||
|
||||
renderProgManager.BindShader_SMAA_EdgeDetection();
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
|
@ -5051,41 +5053,46 @@ void RB_PostProcess( const void* data )
|
|||
}
|
||||
|
||||
#if 1
|
||||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->grainImage1->Bind();
|
||||
|
||||
renderProgManager.BindShader_PostProcess();
|
||||
|
||||
const static int GRAIN_SIZE = 128;
|
||||
|
||||
// screen power of two correction factor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[1] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[2] = 1.0f;
|
||||
screenCorrectionParm[3] = 1.0f;
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
||||
float jitterTexOffset[4];
|
||||
if( r_shadowMapRandomizeJitter.GetBool() )
|
||||
if( r_useFilmicPostProcessEffects.GetBool() )
|
||||
{
|
||||
jitterTexOffset[0] = ( rand() & 255 ) / 255.0;
|
||||
jitterTexOffset[1] = ( rand() & 255 ) / 255.0;
|
||||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->currentRenderImage->Bind();
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->grainImage1->Bind();
|
||||
|
||||
renderProgManager.BindShader_PostProcess();
|
||||
|
||||
const static int GRAIN_SIZE = 128;
|
||||
|
||||
// screen power of two correction factor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[1] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[2] = 1.0f;
|
||||
screenCorrectionParm[3] = 1.0f;
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
||||
float jitterTexOffset[4];
|
||||
if( r_shadowMapRandomizeJitter.GetBool() )
|
||||
{
|
||||
jitterTexOffset[0] = ( rand() & 255 ) / 255.0;
|
||||
jitterTexOffset[1] = ( rand() & 255 ) / 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
}
|
||||
jitterTexOffset[2] = 0.0f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
// Draw
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
}
|
||||
else
|
||||
{
|
||||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
}
|
||||
jitterTexOffset[2] = 0.0f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
// Draw
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
#endif
|
||||
|
||||
GL_SelectTexture( 2 );
|
||||
|
|
|
@ -921,7 +921,7 @@ extern idCVar r_skipIntelWorkarounds; // skip work arounds for Intel driver bug
|
|||
extern idCVar r_vidMode; // video mode number
|
||||
extern idCVar r_displayRefresh; // optional display refresh rate option for vid mode
|
||||
extern idCVar r_fullscreen; // 0 = windowed, 1 = full screen
|
||||
extern idCVar r_multiSamples; // number of antialiasing samples
|
||||
extern idCVar r_antiAliasing; // anti aliasing mode, SMAA, TXAA, MSAA etc.
|
||||
|
||||
extern idCVar r_znear; // near Z clip plane
|
||||
|
||||
|
@ -1092,6 +1092,8 @@ extern idCVar r_ldrContrastOffset;
|
|||
|
||||
extern idCVar r_useFilmicPostProcessEffects;
|
||||
extern idCVar r_forceAmbient;
|
||||
|
||||
extern idCVar r_antiAliasing;
|
||||
// RB end
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue