diff options
author | James Canete <use.less01@gmail.com> | 2012-12-18 06:15:38 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-12 21:26:43 +0000 |
commit | 4e66dca0cbea0d081f584c9bb67cf21d3968cfcc (patch) | |
tree | 4394dba1e169ebf6d8441fca805ccbc271b2b636 /src/rend2 | |
parent | f602b02641142bef5225b9f94530a07d58dcfb19 (diff) |
Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1.
Diffstat (limited to 'src/rend2')
-rw-r--r-- | src/rend2/tr_backend.c | 2 | ||||
-rw-r--r-- | src/rend2/tr_extensions.c | 15 | ||||
-rw-r--r-- | src/rend2/tr_image.c | 40 | ||||
-rw-r--r-- | src/rend2/tr_init.c | 11 | ||||
-rw-r--r-- | src/rend2/tr_local.h | 1 |
5 files changed, 38 insertions, 31 deletions
diff --git a/src/rend2/tr_backend.c b/src/rend2/tr_backend.c index b8d56e59..c3d39433 100644 --- a/src/rend2/tr_backend.c +++ b/src/rend2/tr_backend.c @@ -1747,7 +1747,7 @@ const void *RB_PostProcess(const void *data) autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer; RB_ToneMap(srcFbo, autoExposure); } - else if (!glRefConfig.framebuffer_srgb && r_cameraExposure->value == 0.0f) + else if (r_cameraExposure->value == 0.0f) { FBO_FastBlit(srcFbo, NULL, tr.screenScratchFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); } diff --git a/src/rend2/tr_extensions.c b/src/rend2/tr_extensions.c index f888cbc8..0b70d48b 100644 --- a/src/rend2/tr_extensions.c +++ b/src/rend2/tr_extensions.c @@ -608,21 +608,6 @@ void GLimp_InitExtraExtensions() ri.Printf(PRINT_ALL, result[2], extension); } - // GL_EXT_framebuffer_sRGB - extension = "GL_EXT_framebuffer_sRGB"; - glRefConfig.framebuffer_srgb = qfalse; - if (GLimp_HaveExtension(extension)) - { - if (r_srgb->integer) - glRefConfig.framebuffer_srgb = qtrue; - - ri.Printf(PRINT_ALL, result[glRefConfig.framebuffer_srgb], extension); - } - else - { - ri.Printf(PRINT_ALL, result[2], extension); - } - glRefConfig.textureCompression = TCR_NONE; // GL_EXT_texture_compression_latc diff --git a/src/rend2/tr_image.c b/src/rend2/tr_image.c index c00bfbbc..20edb0af 100644 --- a/src/rend2/tr_image.c +++ b/src/rend2/tr_image.c @@ -2152,6 +2152,26 @@ static void Upload32( byte *data, int width, int height, imgType_t type, imgFlag } } + // Convert to RGB if sRGB textures aren't supported in hardware + if (!glRefConfig.texture_srgb && (flags & IMGFLAG_SRGB)) + { + byte *in = data; + int c = width * height; + while (c--) + { + for (i = 0; i < 3; i++) + { + float x = ByteToFloat(in[i]); + x = sRGBtoRGB(x); + in[i] = FloatToByte(x); + } + in += 4; + } + + // FIXME: Probably should mark the image as non-sRGB as well + flags &= ~IMGFLAG_SRGB; + } + // normals are always swizzled if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) { @@ -2947,10 +2967,7 @@ void R_CreateBuiltinImages( void ) { { int format; - if (glRefConfig.texture_srgb && glRefConfig.framebuffer_srgb) - format = GL_SRGB8_ALPHA8_EXT; - else - format = GL_RGBA8; + format = GL_RGBA8; tr.screenScratchImage = R_CreateImage("*screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, format); } @@ -3085,10 +3102,21 @@ void R_SetColorMappings( void ) { } for ( i = 0; i < 256; i++ ) { + int i2; + + if (r_srgb->integer) + { + i2 = 255 * RGBtosRGB(i/255.0f) + 0.5f; + } + else + { + i2 = i; + } + if ( g == 1 ) { - inf = i; + inf = i2; } else { - inf = 255 * pow ( i/255.0f, 1.0f / g ) + 0.5f; + inf = 255 * pow ( i2/255.0f, 1.0f / g ) + 0.5f; } inf <<= shift; if (inf < 0) { diff --git a/src/rend2/tr_init.c b/src/rend2/tr_init.c index 7b384106..2ee6ff32 100644 --- a/src/rend2/tr_init.c +++ b/src/rend2/tr_init.c @@ -934,11 +934,6 @@ void GL_SetDefaultState( void ) glState.currentVBO = NULL; glState.currentIBO = NULL; - if (glRefConfig.framebuffer_srgb) - { - qglEnable(GL_FRAMEBUFFER_SRGB_EXT); - } - qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); qglDepthMask( GL_TRUE ); qglDisable( GL_DEPTH_TEST ); @@ -1159,9 +1154,9 @@ void R_Register( void ) r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_forceToneMap = ri.Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT ); - r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-3.25", CVAR_CHEAT ); - r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-1.0", CVAR_CHEAT ); - r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "1.0", CVAR_CHEAT ); + r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT ); + r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT ); + r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT ); r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE ); r_forceAutoExposure = ri.Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT ); diff --git a/src/rend2/tr_local.h b/src/rend2/tr_local.h index 77b11f90..3d756b79 100644 --- a/src/rend2/tr_local.h +++ b/src/rend2/tr_local.h @@ -1711,7 +1711,6 @@ typedef struct { qboolean framebufferBlit; qboolean texture_srgb; - qboolean framebuffer_srgb; qboolean depthClamp; } glRefConfig_t; |