[iortcw] 172/497: All: Rend2: Remove R_MipMap and R_MipMap2 / Fix gamma conversion in R_MipMapsRGB
Simon McVittie
smcv at debian.org
Fri Sep 8 10:36:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.42d
in repository iortcw.
commit ae43922ed9636adfbc0f3d7c51164c69294ec72c
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date: Sat Aug 2 09:28:44 2014 +0000
All: Rend2: Remove R_MipMap and R_MipMap2 / Fix gamma conversion in R_MipMapsRGB
---
MP/code/rend2/tr_image.c | 104 ++--------------------------------------------
SP/code/rend2/tr_image.c | 105 ++---------------------------------------------
2 files changed, 7 insertions(+), 202 deletions(-)
diff --git a/MP/code/rend2/tr_image.c b/MP/code/rend2/tr_image.c
index 1eb06bc..01b09dd 100644
--- a/MP/code/rend2/tr_image.c
+++ b/MP/code/rend2/tr_image.c
@@ -1439,62 +1439,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
================
*/
-#if 0
-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;
- }
- }
- }
-
- memcpy( in, temp, outWidth * outHeight * 4 );
- ri.Hunk_FreeTempMemory( temp );
-}
-#endif
-
static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
{
int x, y, c, stride;
@@ -1506,7 +1456,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;
}
@@ -1544,54 +1494,6 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
}
}
-/*
-================
-R_MipMap
-
-Operates in place, quartering the size of the texture
-================
-*/
-#if 0
-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;
- }
- }
-}
-#endif
static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int height)
{
diff --git a/SP/code/rend2/tr_image.c b/SP/code/rend2/tr_image.c
index cf51f5d..0781cc1 100644
--- a/SP/code/rend2/tr_image.c
+++ b/SP/code/rend2/tr_image.c
@@ -1426,64 +1426,15 @@ 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
================
*/
-#if 0
-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;
- }
- }
- }
-
- memcpy( in, temp, outWidth * outHeight * 4 );
- ri.Hunk_FreeTempMemory( temp );
-}
-#endif
-
static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
{
int x, y, c, stride;
@@ -1495,7 +1446,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;
}
@@ -1533,54 +1484,6 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
}
}
-/*
-================
-R_MipMap
-
-Operates in place, quartering the size of the texture
-================
-*/
-#if 0
-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;
- }
- }
-}
-#endif
static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int height)
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list