summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/renderergl2/tr_image.c102
1 files changed, 3 insertions, 99 deletions
diff --git a/src/renderergl2/tr_image.c b/src/renderergl2/tr_image.c
index 75626531..060eb1c4 100644
--- a/src/renderergl2/tr_image.c
+++ b/src/renderergl2/tr_image.c
@@ -1276,61 +1276,12 @@ void R_LightScaleTexture (byte *in, int inwidth, int inheight, qboolean only_gam
/*
================
-R_MipMap2
+R_MipMapsRGB
Operates in place, quartering the size of the texture
-Proper linear filter
+Colors are gamma correct
================
*/
-static void R_MipMap2( byte *in, int inWidth, int inHeight ) {
- int i, j, k;
- byte *outpix;
- int inWidthMask, inHeightMask;
- int total;
- int outWidth, outHeight;
- unsigned *temp;
-
- outWidth = inWidth >> 1;
- outHeight = inHeight >> 1;
- temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 );
-
- inWidthMask = inWidth - 1;
- inHeightMask = inHeight - 1;
-
- for ( i = 0 ; i < outHeight ; i++ ) {
- for ( j = 0 ; j < outWidth ; j++ ) {
- outpix = (byte *) ( temp + i * outWidth + j );
- for ( k = 0 ; k < 4 ; k++ ) {
- total =
- 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] +
- 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] +
- 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] +
- 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] +
-
- 2 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] +
- 4 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] +
- 4 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] +
- 2 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] +
-
- 2 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] +
- 4 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] +
- 4 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] +
- 2 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] +
-
- 1 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] +
- 2 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] +
- 2 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] +
- 1 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k];
- outpix[k] = total / 36;
- }
- }
- }
-
- Com_Memcpy( in, temp, outWidth * outHeight * 4 );
- ri.Hunk_FreeTempMemory( temp );
-}
-
-
static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
{
int x, y, c, stride;
@@ -1342,7 +1293,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
if (!downmipSrgbLookupSet) {
for (x = 0; x < 256; x++)
- downmipSrgbLookup[x] = ((x < 10) ? x / 3294.6f : powf((x / 255.0f + 0.055f) / 1.055f, 2.4f)) * 0.25f;
+ downmipSrgbLookup[x] = powf(x / 255.0f, 2.2f) * 0.25f;
downmipSrgbLookupSet = 1;
}
@@ -1380,53 +1331,6 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
}
}
-/*
-================
-R_MipMap
-
-Operates in place, quartering the size of the texture
-================
-*/
-static void R_MipMap (byte *in, int width, int height) {
- int i, j;
- byte *out;
- int row;
-
- if ( !r_simpleMipMaps->integer ) {
- R_MipMap2( in, width, height );
- return;
- }
-
- if ( width == 1 && height == 1 ) {
- return;
- }
-
- row = width * 4;
- out = in;
- width >>= 1;
- height >>= 1;
-
- if ( width == 0 || height == 0 ) {
- width += height; // get largest
- for (i=0 ; i<width ; i++, out+=4, in+=8 ) {
- out[0] = ( in[0] + in[4] )>>1;
- out[1] = ( in[1] + in[5] )>>1;
- out[2] = ( in[2] + in[6] )>>1;
- out[3] = ( in[3] + in[7] )>>1;
- }
- return;
- }
-
- for (i=0 ; i<height ; i++, in+=row) {
- for (j=0 ; j<width ; j++, out+=4, in+=8) {
- out[0] = (in[0] + in[4] + in[row+0] + in[row+4])>>2;
- out[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2;
- out[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2;
- out[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2;
- }
- }
-}
-
static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int height)
{