diff --git a/base/renderprogs/builtin/debug/lightgrid.ps.hlsl b/base/renderprogs/builtin/debug/lightgrid.ps.hlsl index 0689db74..44cb95f9 100644 --- a/base/renderprogs/builtin/debug/lightgrid.ps.hlsl +++ b/base/renderprogs/builtin/debug/lightgrid.ps.hlsl @@ -108,11 +108,15 @@ void main( PS_IN fragment, out PS_OUT result ) // offset by one pixel border bleed size for linear filtering #if 1 - float2 octCoordNormalizedToTextureDimensions = ( normalizedOctCoordZeroOne * ( 16.0 / 18.0 ) ); + // rpScreenCorrectionFactor.x = probeSize - borderSize, e.g. ( 18 - 2 ) = 16 + // rpScreenCorrectionFactor.y = probeSize including border, e.g = 18 + // rpScreenCorrectionFactor.z = borderSize e.g = 2 + // rpScreenCorrectionFactor.w = probeSize factor accounting account offset border, e.g = ( 16 / 18 ) = 0.8888 + float2 octCoordNormalizedToTextureDimensions = normalizedOctCoordZeroOne * rpScreenCorrectionFactor.w; float2 probeTopLeftPosition; - probeTopLeftPosition.x = ( gridCoord[0] * gridStep[0] + gridCoord[2] * gridStep[1] ) * 2.0 + 1.0; - probeTopLeftPosition.y = ( gridCoord[1] ) * 2.0 + 1.0; + probeTopLeftPosition.x = ( gridCoord[0] * gridStep[0] + gridCoord[2] * gridStep[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5; + probeTopLeftPosition.y = ( gridCoord[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5; float2 normalizedProbeTopLeftPosition = probeTopLeftPosition * rpCascadeDistances.zw; diff --git a/base/renderprogs/builtin/lighting/ambient_lightgrid_IBL.ps.hlsl b/base/renderprogs/builtin/lighting/ambient_lightgrid_IBL.ps.hlsl index a8e77824..d5271330 100644 --- a/base/renderprogs/builtin/lighting/ambient_lightgrid_IBL.ps.hlsl +++ b/base/renderprogs/builtin/lighting/ambient_lightgrid_IBL.ps.hlsl @@ -333,11 +333,13 @@ void main( PS_IN fragment, out PS_OUT result ) // offset by one pixel border bleed size for linear filtering #if 1 - float2 octCoordNormalizedToTextureDimensions = ( ( normalizedOctCoordZeroOne + atlasOffset ) * ( 16.0 / 18.0 ) ); + // rpScreenCorrectionFactor.w = probeSize factor accounting account offset border, e.g = ( 16 / 18 ) = 0.8888 + float2 octCoordNormalizedToTextureDimensions = ( normalizedOctCoordZeroOne + atlasOffset ) * rpScreenCorrectionFactor.w; + // rpScreenCorrectionFactor.z = borderSize e.g = 2 float2 probeTopLeftPosition; - probeTopLeftPosition.x = ( gridCoord2[0] * gridStep[0] + gridCoord2[2] * gridStep[1] ) * 2.0 + 1.0; - probeTopLeftPosition.y = ( gridCoord2[1] ) * 2.0 + 1.0; + probeTopLeftPosition.x = ( gridCoord2[0] * gridStep[0] + gridCoord2[2] * gridStep[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5; + probeTopLeftPosition.y = ( gridCoord2[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5; float2 normalizedProbeTopLeftPosition = probeTopLeftPosition * rpCascadeDistances.zw; diff --git a/neo/framework/DeclManager.cpp b/neo/framework/DeclManager.cpp index cc20c193..d2a08eae 100644 --- a/neo/framework/DeclManager.cpp +++ b/neo/framework/DeclManager.cpp @@ -2040,7 +2040,7 @@ struct evarPrefix_t const char* prefix; }; -const evarPrefix_t EvarPrefixes[] = +static const evarPrefix_t EvarPrefixes[] = { { EVAR_STRING, "editor_var " }, { EVAR_INT, "editor_int " }, @@ -2053,15 +2053,15 @@ const evarPrefix_t EvarPrefixes[] = { EVAR_SOUND, "editor_snd "} }; -const int NumEvarPrefixes = sizeof( EvarPrefixes ) / sizeof( evarPrefix_t ); +static const int NumEvarPrefixes = sizeof( EvarPrefixes ) / sizeof( evarPrefix_t ); -typedef struct evar_s +struct LocalEvar_t { int type; idStr fullname; idStr name; idStr desc; -} evar_t; +}; #include // idDeclModelDef @@ -2361,14 +2361,14 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) } // collect editor specific spawn flags - idList evars; + idList evars; for( int i = 0; i < NumEvarPrefixes; i++ ) { kv = decl->dict.MatchPrefix( EvarPrefixes[i].prefix ); while( kv ) { - evar_t ev; + LocalEvar_t ev; ev.fullname = kv->GetKey(); kv->GetKey().Right( kv->GetKey().Length() - strlen( EvarPrefixes[i].prefix ), ev.name ); ev.desc = kv->GetValue(); @@ -2386,7 +2386,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) // add missing property to control the radius - evar_t ev; + LocalEvar_t ev; ev.fullname = "editor_int light"; ev.name = "light"; ev.desc = "light radius"; @@ -2401,7 +2401,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) { // entities with dynamic models - evar_t ev; + LocalEvar_t ev; ev.fullname = "editor_model model"; ev.name = "model"; ev.desc = "Model Selection (ex mapobjects/model.obj)"; @@ -2437,7 +2437,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) //} // is it an editor var or a regular spawn argument? - evar_t* ev = nullptr; + LocalEvar_t* ev = nullptr; int vc = evars.Num(); for( int j = 0; j < vc; j++ ) { @@ -2464,7 +2464,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) // add editor_vars that aren't already covered by the default vars for( int i = 0; i < evars.Num(); i++ ) { - const evar_t* ev = &evars[ i ]; + const LocalEvar_t* ev = &evars[ i ]; const idKeyValue* kv2 = dictToWrite.FindKey( ev->name ); if( !kv2 ) @@ -2538,7 +2538,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) kv = dictToWrite.GetKeyVal( i ); // is it an editor var or a regular spawn argument? - evar_t* ev = nullptr; + LocalEvar_t* ev = nullptr; int vc = evars.Num(); for( int j = 0; j < vc; j++ ) { diff --git a/neo/renderer/OpenGL/RenderDebug_GL.cpp b/neo/renderer/OpenGL/RenderDebug_GL.cpp index 48df6ffe..7f24b73c 100644 --- a/neo/renderer/OpenGL/RenderDebug_GL.cpp +++ b/neo/renderer/OpenGL/RenderDebug_GL.cpp @@ -1839,6 +1839,14 @@ void idRenderBackend::DBG_ShowLightGrid() renderProgManager.SetUniformValue( RENDERPARM_JITTERTEXSCALE, lightGridSize.ToFloatPtr() ); renderProgManager.SetUniformValue( RENDERPARM_JITTERTEXOFFSET, lightGridBounds.ToFloatPtr() ); + // individual probe sizes on the atlas image + idVec4 probeSize; + probeSize[0] = area->lightGrid.imageSingleProbeSize - area->lightGrid.imageBorderSize; + probeSize[1] = area->lightGrid.imageSingleProbeSize; + probeSize[2] = area->lightGrid.imageBorderSize; + probeSize[3] = float( area->lightGrid.imageSingleProbeSize - area->lightGrid.imageBorderSize ) / area->lightGrid.imageSingleProbeSize; + renderProgManager.SetUniformValue( RENDERPARM_SCREENCORRECTIONFACTOR, probeSize.ToFloatPtr() ); // rpScreenCorrectionFactor + for( int i = 0; i < area->lightGrid.lightGridPoints.Num(); i++ ) { lightGridPoint_t* gridPoint = &area->lightGrid.lightGridPoints[i]; diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index 24ef280c..3ddb88af 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -1355,6 +1355,14 @@ void idRenderBackend::DrawSingleInteraction( drawInteraction_t* din, bool useFas renderProgManager.SetUniformValue( RENDERPARM_JITTERTEXSCALE, lightGridSize.ToFloatPtr() ); renderProgManager.SetUniformValue( RENDERPARM_JITTERTEXOFFSET, lightGridBounds.ToFloatPtr() ); + // individual probe sizes on the atlas image + idVec4 probeSize; + probeSize[0] = currentSpace->lightGridAtlasSingleProbeSize - currentSpace->lightGridAtlasBorderSize; + probeSize[1] = currentSpace->lightGridAtlasSingleProbeSize; + probeSize[2] = currentSpace->lightGridAtlasBorderSize; + probeSize[3] = float( currentSpace->lightGridAtlasSingleProbeSize - currentSpace->lightGridAtlasBorderSize ) / currentSpace->lightGridAtlasSingleProbeSize; + renderProgManager.SetUniformValue( RENDERPARM_SCREENCORRECTIONFACTOR, probeSize.ToFloatPtr() ); // rpScreenCorrectionFactor + if( specUsage == TD_SPECULAR_PBR_RMAO || specUsage == TD_SPECULAR_PBR_RMAOD ) { // PBR path with roughness, metal and AO @@ -1397,9 +1405,9 @@ void idRenderBackend::DrawSingleInteraction( drawInteraction_t* din, bool useFas #endif GL_SelectTexture( INTERACTION_TEXUNIT_AMBIENT_CUBE1 ); - currentSpace->irradianceAtlasImage->Bind(); + currentSpace->lightGridAtlasImage->Bind(); - idVec2i res = currentSpace->irradianceAtlasImage->GetUploadResolution(); + idVec2i res = currentSpace->lightGridAtlasImage->GetUploadResolution(); idVec4 textureSize( res.x, res.y, 1.0f / res.x, 1.0f / res.y ); renderProgManager.SetUniformValue( RENDERPARM_CASCADEDISTANCES, textureSize.ToFloatPtr() ); diff --git a/neo/renderer/RenderCommon.h b/neo/renderer/RenderCommon.h index 4c5a947e..90413b40 100644 --- a/neo/renderer/RenderCommon.h +++ b/neo/renderer/RenderCommon.h @@ -452,7 +452,9 @@ struct viewEntity_t // RB: use light grid of the best area this entity is in bool useLightGrid; - idImage* irradianceAtlasImage; + idImage* lightGridAtlasImage; + int lightGridAtlasSingleProbeSize; // including border + int lightGridAtlasBorderSize; idVec3 lightGridOrigin; idVec3 lightGridSize; @@ -513,7 +515,8 @@ struct calcEnvprobeParms_t -static const int LIGHTGRID_IRRADIANCE_SIZE = ( 16 * 1 ) + 2; +static const int LIGHTGRID_IRRADIANCE_BORDER_SIZE = 2; // one pixel border all around the octahedron so 2 on each side +static const int LIGHTGRID_IRRADIANCE_SIZE = ( 16 * 1 ) + LIGHTGRID_IRRADIANCE_BORDER_SIZE; struct calcLightGridPointParms_t { diff --git a/neo/renderer/RenderProgs_embedded.h b/neo/renderer/RenderProgs_embedded.h index 1ec68587..402ecae2 100644 --- a/neo/renderer/RenderProgs_embedded.h +++ b/neo/renderer/RenderProgs_embedded.h @@ -2883,11 +2883,15 @@ static const cgShaderDef_t cg_renderprogs[] = "\n" " // offset by one pixel border bleed size for linear filtering\n" "#if 1\n" - " float2 octCoordNormalizedToTextureDimensions = ( normalizedOctCoordZeroOne * ( 16.0 / 18.0 ) );\n" + " // rpScreenCorrectionFactor.x = probeSize - borderSize, e.g. ( 18 - 2 ) = 16\n" + " // rpScreenCorrectionFactor.y = probeSize including border, e.g = 18\n" + " // rpScreenCorrectionFactor.z = borderSize e.g = 2\n" + " // rpScreenCorrectionFactor.w = probeSize factor accounting account offset border, e.g = ( 16 / 18 ) = 0.8888\n" + " float2 octCoordNormalizedToTextureDimensions = normalizedOctCoordZeroOne * rpScreenCorrectionFactor.w;\n" "\n" " float2 probeTopLeftPosition;\n" - " probeTopLeftPosition.x = ( gridCoord[0] * gridStep[0] + gridCoord[2] * gridStep[1] ) * 2.0 + 1.0;\n" - " probeTopLeftPosition.y = ( gridCoord[1] ) * 2.0 + 1.0;\n" + " probeTopLeftPosition.x = ( gridCoord[0] * gridStep[0] + gridCoord[2] * gridStep[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5;\n" + " probeTopLeftPosition.y = ( gridCoord[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5;\n" "\n" " float2 normalizedProbeTopLeftPosition = probeTopLeftPosition * rpCascadeDistances.zw;\n" "\n" @@ -5592,11 +5596,13 @@ static const cgShaderDef_t cg_renderprogs[] = "\n" " // offset by one pixel border bleed size for linear filtering\n" "#if 1\n" - " float2 octCoordNormalizedToTextureDimensions = ( ( normalizedOctCoordZeroOne + atlasOffset ) * ( 16.0 / 18.0 ) );\n" + " // rpScreenCorrectionFactor.w = probeSize factor accounting account offset border, e.g = ( 16 / 18 ) = 0.8888\n" + " float2 octCoordNormalizedToTextureDimensions = ( normalizedOctCoordZeroOne + atlasOffset ) * rpScreenCorrectionFactor.w;\n" "\n" + " // rpScreenCorrectionFactor.z = borderSize e.g = 2\n" " float2 probeTopLeftPosition;\n" - " probeTopLeftPosition.x = ( gridCoord2[0] * gridStep[0] + gridCoord2[2] * gridStep[1] ) * 2.0 + 1.0;\n" - " probeTopLeftPosition.y = ( gridCoord2[1] ) * 2.0 + 1.0;\n" + " probeTopLeftPosition.x = ( gridCoord2[0] * gridStep[0] + gridCoord2[2] * gridStep[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5;\n" + " probeTopLeftPosition.y = ( gridCoord2[1] ) * rpScreenCorrectionFactor.z + rpScreenCorrectionFactor.z * 0.5;\n" "\n" " float2 normalizedProbeTopLeftPosition = probeTopLeftPosition * rpCascadeDistances.zw;\n" "\n" diff --git a/neo/renderer/RenderWorld_lightgrid.cpp b/neo/renderer/RenderWorld_lightgrid.cpp index 760640a0..47961442 100644 --- a/neo/renderer/RenderWorld_lightgrid.cpp +++ b/neo/renderer/RenderWorld_lightgrid.cpp @@ -35,15 +35,13 @@ If you have questions concerning this license or the applicable additional terms #define LGRID_FILE_EXT "lightgrid" #define LGRID_BINARYFILE_EXT "blightgrid" #define LGRID_FILEID "LGRID" -#define LGRID_FILEVERSION "1.00" #define STORE_LIGHTGRID_SHDATA 0 -static const byte BLGRID_VERSION = 2; +static const byte BLGRID_VERSION = 3; static const unsigned int BLGRID_MAGIC = ( 'P' << 24 ) | ( 'R' << 16 ) | ( 'O' << 8 ) | BLGRID_VERSION; - static const int MAX_LIGHTGRID_ATLAS_SIZE = 2048; static const int MAX_AREA_LIGHTGRID_POINTS = ( MAX_LIGHTGRID_ATLAS_SIZE / LIGHTGRID_IRRADIANCE_SIZE ) * ( MAX_LIGHTGRID_ATLAS_SIZE / LIGHTGRID_IRRADIANCE_SIZE ); @@ -53,6 +51,8 @@ LightGrid::LightGrid() area = -1; irradianceImage = NULL; + imageSingleProbeSize = LIGHTGRID_IRRADIANCE_SIZE; + imageBorderSize = LIGHTGRID_IRRADIANCE_BORDER_SIZE; } void LightGrid::SetupLightGrid( const idBounds& bounds, const char* mapName, const idRenderWorld* world, int _area, int limit ) @@ -64,6 +64,9 @@ void LightGrid::SetupLightGrid( const idBounds& bounds, const char* mapName, con area = _area; + imageSingleProbeSize = LIGHTGRID_IRRADIANCE_SIZE; + imageBorderSize = LIGHTGRID_IRRADIANCE_BORDER_SIZE; + idVec3 maxs; int j = 0; @@ -443,7 +446,7 @@ void idRenderWorldLocal::WriteLightGridsToFile( const char* filename ) } // write file id and version - fp->WriteFloatString( "%s \"%s\"\n\n", LGRID_FILEID, LGRID_FILEVERSION ); + fp->WriteFloatString( "%s \"%i\"\n\n", LGRID_FILEID, BLGRID_VERSION ); // write the map file crc //fp->WriteFloatString( "%u\n\n", mapFileCRC ); @@ -460,9 +463,7 @@ void idRenderWorldLocal::WriteLightGridsToFile( const char* filename ) void idRenderWorldLocal::WriteLightGrid( idFile* fp, const LightGrid& lightGrid ) { - // TODO write used irradiance resolution - - fp->WriteFloatString( "lightGridPoints { /* area = */ %i /* numLightGridPoints = */ %i\n", lightGrid.area, lightGrid.lightGridPoints.Num() ); + fp->WriteFloatString( "lightGridPoints { /* area = */ %i /* numLightGridPoints = */ %i /* imageSingleProbeSize = */ %i /* imageBorderSize = */ %i \n", lightGrid.area, lightGrid.lightGridPoints.Num(), lightGrid.imageSingleProbeSize, lightGrid.imageBorderSize ); fp->WriteFloatString( "/* gridMins */ " ); fp->WriteFloatString( "\t ( %f %f %f )\n", lightGrid.lightGridOrigin[0], lightGrid.lightGridOrigin[1], lightGrid.lightGridOrigin[2] ); @@ -522,15 +523,10 @@ bool idRenderWorldLocal::LoadLightGridFile( const char* name ) if( file != NULL ) { int numEntries = 0; - //int magic = 0; + int magic = 0; + file->ReadBig( magic ); file->ReadBig( numEntries ); - //file->ReadString( mapName ); - //file->ReadBig( crc ); - idStrStatic< 32 > fileID; - idStrStatic< 32 > fileVersion; - file->ReadString( fileID ); - file->ReadString( fileVersion ); - if( fileID == LGRID_FILEID && fileVersion == LGRID_FILEVERSION ) //&& crc == mapFileCRC && numEntries > 0 ) + if( magic == BLGRID_MAGIC && numEntries > 0 ) { loaded = true; for( int i = 0; i < numEntries; i++ ) @@ -566,11 +562,9 @@ bool idRenderWorldLocal::LoadLightGridFile( const char* name ) idFileLocal outputFile( fileSystem->OpenFileWrite( generatedFileName, "fs_basepath" ) ); if( outputFile != NULL ) { + int magic = BLGRID_MAGIC; + outputFile->WriteBig( magic ); outputFile->WriteBig( numEntries ); - //outputFile->WriteString( mapName ); - //outputFile->WriteBig( mapFileCRC ); - outputFile->WriteString( LGRID_FILEID ); - outputFile->WriteString( LGRID_FILEVERSION ); } if( !src->ExpectTokenString( LGRID_FILEID ) ) @@ -580,9 +574,35 @@ bool idRenderWorldLocal::LoadLightGridFile( const char* name ) return false; } - if( !src->ReadToken( &token ) || token != LGRID_FILEVERSION ) + int lightGridVersion = 0; + if( !src->ReadToken( &token ) ) { - common->Warning( "%s has version %s instead of %s", fileName.c_str(), token.c_str(), LGRID_FILEVERSION ); + src->Error( "couldn't read expected integer" ); + delete src; + return false; + } + if( token.type == TT_PUNCTUATION && token == "-" ) + { + src->ExpectTokenType( TT_NUMBER, TT_INTEGER, &token ); + lightGridVersion = -( ( signed int ) token.GetIntValue() ); + } + else if( token.type != TT_NUMBER && token.subtype != TT_STRING && token.subtype != TT_NAME ) + { + src->Error( "expected integer value or string, found '%s'", token.c_str() ); + } + + if( token.type == TT_NUMBER ) + { + lightGridVersion = token.GetIntValue(); + } + else if( token.type == TT_STRING || token.subtype == TT_NAME ) + { + lightGridVersion = atoi( token ); + } + + if( lightGridVersion != BLGRID_VERSION ) + { + common->Warning( "%s has version %i instead of %i", fileName.c_str(), lightGridVersion, BLGRID_VERSION ); delete src; return false; } @@ -626,6 +646,8 @@ bool idRenderWorldLocal::LoadLightGridFile( const char* name ) if( outputFile != NULL ) { outputFile->Seek( 0, FS_SEEK_SET ); + int magic = BLGRID_MAGIC; + outputFile->WriteBig( magic ); outputFile->WriteBig( numEntries ); } } @@ -651,6 +673,20 @@ void idRenderWorldLocal::ParseLightGridPoints( idLexer* src, idFile* fileOut ) return; } + int imageProbeSize = src->ParseInt(); + if( imageProbeSize < 8 ) + { + src->Error( "ParseLightGridPoints: bad single image probe size %i", imageProbeSize ); + return; + } + + int imageBorderSize = src->ParseInt(); + if( imageBorderSize < 0 ) + { + src->Error( "ParseLightGridPoints: bad probe border size %i", imageBorderSize ); + return; + } + if( fileOut != NULL ) { // write out the type so the binary reader knows what to instantiate @@ -660,6 +696,9 @@ void idRenderWorldLocal::ParseLightGridPoints( idLexer* src, idFile* fileOut ) portalArea_t* area = &portalAreas[areaIndex]; area->lightGrid.area = areaIndex; + area->lightGrid.imageSingleProbeSize = imageProbeSize; + area->lightGrid.imageBorderSize = imageBorderSize; + // gridMins src->Parse1DMatrix( 3, area->lightGrid.lightGridOrigin.ToFloatPtr() ); src->Parse1DMatrix( 3, area->lightGrid.lightGridSize.ToFloatPtr() ); @@ -674,11 +713,14 @@ void idRenderWorldLocal::ParseLightGridPoints( idLexer* src, idFile* fileOut ) 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 ) ); + idLib::Printf( "area %i probe size (%i %i)\n", areaIndex, imageProbeSize, imageBorderSize ); if( fileOut != NULL ) { fileOut->WriteBig( areaIndex ); fileOut->WriteBig( numLightGridPoints ); + fileOut->WriteBig( imageProbeSize ); + fileOut->WriteBig( imageBorderSize ); fileOut->WriteBig( area->lightGrid.lightGridOrigin ); fileOut->WriteBig( area->lightGrid.lightGridSize ); fileOut->WriteBigArray( area->lightGrid.lightGridBounds, 3 ); @@ -728,9 +770,28 @@ void idRenderWorldLocal::ReadBinaryLightGridPoints( idFile* file ) return; } + int imageProbeSize = 0; + file->ReadBig( imageProbeSize ); + if( imageProbeSize < 0 ) + { + idLib::Error( "ReadBinaryLightGridPoints: bad imageProbeSize %i", imageProbeSize ); + return; + } + + int imageBorderSize = 0; + file->ReadBig( imageBorderSize ); + if( imageBorderSize < 0 ) + { + idLib::Error( "ReadBinaryLightGridPoints: bad imageBorderSize %i", imageBorderSize ); + return; + } + portalArea_t* area = &portalAreas[areaIndex]; area->lightGrid.area = areaIndex; + area->lightGrid.imageSingleProbeSize = imageProbeSize; + area->lightGrid.imageBorderSize = imageBorderSize; + // gridMins file->ReadBig( area->lightGrid.lightGridOrigin ); file->ReadBig( area->lightGrid.lightGridSize ); @@ -742,6 +803,7 @@ void idRenderWorldLocal::ReadBinaryLightGridPoints( idFile* file ) 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 ) ); + idLib::Printf( "area %i probe size (%i %i)\n", areaIndex, imageProbeSize, imageBorderSize ); for( int i = 0; i < numLightGridPoints; i++ ) { diff --git a/neo/renderer/RenderWorld_local.h b/neo/renderer/RenderWorld_local.h index ac5d292c..512d2438 100644 --- a/neo/renderer/RenderWorld_local.h +++ b/neo/renderer/RenderWorld_local.h @@ -80,6 +80,8 @@ public: int area; idImage* irradianceImage; + int imageSingleProbeSize; // including border + int imageBorderSize; LightGrid(); diff --git a/neo/renderer/tr_frontend_addmodels.cpp b/neo/renderer/tr_frontend_addmodels.cpp index 7affc283..c73e8fd4 100644 --- a/neo/renderer/tr_frontend_addmodels.cpp +++ b/neo/renderer/tr_frontend_addmodels.cpp @@ -560,7 +560,9 @@ void R_AddSingleModel( viewEntity_t* vEntity ) if( ref->area->lightGrid.lightGridPoints.Num() && lightGridImage && !lightGridImage->IsDefaulted() ) { vEntity->useLightGrid = true; - vEntity->irradianceAtlasImage = lightGridImage; + vEntity->lightGridAtlasImage = lightGridImage; + vEntity->lightGridAtlasSingleProbeSize = ref->area->lightGrid.imageSingleProbeSize; + vEntity->lightGridAtlasBorderSize = ref->area->lightGrid.imageBorderSize; for( int i = 0; i < 3; i++ ) { diff --git a/neo/tools/compilers/dmap/map.cpp b/neo/tools/compilers/dmap/map.cpp index e2024788..82a41a50 100644 --- a/neo/tools/compilers/dmap/map.cpp +++ b/neo/tools/compilers/dmap/map.cpp @@ -3,7 +3,7 @@ Doom 3 GPL Source Code Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. -Copyright (C) 2013-2015 Robert Beckebans +Copyright (C) 2013-2021 Robert Beckebans This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).