]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
cvar: r_texture_dds_load_dxt1_noalpha; if set, DXT1 alpha detection is disabled,...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 Aug 2010 18:48:30 +0000 (18:48 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 Aug 2010 18:48:30 +0000 (18:48 +0000)
Rationale is that ATI Compressonator sometimes picks the alpha'd compression mode [a, (a+b)/2, b, transparent] and then never uses the transparent color value 3, as it sometimes can yield better results than the non-alpha'd compression mode [a, (2a+b)/3, (a+2b)/3, b], and this throws off alpha detection on loading

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10375 d7cf8633-e32d-0410-b094-e92efae38249

gl_textures.c

index e9b5d7101bc58961d6ce81f55fcfa7b134efb9e7..a44e3a29b948c73b536bdd660e62cade7600e7aa 100644 (file)
@@ -31,6 +31,7 @@ cvar_t gl_texturecompression_sky = {CVAR_SAVE, "gl_texturecompression_sky", "0",
 cvar_t gl_texturecompression_lightcubemaps = {CVAR_SAVE, "gl_texturecompression_lightcubemaps", "1", "whether to compress light cubemaps (spotlights and other light projection images)"};
 cvar_t gl_texturecompression_reflectmask = {CVAR_SAVE, "gl_texturecompression_reflectmask", "1", "whether to compress reflection cubemap masks (mask of which areas of the texture should reflect the generic shiny cubemap)"};
 cvar_t gl_nopartialtextureupdates = {CVAR_SAVE, "gl_nopartialtextureupdates", "1", "use alternate path for dynamic lightmap updates that avoids a possibly slow code path in the driver"};
+cvar_t r_texture_dds_load_dxt1_noalpha = {0, "r_texture_dds_load_dxt1_noalpha", "0", "if set, alpha detection on DXT1 is turned off, and DXT1 textures are assumed to never have alpha"};
 
 qboolean       gl_filter_force = false;
 int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
@@ -805,6 +806,7 @@ void R_Textures_Init (void)
        Cvar_RegisterVariable (&gl_texturecompression_lightcubemaps);
        Cvar_RegisterVariable (&gl_texturecompression_reflectmask);
        Cvar_RegisterVariable (&gl_nopartialtextureupdates);
+       Cvar_RegisterVariable (&r_texture_dds_load_dxt1_noalpha);
 
        R_RegisterModule("R_Textures", r_textures_start, r_textures_shutdown, r_textures_newmap, r_textures_devicelost, r_textures_devicerestored);
 }
@@ -1794,13 +1796,20 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
                        Con_Printf("^1%s: invalid DXT1 DDS image\n", filename);
                        return NULL;
                }
-               for (i = 0;i < size;i += bytesperblock)
-                       if (ddspixels[i+0] + ddspixels[i+1] * 256 <= ddspixels[i+2] + ddspixels[i+3] * 256)
-                               break;
-               if (i < size)
-                       textype = TEXTYPE_DXT1A;
-               else
+               if(r_texture_dds_load_dxt1_noalpha.integer)
+               {
                        flags &= ~TEXF_ALPHA;
+               }
+               else
+               {
+                       for (i = 0;i < size;i += bytesperblock)
+                               if (ddspixels[i+0] + ddspixels[i+1] * 256 <= ddspixels[i+2] + ddspixels[i+3] * 256)
+                                       break;
+                       if (i < size)
+                               textype = TEXTYPE_DXT1A;
+                       else
+                               flags &= ~TEXF_ALPHA;
+               }
        }
        else if (!memcmp(dds+84, "DXT3", 4))
        {