diff --git a/src/engine/renderer/GeometryOptimiser.cpp b/src/engine/renderer/GeometryOptimiser.cpp index 43cbc82b0f..9c84cf252b 100644 --- a/src/engine/renderer/GeometryOptimiser.cpp +++ b/src/engine/renderer/GeometryOptimiser.cpp @@ -645,12 +645,12 @@ std::vector OptimiseMapGeometryMaterial( world_t* world, bspSur uint32_t texData = lhs.texDataDynamic[stage] ? ( lhs.texDataIDs[stage] + materialSystem.GetTexDataSize() ) << TEX_BUNDLE_BITS : lhs.texDataIDs[stage] << TEX_BUNDLE_BITS; - texData |= ( HasLightMap( &lhs ) ? GetLightMapNum( &lhs ) : 255 ) << LIGHTMAP_BITS; + texData |= MaterialSystem::GetLightMapIdx( lhs, tr.worldLight ) << LIGHTMAP_BITS; uint32_t texData2 = rhs.texDataDynamic[stage] ? ( rhs.texDataIDs[stage] + materialSystem.GetTexDataSize() ) << TEX_BUNDLE_BITS : rhs.texDataIDs[stage] << TEX_BUNDLE_BITS; - texData2 |= ( HasLightMap( &rhs ) ? GetLightMapNum( &rhs ) : 255 ) << LIGHTMAP_BITS; + texData2 |= MaterialSystem::GetLightMapIdx( rhs, tr.worldLight ) << LIGHTMAP_BITS; if ( texData < texData2 ) { return true; diff --git a/src/engine/renderer/Material.cpp b/src/engine/renderer/Material.cpp index cb4c0cfcb3..0af6db50f0 100644 --- a/src/engine/renderer/Material.cpp +++ b/src/engine/renderer/Material.cpp @@ -480,6 +480,18 @@ void MaterialSystem::GenerateTexturesBuffer( std::vector& textures, } } +int MaterialSystem::GetLightMapIdx( const MaterialSurface &surface, lightMode_t mode ) +{ + if ( mode == lightMode_t::MAP ) + { + return GetLightMapNum( &surface ) & 255; + } + else + { + return 255; + } +} + // This generates the buffers with indirect rendering commands etc. void MaterialSystem::GenerateWorldCommandBuffer( std::vector& surfaces ) { Log::Debug( "Generating world command buffer" ); @@ -680,7 +692,7 @@ void MaterialSystem::GenerateWorldCommandBuffer( std::vector& s surfaceCommand.drawCommand.baseInstance |= surface.texDataDynamic[stage] ? ( surface.texDataIDs[stage] + texData.size() ) << TEX_BUNDLE_BITS : surface.texDataIDs[stage] << TEX_BUNDLE_BITS; - surfaceCommand.drawCommand.baseInstance |= ( HasLightMap( &surface ) ? GetLightMapNum( &surface ) : 255 ) << LIGHTMAP_BITS; + surfaceCommand.drawCommand.baseInstance |= GetLightMapIdx( surface, tr.worldLight ) << LIGHTMAP_BITS; surfaceCommands[cmdID] = surfaceCommand; material->drawCommandCount++; diff --git a/src/engine/renderer/Material.h b/src/engine/renderer/Material.h index 5a25b70179..22a6f02d4e 100644 --- a/src/engine/renderer/Material.h +++ b/src/engine/renderer/Material.h @@ -356,6 +356,8 @@ class MaterialSystem { bool frameStart = false; + static int GetLightMapIdx( const MaterialSurface &surface, lightMode_t mode ); + void AddPortalSurfaces(); void AddAutospriteSurfaces(); void RenderMaterials( const shaderSort_t fromSort, const shaderSort_t toSort, const uint32_t viewID );