mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Small bugfixes and r_useHDR 1 is now fixed for OpenGL
This commit is contained in:
parent
6bad4df47e
commit
03c5e0273b
9 changed files with 73 additions and 72 deletions
|
@ -150,7 +150,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float3 reflectionVector = globalNormal * dot3( globalView, globalNormal );
|
||||
reflectionVector = normalize( ( reflectionVector * 2.0f ) - globalView );
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
// parallax box correction using portal area bounds
|
||||
float hitScale = 0.0;
|
||||
float3 bounds[2];
|
||||
|
@ -368,6 +368,12 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float3 radiance = textureLod( samp8, normalizedOctCoordZeroOne, mip ).rgb;
|
||||
//radiance = float3( 0.0 );
|
||||
|
||||
// RB: HACK dim down room radiance by better local irradiance brightness
|
||||
//float luma = PhotoLuma( irradiance );
|
||||
//float luma = dot( irradiance, LUMINANCE_LINEAR.rgb );
|
||||
//float luma = length( irradiance.rgb );
|
||||
//radiance *= ( luma * rpSpecularModifier.x * 3.0 );
|
||||
|
||||
float2 envBRDF = texture( samp3, float2( max( vDotN, 0.0 ), roughness ) ).rg;
|
||||
|
||||
#if 0
|
||||
|
@ -388,6 +394,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
#endif
|
||||
|
||||
half3 lightColor = sRGBToLinearRGB( rpAmbientColor.rgb );
|
||||
//half3 lightColor = ( rpAmbientColor.rgb );
|
||||
|
||||
//result.color.rgb = diffuseLight;
|
||||
//result.color.rgb = diffuseLight * lightColor;
|
||||
|
|
|
@ -150,7 +150,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float3 reflectionVector = globalNormal * dot3( globalView, globalNormal );
|
||||
reflectionVector = normalize( ( reflectionVector * 2.0f ) - globalView );
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
// parallax box correction using portal area bounds
|
||||
float hitScale = 0.0;
|
||||
float3 bounds[2];
|
||||
|
@ -266,7 +266,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float specAO = ComputeSpecularAO( vDotN, ao, roughness );
|
||||
float3 specularLight = radiance * ( kS * envBRDF.x + float3( envBRDF.y ) ) * specAO * ( rpSpecularModifier.xyz * 0.5 );
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
// Marmoset Horizon Fade trick
|
||||
const half horizonFade = 1.3;
|
||||
half horiz = saturate( 1.0 + horizonFade * saturate( dot3( reflectionVector, globalNormal ) ) );
|
||||
|
@ -275,11 +275,12 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
#endif
|
||||
|
||||
half3 lightColor = sRGBToLinearRGB( rpAmbientColor.rgb );
|
||||
//half3 lightColor = ( rpAmbientColor.rgb );
|
||||
|
||||
//result.color.rgb = diffuseLight;
|
||||
//result.color.rgb = diffuseLight * lightColor;
|
||||
//result.color.rgb = specularLight;
|
||||
result.color.rgb = ( diffuseLight + specularLight ) * lightColor * fragment.color.rgb;
|
||||
result.color.rgb = ( diffuseLight + specularLight * horiz ) * lightColor * fragment.color.rgb;
|
||||
//result.color.rgb = localNormal.xyz * 0.5 + 0.5;
|
||||
//result.color.rgb = float3( ao );
|
||||
result.color.w = fragment.color.a;
|
||||
|
|
|
@ -615,70 +615,62 @@ void idImage::AllocImage()
|
|||
GL_CheckErrors();
|
||||
PurgeImage();
|
||||
|
||||
int sRGB = r_useSRGB.GetInteger();
|
||||
|
||||
switch( opts.format )
|
||||
{
|
||||
case FMT_RGBA8:
|
||||
//internalFormat = GL_RGBA8;
|
||||
//internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
internalFormat = GL_RGBA8;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_XRGB8:
|
||||
internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB : GL_RGB;
|
||||
internalFormat = GL_RGB;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_RGB565:
|
||||
//internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB : GL_RGB;
|
||||
internalFormat = GL_RGB;
|
||||
dataFormat = GL_RGB;
|
||||
dataType = GL_UNSIGNED_SHORT_5_6_5;
|
||||
break;
|
||||
|
||||
case FMT_ALPHA:
|
||||
#if 1
|
||||
if( ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) )
|
||||
{
|
||||
internalFormat = GL_SRGB;
|
||||
dataFormat = GL_RED;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
internalFormat = GL_R8;
|
||||
dataFormat = GL_RED;
|
||||
}
|
||||
internalFormat = GL_R8;
|
||||
dataFormat = GL_RED;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_L8A8:
|
||||
internalFormat = GL_RG8;
|
||||
dataFormat = GL_RG;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_LUM8:
|
||||
internalFormat = GL_R8;
|
||||
dataFormat = GL_RED;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_INT8:
|
||||
internalFormat = GL_R8;
|
||||
dataFormat = GL_RED;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_DXT1:
|
||||
internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
//internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_DXT5:
|
||||
internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) && opts.colorFormat != CFM_YCOCG_DXT5 && opts.colorFormat != CFM_NORMAL_DXT5 ) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
//internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case FMT_DEPTH:
|
||||
internalFormat = GL_DEPTH_COMPONENT;
|
||||
dataFormat = GL_DEPTH_COMPONENT;
|
||||
|
@ -731,7 +723,6 @@ void idImage::AllocImage()
|
|||
internalFormat = GL_R11F_G11F_B10F;
|
||||
dataFormat = GL_RGB;
|
||||
dataType = GL_UNSIGNED_INT_10F_11F_11F_REV;
|
||||
//dataType = GL_FLOAT;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -263,10 +263,6 @@ static void R_CheckPortableExtensions()
|
|||
glConfig.seamlessCubeMapAvailable = GLEW_ARB_seamless_cube_map != 0;
|
||||
r_useSeamlessCubeMap.SetModified(); // the CheckCvars() next frame will enable / disable it
|
||||
|
||||
// GL_ARB_framebuffer_sRGB
|
||||
glConfig.sRGBFramebufferAvailable = GLEW_ARB_framebuffer_sRGB != 0;
|
||||
r_useSRGB.SetModified(); // the CheckCvars() next frame will enable / disable it
|
||||
|
||||
// GL_ARB_vertex_buffer_object
|
||||
if( glConfig.driverType == GLDRV_OPENGL_MESA_CORE_PROFILE )
|
||||
{
|
||||
|
@ -1407,21 +1403,6 @@ void idRenderBackend::GL_Clear( bool color, bool depth, bool stencil, byte stenc
|
|||
glClear( clearFlags );
|
||||
|
||||
// RB begin
|
||||
/*
|
||||
if( r_useHDR.GetBool() && clearHDR && globalFramebuffers.hdrFBO != NULL )
|
||||
{
|
||||
bool isDefaultFramebufferActive = Framebuffer::IsDefaultFramebufferActive();
|
||||
|
||||
globalFramebuffers.hdrFBO->Bind();
|
||||
glClear( clearFlags );
|
||||
|
||||
if( isDefaultFramebufferActive )
|
||||
{
|
||||
Framebuffer::Unbind();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if( r_useHDR.GetBool() && clearHDR )
|
||||
{
|
||||
bool isDefaultFramebufferActive = Framebuffer::IsDefaultFramebufferActive();
|
||||
|
@ -1518,22 +1499,6 @@ void idRenderBackend::CheckCVars()
|
|||
}
|
||||
}
|
||||
|
||||
if( r_useSRGB.IsModified() )
|
||||
{
|
||||
r_useSRGB.ClearModified();
|
||||
if( glConfig.sRGBFramebufferAvailable )
|
||||
{
|
||||
if( r_useSRGB.GetBool() && r_useSRGB.GetInteger() != 3 )
|
||||
{
|
||||
glEnable( GL_FRAMEBUFFER_SRGB );
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable( GL_FRAMEBUFFER_SRGB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( r_antiAliasing.IsModified() )
|
||||
{
|
||||
switch( r_antiAliasing.GetInteger() )
|
||||
|
|
|
@ -1058,7 +1058,6 @@ extern idCVar r_useShadowDepthBounds; // use depth bounds test on individual sh
|
|||
extern idCVar r_useShadowMapping; // use shadow mapping instead of stencil shadows
|
||||
extern idCVar r_useHalfLambertLighting; // use Half-Lambert lighting instead of classic Lambert
|
||||
extern idCVar r_useHDR;
|
||||
extern idCVar r_useSRGB;
|
||||
extern idCVar r_useSeamlessCubeMap;
|
||||
// RB end
|
||||
|
||||
|
@ -1451,6 +1450,14 @@ public:
|
|||
tics = 0;
|
||||
nextTicCount = 0;
|
||||
}
|
||||
|
||||
void Reset( int expected )
|
||||
{
|
||||
expectedCount = expected;
|
||||
count = 0;
|
||||
tics = 0;
|
||||
nextTicCount = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -199,7 +199,6 @@ struct glconfig_t
|
|||
bool anisotropicFilterAvailable;
|
||||
bool textureLODBiasAvailable;
|
||||
bool seamlessCubeMapAvailable;
|
||||
bool sRGBFramebufferAvailable;
|
||||
bool vertexBufferObjectAvailable;
|
||||
bool mapBufferRangeAvailable;
|
||||
bool vertexArrayObjectAvailable;
|
||||
|
|
|
@ -86,7 +86,6 @@ idCVar r_useNodeCommonChildren( "r_useNodeCommonChildren", "1", CVAR_RENDERER |
|
|||
idCVar r_useShadowSurfaceScissor( "r_useShadowSurfaceScissor", "1", CVAR_RENDERER | CVAR_BOOL, "scissor shadows by the scissor rect of the interaction surfaces" );
|
||||
idCVar r_useCachedDynamicModels( "r_useCachedDynamicModels", "1", CVAR_RENDERER | CVAR_BOOL, "cache snapshots of dynamic models" );
|
||||
idCVar r_useSeamlessCubeMap( "r_useSeamlessCubeMap", "1", CVAR_RENDERER | CVAR_BOOL, "use ARB_seamless_cube_map if available" );
|
||||
idCVar r_useSRGB( "r_useSRGB", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "1 = both texture and framebuffer, 2 = framebuffer only, 3 = texture only" );
|
||||
idCVar r_maxAnisotropicFiltering( "r_maxAnisotropicFiltering", "8", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, "limit aniso filtering" );
|
||||
idCVar r_useTrilinearFiltering( "r_useTrilinearFiltering", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "Extra quality filtering" );
|
||||
// RB: not used anymore
|
||||
|
@ -262,9 +261,9 @@ idCVar r_shadowMapSunDepthBiasScale( "r_shadowMapSunDepthBiasScale", "0.999991",
|
|||
|
||||
// RB: HDR parameters
|
||||
#if defined( USE_VULKAN )
|
||||
idCVar r_useHDR( "r_useHDR", "0", CVAR_RENDERER | CVAR_ROM | CVAR_STATIC | CVAR_BOOL, "use high dynamic range rendering" );
|
||||
idCVar r_useHDR( "r_useHDR", "0", CVAR_RENDERER | CVAR_ROM | CVAR_STATIC | CVAR_BOOL, "Can't be changed, is broken on Vulkan backend" );
|
||||
#else
|
||||
idCVar r_useHDR( "r_useHDR", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use high dynamic range rendering" );
|
||||
idCVar r_useHDR( "r_useHDR", "1", CVAR_RENDERER | CVAR_ROM | CVAR_STATIC | CVAR_BOOL, "Can't be changed: Use high dynamic range rendering" );
|
||||
#endif
|
||||
|
||||
idCVar r_hdrAutoExposure( "r_hdrAutoExposure", "0", CVAR_RENDERER | CVAR_BOOL, "EXPENSIVE: enables adapative HDR tone mapping otherwise the exposure is derived by r_exposure" );
|
||||
|
|
|
@ -95,7 +95,7 @@ void LightGrid::SetupLightGrid( const idBounds& bounds, const char* mapName, con
|
|||
{
|
||||
lightGridPoints.SetNum( numGridPoints );
|
||||
|
||||
idLib::Printf( "area %i (%i x %i x %i) = %i grid points \n", area, lightGridBounds[0], lightGridBounds[1], lightGridBounds[2], numGridPoints );
|
||||
idLib::Printf( "\narea %i (%i x %i x %i) = %i grid points \n", area, lightGridBounds[0], lightGridBounds[1], lightGridBounds[2], numGridPoints );
|
||||
idLib::Printf( "area %i grid size (%i %i %i)\n", area, ( int )lightGridSize[0], ( int )lightGridSize[1], ( int )lightGridSize[2] );
|
||||
idLib::Printf( "area %i grid bounds (%i %i %i)\n", area, ( int )lightGridBounds[0], ( int )lightGridBounds[1], ( int )lightGridBounds[2] );
|
||||
idLib::Printf( "area %i %9u x %" PRIuSIZE " = lightGridSize = (%.2fMB)\n", area, numGridPoints, sizeof( lightGridPoint_t ), ( float )( lightGridPoints.MemoryUsed() ) / ( 1024.0f * 1024.0f ) );
|
||||
|
@ -226,6 +226,21 @@ idVec3 LightGrid::GetProbeIndexDebugColor( const int probeIndex )
|
|||
return GetGridCoordDebugColor( gridCoord );
|
||||
}
|
||||
|
||||
int LightGrid::CountValidGridPoints() const
|
||||
{
|
||||
int validCount = 0;
|
||||
|
||||
for( int i = 0; i < lightGridPoints.Num(); i += 1 )
|
||||
{
|
||||
if( lightGridPoints[i].valid > 0 )
|
||||
{
|
||||
validCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return validCount;
|
||||
}
|
||||
|
||||
void LightGrid::CalculateLightGridPointPositions( const idRenderWorld* world, int area )
|
||||
{
|
||||
// calculate grid point positions
|
||||
|
@ -368,12 +383,19 @@ void idRenderWorldLocal::SetupLightGrid()
|
|||
}
|
||||
else
|
||||
{
|
||||
int totalGridPoints = 0;
|
||||
|
||||
for( int i = 0; i < numPortalAreas; i++ )
|
||||
{
|
||||
portalArea_t* area = &portalAreas[i];
|
||||
|
||||
area->lightGrid.SetupLightGrid( area->globalBounds, mapName, this, i, -1 );
|
||||
|
||||
totalGridPoints += area->lightGrid.CountValidGridPoints();
|
||||
}
|
||||
|
||||
idLib::Printf( "----------------------------------\n" );
|
||||
idLib::Printf( "Total valid light grid points %i\n", totalGridPoints );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,7 +649,7 @@ void idRenderWorldLocal::ParseLightGridPoints( idLexer* src, idFile* fileOut )
|
|||
|
||||
area->lightGrid.lightGridPoints.SetNum( numLightGridPoints );
|
||||
|
||||
idLib::Printf( "area %i (%i x %i x %i) = %i grid points \n", areaIndex, area->lightGrid.lightGridBounds[0], area->lightGrid.lightGridBounds[1], area->lightGrid.lightGridBounds[2], numLightGridPoints );
|
||||
idLib::Printf( "\narea %i (%i x %i x %i) = %i grid points \n", areaIndex, area->lightGrid.lightGridBounds[0], area->lightGrid.lightGridBounds[1], area->lightGrid.lightGridBounds[2], numLightGridPoints );
|
||||
idLib::Printf( "area %i grid size (%i %i %i)\n", areaIndex, ( int )area->lightGrid.lightGridSize[0], ( int )area->lightGrid.lightGridSize[1], ( int )area->lightGrid.lightGridSize[2] );
|
||||
idLib::Printf( "area %i grid bounds (%i %i %i)\n", areaIndex, ( int )area->lightGrid.lightGridBounds[0], ( int )area->lightGrid.lightGridBounds[1], ( int )area->lightGrid.lightGridBounds[2] );
|
||||
idLib::Printf( "area %i %9u x %" PRIuSIZE " = lightGridSize = (%.2fMB)\n", areaIndex, numLightGridPoints, sizeof( lightGridPoint_t ), ( float )( area->lightGrid.lightGridPoints.MemoryUsed() ) / ( 1024.0f * 1024.0f ) );
|
||||
|
@ -695,7 +717,7 @@ void idRenderWorldLocal::ReadBinaryLightGridPoints( idFile* file )
|
|||
|
||||
area->lightGrid.lightGridPoints.SetNum( numLightGridPoints );
|
||||
|
||||
idLib::Printf( "area %i (%i x %i x %i) = %i grid points \n", areaIndex, area->lightGrid.lightGridBounds[0], area->lightGrid.lightGridBounds[1], area->lightGrid.lightGridBounds[2], numLightGridPoints );
|
||||
idLib::Printf( "\narea %i (%i x %i x %i) = %i grid points \n", areaIndex, area->lightGrid.lightGridBounds[0], area->lightGrid.lightGridBounds[1], area->lightGrid.lightGridBounds[2], numLightGridPoints );
|
||||
idLib::Printf( "area %i grid size (%i %i %i)\n", areaIndex, ( int )area->lightGrid.lightGridSize[0], ( int )area->lightGrid.lightGridSize[1], ( int )area->lightGrid.lightGridSize[2] );
|
||||
idLib::Printf( "area %i grid bounds (%i %i %i)\n", areaIndex, ( int )area->lightGrid.lightGridBounds[0], ( int )area->lightGrid.lightGridBounds[1], ( int )area->lightGrid.lightGridBounds[2] );
|
||||
idLib::Printf( "area %i %9u x %" PRIuSIZE " = lightGridSize = (%.2fMB)\n", areaIndex, numLightGridPoints, sizeof( lightGridPoint_t ), ( float )( area->lightGrid.lightGridPoints.MemoryUsed() ) / ( 1024.0f * 1024.0f ) );
|
||||
|
@ -1099,6 +1121,7 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
// CAPTURE SCENE LIGHTING TO CUBEMAPS
|
||||
//--------------------------------------------
|
||||
|
||||
int totalStart = Sys_Milliseconds();
|
||||
|
||||
for( int a = 0; a < tr.primaryWorld->NumAreas(); a++ )
|
||||
{
|
||||
|
@ -1205,7 +1228,7 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
|
||||
if( !useThreads )
|
||||
{
|
||||
progressBar.Reset();
|
||||
progressBar.Reset( tr.lightGridJobs.Num() );
|
||||
progressBar.Start();
|
||||
}
|
||||
|
||||
|
@ -1301,6 +1324,13 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
int totalEnd = Sys_Milliseconds();
|
||||
|
||||
common->Printf( "Baked light grid irradiance in %5.1f minutes\n\n", ( totalEnd - totalStart ) / ( 1000.0f * 60 ) );
|
||||
|
||||
// everything went ok so let's save the configurations to disc
|
||||
// so we can load the texture atlases with the correct subdivisions next time
|
||||
filename.Format( "%s.lightgrid", baseName.c_str() );
|
||||
tr.primaryWorld->WriteLightGridsToFile( filename );
|
||||
}
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
idVec3 GetGridCoordDebugColor( int gridCoord[3] );
|
||||
idVec3 GetProbeIndexDebugColor( const int probeIndex );
|
||||
|
||||
int CountValidGridPoints() const;
|
||||
|
||||
idImage* GetIrradianceImage() const
|
||||
{
|
||||
return irradianceImage;
|
||||
|
|
Loading…
Reference in a new issue