From 629cf29d1edd24f168a5063930a153ad92746f69 Mon Sep 17 00:00:00 2001 From: Eugene Date: Sat, 3 Feb 2024 21:26:53 +0200 Subject: [PATCH] Renderers: do not merge single lightmap --- code/renderer/tr_bsp.c | 8 +++++--- code/renderervk/tr_bsp.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/code/renderer/tr_bsp.c b/code/renderer/tr_bsp.c index 7d3d30ac4..41d729cbe 100644 --- a/code/renderer/tr_bsp.c +++ b/code/renderer/tr_bsp.c @@ -389,7 +389,7 @@ R_LoadLightmaps static void R_LoadLightmaps( const lump_t *l ) { const byte *buf; byte image[LIGHTMAP_LEN*LIGHTMAP_LEN*4]; - int i; + int i, numLightmaps; float maxIntensity = 0; tr.numLightmaps = 0; @@ -413,7 +413,9 @@ static void R_LoadLightmaps( const lump_t *l ) { return; } - if ( r_mergeLightmaps->integer ) { + numLightmaps = l->filelen / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3); + + if ( r_mergeLightmaps->integer && numLightmaps > 1 ) { // check for low texture sizes if ( glConfig.maxTextureSize >= LIGHTMAP_LEN*2 ) { tr.mergeLightmaps = qtrue; @@ -425,7 +427,7 @@ static void R_LoadLightmaps( const lump_t *l ) { buf = fileBase + l->fileofs; // create all the lightmaps - tr.numLightmaps = l->filelen / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3); + tr.numLightmaps = numLightmaps; // we are about to upload textures //R_IssuePendingRenderCommands(); diff --git a/code/renderervk/tr_bsp.c b/code/renderervk/tr_bsp.c index 1b8efb45d..2d80b7ed0 100644 --- a/code/renderervk/tr_bsp.c +++ b/code/renderervk/tr_bsp.c @@ -396,7 +396,7 @@ R_LoadLightmaps static void R_LoadLightmaps( const lump_t *l ) { const byte *buf; byte image[LIGHTMAP_LEN*LIGHTMAP_LEN*4]; - int i; + int i, numLightmaps; float maxIntensity = 0; tr.numLightmaps = 0; @@ -420,7 +420,9 @@ static void R_LoadLightmaps( const lump_t *l ) { return; } - if ( r_mergeLightmaps->integer ) { + numLightmaps = l->filelen / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3); + + if ( r_mergeLightmaps->integer && numLightmaps > 1 ) { // check for low texture sizes if ( glConfig.maxTextureSize >= LIGHTMAP_LEN * 2 ) { tr.mergeLightmaps = qtrue; @@ -432,7 +434,7 @@ static void R_LoadLightmaps( const lump_t *l ) { buf = fileBase + l->fileofs; // create all the lightmaps - tr.numLightmaps = l->filelen / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3); + tr.numLightmaps = numLightmaps; tr.lightmaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );