From c6774cf113c15361156d6af7daca003c079d8649 Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Mon, 7 Oct 2013 01:46:50 -0700 Subject: [PATCH] OpenGL2: default to RGBM lightmap, and add r_floatLightmap for old behaviour. --- code/renderergl2/tr_bsp.c | 4 ++-- code/renderergl2/tr_glsl.c | 4 ++-- code/renderergl2/tr_init.c | 2 ++ code/renderergl2/tr_local.h | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index 64d54805..3479be1a 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -271,7 +271,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { if (r_hdr->integer) { - if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel) + if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) textureInternalFormat = GL_RGBA16F_ARB; else textureInternalFormat = GL_RGBA8; @@ -410,7 +410,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { VectorScale(color, lightScale, color); - if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel) + if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); else ColorToRGBM(color, &image[j*4]); diff --git a/code/renderergl2/tr_glsl.c b/code/renderergl2/tr_glsl.c index 93884b91..54b05dc5 100644 --- a/code/renderergl2/tr_glsl.c +++ b/code/renderergl2/tr_glsl.c @@ -905,7 +905,7 @@ void GLSL_InitGPUShaders(void) if (i & GENERICDEF_USE_LIGHTMAP) Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); - if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel)) + if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) @@ -1034,7 +1034,7 @@ void GLSL_InitGPUShaders(void) Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); } - if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel)) + if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); if (i & LIGHTDEF_LIGHTTYPE_MASK) diff --git a/code/renderergl2/tr_init.c b/code/renderergl2/tr_init.c index b9b90a47..e17e1fd5 100644 --- a/code/renderergl2/tr_init.c +++ b/code/renderergl2/tr_init.c @@ -110,6 +110,7 @@ cvar_t *r_cameraExposure; cvar_t *r_softOverbright; cvar_t *r_hdr; +cvar_t *r_floatLightmap; cvar_t *r_postProcess; cvar_t *r_toneMap; @@ -1170,6 +1171,7 @@ void R_Register( void ) r_softOverbright = ri.Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/code/renderergl2/tr_local.h b/code/renderergl2/tr_local.h index 83b34d3a..5b864ce1 100644 --- a/code/renderergl2/tr_local.h +++ b/code/renderergl2/tr_local.h @@ -1958,6 +1958,7 @@ extern cvar_t *r_mergeLeafSurfaces; extern cvar_t *r_softOverbright; extern cvar_t *r_hdr; +extern cvar_t *r_floatLightmap; extern cvar_t *r_postProcess; extern cvar_t *r_toneMap;