From 6f19bff3cf0cb355ed6523ce32b9490b424946a7 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 4 Sep 2024 23:04:20 +0200 Subject: [PATCH] Wrote some debug code for capturing env probes --- neo/renderer/RenderSystem_init.cpp | 6 +----- neo/renderer/RenderWorld_envprobes.cpp | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/neo/renderer/RenderSystem_init.cpp b/neo/renderer/RenderSystem_init.cpp index 610ee3c1..a86aa0bd 100644 --- a/neo/renderer/RenderSystem_init.cpp +++ b/neo/renderer/RenderSystem_init.cpp @@ -855,7 +855,6 @@ bool R_ReadPixelsRGB8( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nvrh #endif // fix alpha - // SRS - changed to uint32_t for type consistency for( uint32_t i = 0; i < ( desc.width * desc.height ); i++ ) { data[ i * 4 + 3 ] = 0xff; @@ -970,7 +969,6 @@ bool R_ReadPixelsRGB16F( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nv } #endif - // SRS - changed to uint32_t for type consistency for( uint32_t i = 0; i < ( desc.width * desc.height ); i++ ) { outData[ i * 3 + 0 ] = data[ i * 4 + 0 ]; @@ -985,7 +983,6 @@ bool R_ReadPixelsRGB16F( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nv const idVec3 LUMINANCE_LINEAR( 0.299f, 0.587f, 0.144f ); idVec3 rgb; - // SRS - changed to uint32_t for type consistency for( uint32_t i = 0; i < ( desc.width * desc.height ); i++ ) { rgb.x = F16toF32( outData[ i * 3 + 0 ] ); @@ -1001,7 +998,7 @@ bool R_ReadPixelsRGB16F( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nv // captures within the Doom 3 main campaign usually have a luminance of ~ 0.5 - 4.0 // the threshold is a bit higher and might need to be adapted for total conversion content float luminance = rgb * LUMINANCE_LINEAR; - if( luminance > 20.0f ) + if( luminance > 30.0f ) { isCorrupted = true; break; @@ -1010,7 +1007,6 @@ bool R_ReadPixelsRGB16F( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nv if( isCorrupted ) { - // SRS - changed to uint32_t for type consistency for( uint32_t i = 0; i < ( desc.width * desc.height ); i++ ) { outData[ i * 3 + 0 ] = F32toF16( 0 ); diff --git a/neo/renderer/RenderWorld_envprobes.cpp b/neo/renderer/RenderWorld_envprobes.cpp index 2dcf1d45..9652c939 100644 --- a/neo/renderer/RenderWorld_envprobes.cpp +++ b/neo/renderer/RenderWorld_envprobes.cpp @@ -1022,6 +1022,10 @@ CONSOLE_COMMAND_SHIP( bakeEnvironmentProbes, "Bake environment probes", NULL ) byte* buffers[6]; + int areaNum = tr.primaryWorld->PointInArea( def->parms.origin ); + idVec3 point = def->parms.origin; + point.SnapInt(); + for( int j = 0; j < 6; j++ ) { ref = primary.renderView; @@ -1049,12 +1053,23 @@ CONSOLE_COMMAND_SHIP( bakeEnvironmentProbes, "Bake environment probes", NULL ) byte* floatRGB16F = NULL; - R_ReadPixelsRGB16F( deviceManager->GetDevice(), &tr.backend.GetCommonPasses(), globalImages->envprobeHDRImage->GetTextureHandle() , nvrhi::ResourceStates::RenderTarget, &floatRGB16F, captureSize, captureSize ); + //if( point.x == 0 && point.y == 64 && point.z == 56 && j == 1 ) + //{ + // floatRGB16F = NULL; + //} + + //bool validCapture = + R_ReadPixelsRGB16F( deviceManager->GetDevice(), &tr.backend.GetCommonPasses(), globalImages->envprobeHDRImage->GetTextureHandle(), nvrhi::ResourceStates::RenderTarget, &floatRGB16F, captureSize, captureSize ); #if 0 idStr testName; - testName.Format( "env/test/envprobe_%i_side_%i.exr", i, j ); + testName.Format( "env/test/%s/area%i_envprobe_%i_%i_%i_side_%i.exr", baseName.c_str(), areaNum, int( point.x ), int( point.y ), int( point.z ), j ); R_WriteEXR( testName, floatRGB16F, 3, captureSize, captureSize, "fs_basepath" ); + + if( !validCapture ) + { + common->Printf( "failed to capture side %s\n", testName.c_str() ); + } #endif buffers[ j ] = floatRGB16F; } @@ -1063,10 +1078,6 @@ CONSOLE_COMMAND_SHIP( bakeEnvironmentProbes, "Bake environment probes", NULL ) progressBar.Increment( true ); tr.takingEnvprobe = true; - int areaNum = tr.primaryWorld->PointInArea( def->parms.origin ); - idVec3 point = def->parms.origin; - point.SnapInt(); - fullname.Format( "%s/area%i_envprobe_%i_%i_%i", baseName.c_str(), areaNum, int( point.x ), int( point.y ), int( point.z ) ); fullname.ReplaceChar( '-', '_' );