[quake3-commits] r2390 - trunk/code/rend2

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Dec 18 01:15:38 EST 2012


Author: smiletheory
Date: 2012-12-18 01:15:38 -0500 (Tue, 18 Dec 2012)
New Revision: 2390

Modified:
   trunk/code/rend2/tr_backend.c
   trunk/code/rend2/tr_extensions.c
   trunk/code/rend2/tr_image.c
   trunk/code/rend2/tr_init.c
   trunk/code/rend2/tr_local.h
Log:
Support r_srgb even without hardware support.  Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1.

Modified: trunk/code/rend2/tr_backend.c
===================================================================
--- trunk/code/rend2/tr_backend.c	2012-12-16 19:20:08 UTC (rev 2389)
+++ trunk/code/rend2/tr_backend.c	2012-12-18 06:15:38 UTC (rev 2390)
@@ -1747,7 +1747,7 @@
 			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);
 		}

Modified: trunk/code/rend2/tr_extensions.c
===================================================================
--- trunk/code/rend2/tr_extensions.c	2012-12-16 19:20:08 UTC (rev 2389)
+++ trunk/code/rend2/tr_extensions.c	2012-12-18 06:15:38 UTC (rev 2390)
@@ -608,21 +608,6 @@
 		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

Modified: trunk/code/rend2/tr_image.c
===================================================================
--- trunk/code/rend2/tr_image.c	2012-12-16 19:20:08 UTC (rev 2389)
+++ trunk/code/rend2/tr_image.c	2012-12-18 06:15:38 UTC (rev 2390)
@@ -2152,6 +2152,26 @@
 		}
 	}
 
+	// 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 @@
 		{
 			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 @@
 	}
 
 	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) {

Modified: trunk/code/rend2/tr_init.c
===================================================================
--- trunk/code/rend2/tr_init.c	2012-12-16 19:20:08 UTC (rev 2389)
+++ trunk/code/rend2/tr_init.c	2012-12-18 06:15:38 UTC (rev 2390)
@@ -934,11 +934,6 @@
 	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 @@
 
 	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 );

Modified: trunk/code/rend2/tr_local.h
===================================================================
--- trunk/code/rend2/tr_local.h	2012-12-16 19:20:08 UTC (rev 2389)
+++ trunk/code/rend2/tr_local.h	2012-12-18 06:15:38 UTC (rev 2390)
@@ -1711,7 +1711,6 @@
 	qboolean framebufferBlit;
 
 	qboolean texture_srgb;
-	qboolean framebuffer_srgb;
 
 	qboolean depthClamp;
 } glRefConfig_t;



More information about the quake3-commits mailing list