Added r_exposure and tweaked lighting

This commit is contained in:
Robert Beckebans 2016-01-14 00:59:41 +01:00
parent f82b700598
commit d50c93f26f
11 changed files with 1776 additions and 422 deletions

View file

@ -36,6 +36,10 @@ return
"color.vertex",
"colorProcess.pixel",
"colorProcess.vertex",
"DeepGBufferRadiosity_radiosity.pixel",
"DeepGBufferRadiosity_radiosity.vertex",
"DeepGBufferRadiosity_blur.pixel",
"DeepGBufferRadiosity_blur.vertex",
"debug_shadowmap.pixel",
"debug_shadowmap.vertex",
"depth.pixel",

View file

@ -133,7 +133,7 @@ static float dot4( float2 a, float4 b ) { return dot( float4( a, 0, 1 ), b ); }
half3 sRGBToLinearRGB( half3 rgb )
{
#if defined(USE_SRGB)
#if defined(USE_LINEAR_RGB)
return max( pow( rgb, half3( 2.2 ) ), half3( 0.0 ) );
#else
return rgb;
@ -142,7 +142,7 @@ half3 sRGBToLinearRGB( half3 rgb )
half4 sRGBAToLinearRGBA( half4 rgba )
{
#if defined(USE_SRGB)
#if defined(USE_LINEAR_RGB)
return float4( max( pow( rgba.rgb, half3( 2.2 ) ), half3( 0.0 ) ), rgba.a );
#else
return rgba;
@ -151,7 +151,7 @@ half4 sRGBAToLinearRGBA( half4 rgba )
half3 LinearRGBToSRGB( half3 rgb )
{
#if defined(USE_SRGB)
#if defined(USE_LINEAR_RGB)
return pow( rgb, half3( 1.0 ) / half3( 2.2 ) );
#else
return rgb;
@ -160,7 +160,7 @@ half3 LinearRGBToSRGB( half3 rgb )
half4 LinearRGBToSRGB( half4 rgba )
{
#if defined(USE_SRGB)
#if defined(USE_LINEAR_RGB)
rgba.rgb = pow( rgba.rgb, half3( 1.0 ) / half3( 2.2 ) );
return rgba; //pow( rgba, half4( 1.0 ) / half4( 2.2 ) );
#else

View file

@ -86,7 +86,8 @@ void main( PS_IN fragment, out PS_OUT result )
half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
halfLdotN *= halfLdotN;
half lambert = halfLdotN;
// tweak to not loose so many details
half lambert = lerp( ldotN, halfLdotN, 0.5 );
#else
half lambert = ldotN;
#endif

View file

@ -93,7 +93,8 @@ void main( PS_IN fragment, out PS_OUT result )
half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
halfLdotN *= halfLdotN;
half lambert = halfLdotN;
// tweak to not loose so many details
half lambert = lerp( ldotN, halfLdotN, 0.5 );
#else
half lambert = ldotN;
#endif

View file

@ -136,8 +136,13 @@ void main( PS_IN fragment, out PS_OUT result )
//color.rgb = color.rgb * ( float3( 0.5 ) + 6.2 * color.rgb ) / ( float3( 0.06 ) + color.rgb * ( float3( 1.7 ) + 6.2 * color.rgb ) );
#elif OPERATOR == 2
float exposure = 1.0;
float3 exposedColor = exposure * color.rgb;
// can be in range [-4.0 .. 4.0]
float exposure = rpScreenCorrectionFactor.w;
// exposure curves ranges from 0.0625 to 16.0
float3 exposedColor = exp2( exposure ) * color.rgb;
//float3 exposedColor = exposure * color.rgb;
float3 curr = ACESFilm( exposedColor );
@ -148,7 +153,7 @@ void main( PS_IN fragment, out PS_OUT result )
//float exposure = ( hdrKey / hdrAverageLuminance ) * 0.2;
//float exposure = Yr * 1.0;
float exposure = 1.0;
float exposure = rpScreenCorrectionFactor.w;
float3 exposedColor = exposure * color.rgb;
float3 curr = Uncharted2Tonemap( exposedColor );

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2014-2016 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -35,6 +36,7 @@ extern idCVar r_antiAliasing;
extern idCVar r_motionBlur;
extern idCVar r_swapInterval;
extern idCVar s_volume_dB;
extern idCVar r_exposure; // RB: use this to control HDR exposure or brightness in LDR mode
extern idCVar r_lightScale;
/*
@ -392,7 +394,7 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData
originalAntialias = r_antiAliasing.GetInteger();
originalMotionBlur = r_motionBlur.GetInteger();
originalVsync = r_swapInterval.GetInteger();
originalBrightness = r_lightScale.GetFloat();
originalBrightness = r_exposure.GetFloat();
originalVolume = s_volume_dB.GetFloat();
// RB begin
originalShadowMapping = r_useShadowMapping.GetInteger();
@ -546,9 +548,11 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustFi
// RB end
case SYSTEM_FIELD_BRIGHTNESS:
{
const float percent = LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f );
const float percent = LinearAdjust( r_exposure.GetFloat(), 0.0f, 1.0f, 0.0f, 100.0f );
const float adjusted = percent + ( float )adjustAmount;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
r_exposure.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, 0.0f, 1.0f ) );
r_lightScale.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, 2.0f, 4.0f ) );
break;
}
@ -650,7 +654,7 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
// return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
// RB end
case SYSTEM_FIELD_BRIGHTNESS:
return LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f );
return LinearAdjust( r_exposure.GetFloat(), 0.0f, 1.0f, 0.0f, 100.0f );
case SYSTEM_FIELD_VOLUME:
{
return 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) );
@ -682,7 +686,7 @@ bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataCh
{
return true;
}
if( originalBrightness != r_lightScale.GetFloat() )
if( originalBrightness != r_exposure.GetFloat() )
{
return true;
}

View file

@ -555,9 +555,9 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
src.AddDefine( "USE_HALF_LAMBERT" );
}
if( r_useSRGB.GetBool() || r_useHDR.GetBool() )
if( r_useHDR.GetBool() )
{
src.AddDefine( "USE_SRGB" );
src.AddDefine( "USE_LINEAR_RGB" );
}
// SMAA configuration

File diff suppressed because it is too large Load diff

View file

@ -149,7 +149,7 @@ idCVar r_shadowPolygonFactor( "r_shadowPolygonFactor", "0", CVAR_RENDERER | CVAR
idCVar r_subviewOnly( "r_subviewOnly", "0", CVAR_RENDERER | CVAR_BOOL, "1 = don't render main view, allowing subviews to be debugged" );
idCVar r_testGamma( "r_testGamma", "0", CVAR_RENDERER | CVAR_FLOAT, "if > 0 draw a grid pattern to test gamma levels", 0, 195 );
idCVar r_testGammaBias( "r_testGammaBias", "0", CVAR_RENDERER | CVAR_FLOAT, "if > 0 draw a grid pattern to test gamma levels" );
idCVar r_lightScale( "r_lightScale", "3", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "all light intensities are multiplied by this" );
idCVar r_lightScale( "r_lightScale", "3", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "all light intensities are multiplied by this", 0, 100 );
idCVar r_flareSize( "r_flareSize", "1", CVAR_RENDERER | CVAR_FLOAT, "scale the flare deforms from the material def" );
idCVar r_skipPrelightShadows( "r_skipPrelightShadows", "0", CVAR_RENDERER | CVAR_BOOL, "skip the dmap generated static shadow volumes" );
@ -246,10 +246,12 @@ idCVar r_shadowMapSunDepthBiasScale( "r_shadowMapSunDepthBiasScale", "0.999991",
// RB: HDR parameters
idCVar r_useHDR( "r_useHDR", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use high dynamic range rendering" );
idCVar r_hdrAutoExposure( "r_hdrAutoExposure", "1", CVAR_RENDERER | CVAR_BOOL, "EXPENSIVE: enables adapative HDR tone mapping otherwise the exposure is derived by r_exposure" );
idCVar r_hdrMinLuminance( "r_hdrMinLuminance", "0.05", CVAR_RENDERER | CVAR_FLOAT, "" );
idCVar r_hdrMaxLuminance( "r_hdrMaxLuminance", "300", CVAR_RENDERER | CVAR_FLOAT, "" );
idCVar r_hdrKey( "r_hdrKey", "1.0", CVAR_RENDERER | CVAR_FLOAT, "mid-gray 0.5 in linear RGB space (without gamma curve applied)" );
idCVar r_hdrContrastThreshold( "r_hdrContrastThreshold", "33", CVAR_RENDERER | CVAR_FLOAT, "all pixels brighter than this cause HDR bloom glares" );
idCVar r_hdrContrastDynamicThreshold( "r_hdrContrastDynamicThreshold", "33", CVAR_RENDERER | CVAR_FLOAT, "if dynamic tonemapping is on, all pixels brighter than this cause HDR bloom glares" );
idCVar r_hdrContrastStaticThreshold( "r_hdrContrastStaticThreshold", "0.5", CVAR_RENDERER | CVAR_FLOAT, "if dynamic tonemapping is off, all pixels brighter than this cause HDR bloom glares" );
idCVar r_hdrContrastOffset( "r_hdrContrastOffset", "100", CVAR_RENDERER | CVAR_FLOAT, "" );
idCVar r_hdrGlarePasses( "r_hdrGlarePasses", "8", CVAR_RENDERER | CVAR_INTEGER, "how many times the bloom blur is rendered offscreen. number should be even" );
idCVar r_hdrDebug( "r_hdrDebug", "0", CVAR_RENDERER | CVAR_FLOAT, "show scene luminance as heat map" );
@ -258,14 +260,18 @@ idCVar r_ldrContrastThreshold( "r_ldrContrastThreshold", "1.1", CVAR_RENDERER |
idCVar r_ldrContrastOffset( "r_ldrContrastOffset", "3", CVAR_RENDERER | CVAR_FLOAT, "" );
idCVar r_useFilmicPostProcessEffects( "r_useFilmicPostProcessEffects", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "apply several post process effects to mimic a filmic look" );
idCVar r_forceAmbient( "r_forceAmbient", "0.2", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
idCVar r_forceAmbient( "r_forceAmbient", "0.2", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
idCVar r_useSSGI( "r_useSSGI", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space global illumination and reflections" );
idCVar r_useSSGI( "r_useSSGI", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space global illumination and reflections" );
idCVar r_ssgiDebug( "r_ssgiDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
idCVar r_ssgiFiltering( "r_ssgiFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useSSAO( "r_useSSAO", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space ambient occlusion to darken corners" );
idCVar r_ssaoDebug( "r_ssaoDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
idCVar r_ssaoFiltering( "r_ssaoFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useHierarchicalDepthBuffer( "r_useHierarchicalDepthBuffer", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_exposure( "r_exposure", "0.5", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "HDR exposure or LDR brightness [0.0 .. 1.0]", 0.0f, 1.0f );
// RB end
const char* fileExten[3] = { "tga", "png", "jpg" };

View file

@ -1340,6 +1340,8 @@ static void RB_RenderInteractions( const drawSurf_t* surfList, const viewLight_t
}
// RB end
float lightScale = r_useHDR.GetBool() ? 3.0f : r_lightScale.GetFloat();
for( int lightStageNum = 0; lightStageNum < lightShader->GetNumStages(); lightStageNum++ )
{
const shaderStage_t* lightStage = lightShader->GetStage( lightStageNum );
@ -1350,7 +1352,6 @@ static void RB_RenderInteractions( const drawSurf_t* surfList, const viewLight_t
continue;
}
const float lightScale = r_lightScale.GetFloat();
const idVec4 lightColor(
lightScale * lightRegs[ lightStage->color.registers[0] ],
lightScale * lightRegs[ lightStage->color.registers[1] ],
@ -1756,7 +1757,7 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
{
if( fillGbuffer )
{
if( !r_useSSGI.GetBool() )
if( !r_useSSGI.GetBool() && !r_useSSAO.GetBool() )
{
return;
}
@ -1809,6 +1810,17 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
const idVec4 diffuseColor = lightColor;
const idVec4 specularColor = lightColor * 2.0f;
idVec4 ambientColor;
float ambientBoost = 1.0f;
ambientBoost += r_useSSAO.GetBool() ? 0.5f : 0.0f;
ambientBoost *= r_useHDR.GetBool() ? 1.1f : 1.0f;
ambientColor.x = r_forceAmbient.GetFloat() * ambientBoost;
ambientColor.y = r_forceAmbient.GetFloat() * ambientBoost;
ambientColor.z = r_forceAmbient.GetFloat() * ambientBoost;
ambientColor.w = 1;
renderProgManager.SetRenderParm( RENDERPARM_AMBIENT_COLOR, ambientColor.ToFloatPtr() );
// setup renderparms assuming we will be drawing trivial surfaces first
RB_SetupForFastPathInteractions( diffuseColor, specularColor );
@ -1852,7 +1864,7 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
//else
{
#if 1
if( r_useSSGI.GetBool() && fillGbuffer )
if( ( r_useSSAO.GetBool() || r_useSSGI.GetBool() ) && fillGbuffer )
{
// fill geometry buffer with normal/roughness information
if( drawSurf->jointCache )
@ -1931,15 +1943,6 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
renderProgManager.SetRenderParm( RENDERPARM_COLOR, directedColor.ToFloatPtr() );
renderProgManager.SetRenderParm( RENDERPARM_AMBIENT_COLOR, ambientColor.ToFloatPtr() );
}
#else
idVec4 ambientColor;
float ambientBoost = r_useHDR.GetBool() ? 1.5 : 1.0;
ambientColor.x = r_forceAmbient.GetFloat();
ambientColor.y = r_forceAmbient.GetFloat();
ambientColor.z = r_forceAmbient.GetFloat();
ambientColor.w = 1;
renderProgManager.SetRenderParm( RENDERPARM_AMBIENT_COLOR, ambientColor.ToFloatPtr() );
#endif
/*
@ -2113,8 +2116,7 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
renderLog.CloseBlock();
renderLog.CloseMainBlock();
#if 1
if( r_useSSGI.GetBool() && fillGbuffer )
if( ( r_useSSAO.GetBool() || r_useSSGI.GetBool() ) && fillGbuffer )
{
GL_SelectTexture( 0 );
globalImages->currentNormalsImage->Bind();
@ -2137,7 +2139,6 @@ static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs
globalImages->BindNull();
}
#endif
}
// RB end
@ -4236,88 +4237,102 @@ static void RB_CalculateAdaptation()
float newAdaptation;
float newMaximum;
curTime = Sys_Milliseconds() / 1000.0f;
// calculate the average scene luminance
globalFramebuffers.hdr64FBO->Bind();
// read back the contents
// glFinish();
glReadPixels( 0, 0, 64, 64, GL_RGBA, GL_FLOAT, image );
sum = 0.0f;
maxLuminance = 0.0f;
for( i = 0; i < ( 64 * 64 ); i += 4 )
if( !r_hdrAutoExposure.GetBool() )
{
color[0] = image[i * 4 + 0];
color[1] = image[i * 4 + 1];
color[2] = image[i * 4 + 2];
color[3] = image[i * 4 + 3];
// no dynamic exposure
luminance = ( color.x * LUMINANCE_SRGB.x + color.y * LUMINANCE_SRGB.y + color.z * LUMINANCE_SRGB.z ) + 0.0001f;
if( luminance > maxLuminance )
{
maxLuminance = luminance;
}
float logLuminance = log( luminance + 1 );
//if( logLuminance > 0 )
{
sum += luminance;
}
}
#if 0
sum /= ( 64.0f * 64.0f );
avgLuminance = exp( sum );
#else
avgLuminance = sum / ( 64.0f * 64.0f );
#endif
// the user's adapted luminance level is simulated by closing the gap between
// adapted luminance and current luminance by 2% every frame, based on a
// 30 fps rate. This is not an accurate model of human adaptation, which can
// take longer than half an hour.
if( backEnd.hdrTime > curTime )
{
backEnd.hdrTime = curTime;
}
deltaTime = curTime - backEnd.hdrTime;
//if(r_hdrMaxLuminance->value)
{
backEnd.hdrAverageLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), backEnd.hdrAverageLuminance );
avgLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), avgLuminance );
backEnd.hdrMaxLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), backEnd.hdrMaxLuminance );
maxLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), maxLuminance );
}
newAdaptation = backEnd.hdrAverageLuminance + ( avgLuminance - backEnd.hdrAverageLuminance ) * ( 1.0f - powf( 0.98f, 30.0f * deltaTime ) );
newMaximum = backEnd.hdrMaxLuminance + ( maxLuminance - backEnd.hdrMaxLuminance ) * ( 1.0f - powf( 0.98f, 30.0f * deltaTime ) );
if( !IsNAN( newAdaptation ) && !IsNAN( newMaximum ) )
{
#if 1
backEnd.hdrAverageLuminance = newAdaptation;
backEnd.hdrMaxLuminance = newMaximum;
#else
backEnd.hdrAverageLuminance = avgLuminance;
backEnd.hdrMaxLuminance = maxLuminance;
#endif
}
backEnd.hdrTime = curTime;
// calculate HDR image key
if( r_hdrKey.GetFloat() <= 0 )
{
// calculation from: Perceptual Effects in Real-time Tone Mapping - Krawczyk et al.
backEnd.hdrKey = 1.03 - ( 2.0 / ( 2.0 + ( backEnd.hdrAverageLuminance + 1.0f ) ) );
backEnd.hdrKey = r_hdrKey.GetFloat();
backEnd.hdrAverageLuminance = 1;
backEnd.hdrMaxLuminance = 1;
}
else
{
backEnd.hdrKey = r_hdrKey.GetFloat();
curTime = Sys_Milliseconds() / 1000.0f;
// calculate the average scene luminance
globalFramebuffers.hdr64FBO->Bind();
// read back the contents
// glFinish();
glReadPixels( 0, 0, 64, 64, GL_RGBA, GL_FLOAT, image );
sum = 0.0f;
maxLuminance = 0.0f;
for( i = 0; i < ( 64 * 64 ); i += 4 )
{
color[0] = image[i * 4 + 0];
color[1] = image[i * 4 + 1];
color[2] = image[i * 4 + 2];
color[3] = image[i * 4 + 3];
luminance = ( color.x * LUMINANCE_SRGB.x + color.y * LUMINANCE_SRGB.y + color.z * LUMINANCE_SRGB.z ) + 0.0001f;
if( luminance > maxLuminance )
{
maxLuminance = luminance;
}
float logLuminance = log( luminance + 1 );
//if( logLuminance > 0 )
{
sum += luminance;
}
}
#if 0
sum /= ( 64.0f * 64.0f );
avgLuminance = exp( sum );
#else
avgLuminance = sum / ( 64.0f * 64.0f );
#endif
// the user's adapted luminance level is simulated by closing the gap between
// adapted luminance and current luminance by 2% every frame, based on a
// 30 fps rate. This is not an accurate model of human adaptation, which can
// take longer than half an hour.
if( backEnd.hdrTime > curTime )
{
backEnd.hdrTime = curTime;
}
deltaTime = curTime - backEnd.hdrTime;
//if(r_hdrMaxLuminance->value)
{
backEnd.hdrAverageLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), backEnd.hdrAverageLuminance );
avgLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), avgLuminance );
backEnd.hdrMaxLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), backEnd.hdrMaxLuminance );
maxLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), maxLuminance );
}
newAdaptation = backEnd.hdrAverageLuminance + ( avgLuminance - backEnd.hdrAverageLuminance ) * ( 1.0f - powf( 0.98f, 30.0f * deltaTime ) );
newMaximum = backEnd.hdrMaxLuminance + ( maxLuminance - backEnd.hdrMaxLuminance ) * ( 1.0f - powf( 0.98f, 30.0f * deltaTime ) );
if( !IsNAN( newAdaptation ) && !IsNAN( newMaximum ) )
{
#if 1
backEnd.hdrAverageLuminance = newAdaptation;
backEnd.hdrMaxLuminance = newMaximum;
#else
backEnd.hdrAverageLuminance = avgLuminance;
backEnd.hdrMaxLuminance = maxLuminance;
#endif
}
backEnd.hdrTime = curTime;
// calculate HDR image key
#if 0
// RB: this never worked :/
if( r_hdrAutoExposure.GetBool() )
{
// calculation from: Perceptual Effects in Real-time Tone Mapping - Krawczyk et al.
backEnd.hdrKey = 1.03 - ( 2.0 / ( 2.0 + ( backEnd.hdrAverageLuminance + 1.0f ) ) );
}
else
#endif
{
backEnd.hdrKey = r_hdrKey.GetFloat();
}
}
if( r_hdrDebug.GetBool() )
@ -4380,15 +4395,18 @@ static void RB_Tonemap( const viewDef_t* viewDef )
screenCorrectionParm[0] = 1.0f;
screenCorrectionParm[1] = 1.0f;
screenCorrectionParm[2] = 1.0f;
screenCorrectionParm[3] = 1.0f;
}
else
{
screenCorrectionParm[0] = backEnd.hdrKey;
screenCorrectionParm[1] = backEnd.hdrAverageLuminance;
screenCorrectionParm[2] = backEnd.hdrMaxLuminance;
screenCorrectionParm[3] = 1.0f;
}
float exposure = ( r_exposure.GetFloat() * 2.0f - 1.0f ) * 4.0f;
//float exposure = r_exposure.GetFloat() * 2.0f;
screenCorrectionParm[3] = idMath::ClampFloat( -10.0f, 10.0f, exposure );
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
// Draw
@ -4472,7 +4490,14 @@ static void RB_Bloom( const viewDef_t* viewDef )
float overbright[4];
if( r_useHDR.GetBool() )
{
overbright[0] = r_hdrContrastThreshold.GetFloat();
if( r_hdrAutoExposure.GetBool() )
{
overbright[0] = r_hdrContrastDynamicThreshold.GetFloat();
}
else
{
overbright[0] = r_hdrContrastStaticThreshold.GetFloat();
}
overbright[1] = r_hdrContrastOffset.GetFloat();
overbright[2] = 0;
overbright[3] = 0;
@ -4535,7 +4560,7 @@ static void RB_SSAO( const viewDef_t* viewDef )
return;
}
if( r_useSSGI.GetInteger() <= 0 )
if( r_useSSAO.GetInteger() <= 0 )
{
return;
}
@ -4704,7 +4729,7 @@ static void RB_SSAO( const viewDef_t* viewDef )
}
else
{
if( r_ssgiDebug.GetInteger() <= 0 )
if( r_ssaoDebug.GetInteger() <= 0 )
{
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO | GLS_ALPHAMASK | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
}
@ -4807,7 +4832,7 @@ static void RB_SSAO( const viewDef_t* viewDef )
Framebuffer::Unbind();
}
if( r_ssgiDebug.GetInteger() <= 0 )
if( r_ssaoDebug.GetInteger() <= 0 )
{
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
}
@ -5235,14 +5260,14 @@ void RB_DrawViewInternal( const viewDef_t* viewDef, const int stereoEye )
//-------------------------------------------------
// capture the depth for the motion blur before rendering any post process surfaces that may contribute to the depth
//-------------------------------------------------
if( ( r_motionBlur.GetInteger() > 0 || r_useSSGI.GetBool() ) && !r_useHDR.GetBool() )
if( ( r_motionBlur.GetInteger() > 0 || r_useSSAO.GetBool() || r_useSSGI.GetBool() ) && !r_useHDR.GetBool() )
{
const idScreenRect& viewport = backEnd.viewDef->viewport;
globalImages->currentDepthImage->CopyDepthbuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
}
//-------------------------------------------------
// darken the scene using the screen space ambient occlusion result
// darken the scene using the screen space ambient occlusion
//-------------------------------------------------
RB_SSAO( viewDef );
//RB_SSGI( viewDef );
@ -5630,7 +5655,7 @@ void RB_PostProcess( const void* data )
return;
}
if( r_ssgiDebug.GetInteger() > 0 )
if( ( r_ssaoDebug.GetInteger() > 0 ) || ( r_ssgiDebug.GetInteger() > 0 ) )
{
return;
}

View file

@ -941,7 +941,7 @@ extern idCVar r_singleTriangle; // only draw a single triangle per primitive
extern idCVar r_logFile; // number of frames to emit GL logs
extern idCVar r_clear; // force screen clear every frame
extern idCVar r_subviewOnly; // 1 = don't render main view, allowing subviews to be debugged
extern idCVar r_lightScale; // all light intensities are multiplied by this, which is normally 2
extern idCVar r_lightScale; // all light intensities are multiplied by this, which is normally 3
extern idCVar r_flareSize; // scale the flare deforms from the material def
extern idCVar r_gamma; // changes gamma tables
@ -1089,10 +1089,12 @@ extern idCVar r_shadowMapOccluderFacing;
extern idCVar r_shadowMapRegularDepthBiasScale;
extern idCVar r_shadowMapSunDepthBiasScale;
extern idCVar r_hdrAutoExposure;
extern idCVar r_hdrMinLuminance;
extern idCVar r_hdrMaxLuminance;
extern idCVar r_hdrKey;
extern idCVar r_hdrContrastThreshold;
extern idCVar r_hdrContrastDynamicThreshold;
extern idCVar r_hdrContrastStaticThreshold;
extern idCVar r_hdrContrastOffset;
extern idCVar r_hdrGlarePasses;
extern idCVar r_hdrDebug;
@ -1106,8 +1108,13 @@ extern idCVar r_forceAmbient;
extern idCVar r_useSSGI;
extern idCVar r_ssgiDebug;
extern idCVar r_ssgiFiltering;
extern idCVar r_useSSAO;
extern idCVar r_ssaoDebug;
extern idCVar r_ssaoFiltering;
extern idCVar r_useHierarchicalDepthBuffer;
extern idCVar r_exposure;
// RB end
/*