]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
avgcolor calculation: also calculate alpha for DXT3
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 26 Dec 2010 09:59:49 +0000 (09:59 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 26 Dec 2010 20:16:27 +0000 (21:16 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10684 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=ca82978880bd5f5e58d316f757ac685783dc07a7

gl_textures.c

index e263502a2f24087ec348ed1d20c92fdfe383d3b5..c3141423ca9ad8f56c42c1607449282b22cfa227 100644 (file)
@@ -2057,7 +2057,18 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
                                avgcolor[1] += ((c >>  5) & 0x3F) + ((c >> 21) & 0x3F);
                                avgcolor[2] += ((c      ) & 0x1F) + ((c >> 16) & 0x1F);
                                if(textype == TEXTYPE_DXT5)
-                                       avgcolor[3] = (0.5 * mippixels[i-8] + 0.5 * mippixels[i-7]);
+                                       avgcolor[3] += (0.5 * mippixels[i-8] + 0.5 * mippixels[i-7]);
+                               else if(textype == TEXTYPE_DXT3)
+                                       avgcolor[3] += (
+                                                 (mippixels_start[i-8] & 0x0F)
+                                               + (mippixels_start[i-8] >> 4)
+                                               + (mippixels_start[i-7] & 0x0F)
+                                               + (mippixels_start[i-7] >> 4)
+                                               + (mippixels_start[i-6] & 0x0F)
+                                               + (mippixels_start[i-6] >> 4)
+                                               + (mippixels_start[i-5] & 0x0F)
+                                               + (mippixels_start[i-5] >> 4)
+                                              ) * (0.125f / 15.0f * 255.0f);
                                else
                                        avgcolor[3] += 255;
                        }