mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
Added cacheGlobalIlluminationData cmd to turn env/maps/*.exr into .bimage files
This commit is contained in:
parent
c6f3688dbf
commit
e6a6a40d68
4 changed files with 74 additions and 9 deletions
|
@ -762,7 +762,7 @@ ID_TIME_T idBinaryImage::WriteGeneratedFile( ID_TIME_T sourceFileTime )
|
|||
idLib::Warning( "idBinaryImage: Could not open file '%s'", binaryFileName.c_str() );
|
||||
return FILE_NOT_FOUND_TIMESTAMP;
|
||||
}
|
||||
idLib::Printf( "Writing %s: %ix%i\n", binaryFileName.c_str(), fileData.width, fileData.height );
|
||||
//idLib::Printf( "Writing %s: %ix%i\n", binaryFileName.c_str(), fileData.width, fileData.height );
|
||||
|
||||
fileData.headerMagic = BIMAGE_MAGIC;
|
||||
fileData.sourceFileTime = sourceFileTime;
|
||||
|
|
|
@ -512,12 +512,15 @@ void R_WriteEXR( const char* filename, const void* data, int channelsPerPixel, i
|
|||
|
||||
class idImageManager
|
||||
{
|
||||
friend class idImage;
|
||||
|
||||
public:
|
||||
|
||||
idImageManager()
|
||||
{
|
||||
insideLevelLoad = false;
|
||||
preloadingMapImages = false;
|
||||
cacheImages = false;
|
||||
commandList = nullptr;
|
||||
}
|
||||
|
||||
|
@ -600,10 +603,6 @@ public:
|
|||
idImage* taaFeedback1Image;
|
||||
idImage* taaFeedback2Image;
|
||||
idImage* bloomRenderImage[2];
|
||||
//idImage* glowImage[2]; // contains any glowable surface information.
|
||||
//idImage* glowDepthImage[2];
|
||||
//idImage* accumTransparencyImage;
|
||||
//idImage* revealTransparencyImage;
|
||||
idImage* envprobeHDRImage;
|
||||
idImage* envprobeDepthImage;
|
||||
idImage* heatmap5Image;
|
||||
|
@ -643,13 +642,18 @@ public:
|
|||
bool ExcludePreloadImage( const char* name );
|
||||
|
||||
idList<idImage*, TAG_IDLIB_LIST_IMAGE> images;
|
||||
private:
|
||||
idHashIndex imageHash;
|
||||
|
||||
static void CacheGlobalIlluminationData_f( const idCmdArgs& args ); // RB
|
||||
static void R_ListImages_f( const idCmdArgs& args );
|
||||
|
||||
// Transient list of images to load on the main thread to the gpu. Freed after images are loaded.
|
||||
idList<idImage*, TAG_IDLIB_LIST_IMAGE> imagesToLoad;
|
||||
|
||||
bool insideLevelLoad; // don't actually load images now
|
||||
bool preloadingMapImages; // unless this is set
|
||||
bool cacheImages; // similar to preload but surpresses prints
|
||||
|
||||
nvrhi::CommandListHandle commandList;
|
||||
};
|
||||
|
|
|
@ -137,7 +137,7 @@ static int R_QsortImageName( const void* a, const void* b )
|
|||
R_ListImages_f
|
||||
===============
|
||||
*/
|
||||
void R_ListImages_f( const idCmdArgs& args )
|
||||
void idImageManager::R_ListImages_f( const idCmdArgs& args )
|
||||
{
|
||||
int i, partialSize;
|
||||
idImage* image;
|
||||
|
@ -770,6 +770,7 @@ void idImageManager::Init()
|
|||
CreateIntrinsicImages();
|
||||
|
||||
cmdSystem->AddCommand( "reloadImages", R_ReloadImages_f, CMD_FL_RENDERER, "reloads images" );
|
||||
cmdSystem->AddCommand( "cacheGlobalIlluminationData", CacheGlobalIlluminationData_f, CMD_FL_RENDERER, "turn env/maps/*.exr files into .bimage files" );
|
||||
#endif
|
||||
cmdSystem->AddCommand( "listImages", R_ListImages_f, CMD_FL_RENDERER, "lists images" );
|
||||
cmdSystem->AddCommand( "combineCubeImages", R_CombineCubeImages_f, CMD_FL_RENDERER, "combines six images for roq compression" );
|
||||
|
@ -1108,3 +1109,52 @@ void idImageManager::LoadDeferredImages( nvrhi::ICommandList* _commandList )
|
|||
|
||||
globalImages->imagesToLoad.Clear();
|
||||
}
|
||||
|
||||
#include "CmdlineProgressbar.h"
|
||||
|
||||
#if !defined( DMAP )
|
||||
void idImageManager::CacheGlobalIlluminationData_f( const idCmdArgs& args )
|
||||
{
|
||||
common->Printf( "Caching images to bimage files...\n" );
|
||||
|
||||
int start = Sys_Milliseconds();
|
||||
globalImages->preloadingMapImages = true;
|
||||
globalImages->cacheImages = true;
|
||||
|
||||
idFileList* files = fileSystem->ListFilesTree( "env/maps", "*.exr", true );
|
||||
int numFiles = files->GetNumFiles();
|
||||
|
||||
CommandlineProgressBar progressBar( numFiles, renderSystem->GetWidth(), renderSystem->GetHeight() );
|
||||
progressBar.Start();
|
||||
|
||||
for( int i = 0; i < files->GetNumFiles(); i++ )
|
||||
{
|
||||
const char* filename = files->GetFile( i );
|
||||
|
||||
if( idStr::FindText( filename, "envprobe" ) != -1 )
|
||||
{
|
||||
if( idStr::FindText( filename, "_spec" ) != -1 )
|
||||
{
|
||||
globalImages->ImageFromFile( filename, TF_DEFAULT, TR_CLAMP, TD_R11G11B10F, CF_2D_PACKED_MIPCHAIN );
|
||||
}
|
||||
else
|
||||
{
|
||||
globalImages->ImageFromFile( filename, TF_LINEAR, TR_CLAMP, TD_R11G11B10F, CF_2D_PACKED_MIPCHAIN );
|
||||
}
|
||||
}
|
||||
else if( idStr::FindText( filename, "lightgrid" ) != -1 )
|
||||
{
|
||||
globalImages->ImageFromFile( filename, TF_LINEAR, TR_CLAMP, TD_R11G11B10F, CF_2D );
|
||||
}
|
||||
|
||||
progressBar.Increment( true );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
|
||||
int end = Sys_Milliseconds();
|
||||
common->Printf( "%05d images cached in %5.1f seconds\n", numFiles, ( end - start ) * 0.001 );
|
||||
common->Printf( "----------------------------------------\n" );
|
||||
globalImages->preloadingMapImages = false;
|
||||
globalImages->cacheImages = false;
|
||||
}
|
||||
#endif
|
|
@ -749,7 +749,11 @@ void idImage::ActuallyLoadImage( bool fromBackEnd, nvrhi::ICommandList* commandL
|
|||
DeriveOpts();
|
||||
|
||||
// foresthale 2014-05-30: give a nice progress display when binarizing
|
||||
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
|
||||
if( !globalImages->cacheImages )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
|
||||
}
|
||||
|
||||
if( opts.numLevels > 1 )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 * 4 / 3 );
|
||||
|
@ -844,14 +848,21 @@ void idImage::ActuallyLoadImage( bool fromBackEnd, nvrhi::ICommandList* commandL
|
|||
// RB: convert to compressed DXT or whatever choosen target format
|
||||
if( cubeFiles == CF_2D_PACKED_MIPCHAIN )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
|
||||
if( !globalImages->cacheImages )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
|
||||
}
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( width * opts.height );
|
||||
|
||||
im.Load2DAtlasMipchainFromMemory( width, opts.height, pic, opts.numLevels, opts.format, opts.colorFormat );
|
||||
}
|
||||
else
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
|
||||
if( !globalImages->cacheImages )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeFilename( generatedName.c_str(), binarizeReason.c_str() );
|
||||
}
|
||||
|
||||
if( opts.numLevels > 1 )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height * 4 / 3 );
|
||||
|
|
Loading…
Reference in a new issue