Wrote some debug code for capturing env probes

This commit is contained in:
Robert Beckebans 2024-09-04 23:04:20 +02:00
parent 036318e94e
commit 6f19bff3cf
2 changed files with 18 additions and 11 deletions

View file

@ -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 );

View file

@ -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( '-', '_' );