]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Support alpha textures in Quake if the name starts with '{'.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Aug 2016 15:28:24 +0000 (15:28 +0000)
committerRudolf Polzer <divVerent@xonotic.org>
Thu, 18 Aug 2016 15:42:49 +0000 (17:42 +0200)
Note: this is actually a HLBSP feature, though:

Author: ericw on irc.anynet.org

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12272 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=c704a467c00fc5b703d88b7076db434df4810864

gl_rmain.c
model_brush.c
palette.c
palette.h

index 6f00380358f82c8527d4bc3b98a8d15235246e0d..58b5e7042535c9618066a98f9156aebb2f44d8db 100644 (file)
@@ -3694,6 +3694,9 @@ skinframe_t *R_SkinFrame_LoadInternalQuake(const char *name, int textureflags, i
                featuresmask |= palette_featureflags[skindata[i]];
 
        skinframe->hasalpha = false;
+       // fence textures
+       if (name[0] == '{')
+               skinframe->hasalpha = true;
        skinframe->qhascolormapping = loadpantsandshirt && (featuresmask & (PALETTEFEATURE_PANTS | PALETTEFEATURE_SHIRT));
        skinframe->qgeneratenmap = r_shadow_bumpscale_basetexture.value > 0;
        skinframe->qgeneratemerged = true;
@@ -3750,7 +3753,10 @@ static void R_SkinFrame_GenerateTexturesFromQPixels(skinframe_t *skinframe, qboo
        if (skinframe->qgenerateglow)
        {
                skinframe->qgenerateglow = false;
-               skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_onlyfullbrights); // glow
+               if (skinframe->hasalpha) // fence textures
+                       skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags | TEXF_ALPHA, -1, palette_bgra_onlyfullbrights_transparent); // glow
+               else
+                       skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_onlyfullbrights); // glow
        }
 
        if (colormapped)
@@ -3763,7 +3769,10 @@ static void R_SkinFrame_GenerateTexturesFromQPixels(skinframe_t *skinframe, qboo
        else
        {
                skinframe->qgeneratemerged = false;
-               skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, skinframe->glow ? palette_bgra_nofullbrights : palette_bgra_complete);
+               if (skinframe->hasalpha) // fence textures
+                       skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags | TEXF_ALPHA, -1, skinframe->glow ? palette_bgra_nofullbrights_transparent : palette_bgra_transparent);
+               else
+                       skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, skinframe->glow ? palette_bgra_nofullbrights : palette_bgra_complete);
        }
 
        if (!skinframe->qgeneratemerged && !skinframe->qgeneratebase)
index ce195bd2f9078a3c62f2e193346e20b121e2220f..2761d7d670d38b7d2f6e7e559789b5e80f9ea65b 100644 (file)
@@ -1880,6 +1880,10 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb)
                        if (tx->skinframes[0] && tx->skinframes[0]->hasalpha)
                                tx->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
                }
+               else if (tx->name[0] == '{') // fence textures
+               {
+                       tx->basematerialflags |= MATERIALFLAG_ALPHATEST | MATERIALFLAG_NOSHADOW;
+               }
                else if (!strncmp(tx->name, "mirror", 6)) // Tenebrae
                {
                        // replace the texture with black
index 7b6fb8d6bbc0b9bfb86e5b59bed5d7288731a5e6..8df19dabba2b6eab9b42e0a56b555917a22203f0 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -16,7 +16,9 @@ unsigned int palette_bgra_alpha[256];
 unsigned int palette_bgra_nocolormap[256];
 unsigned int palette_bgra_nocolormapnofullbrights[256];
 unsigned int palette_bgra_nofullbrights[256];
+unsigned int palette_bgra_nofullbrights_transparent[256];
 unsigned int palette_bgra_onlyfullbrights[256];
+unsigned int palette_bgra_onlyfullbrights_transparent[256];
 unsigned int palette_bgra_pantsaswhite[256];
 unsigned int palette_bgra_shirtaswhite[256];
 unsigned int palette_bgra_transparent[256];
@@ -133,11 +135,17 @@ static void Palette_SetupSpecialPalettes(void)
                palette_bgra_nofullbrights[i] = palette_bgra_complete[i];
        for (i = fullbright_start;i < fullbright_end;i++)
                palette_bgra_nofullbrights[i] = palette_bgra_complete[0];
+       for (i = 0;i < 256;i++)
+               palette_bgra_nofullbrights_transparent[i] = palette_bgra_nofullbrights[i];
+       palette_bgra_nofullbrights_transparent[transparentcolor] = 0;
 
        for (i = 0;i < 256;i++)
                palette_bgra_onlyfullbrights[i] = 0;
        for (i = fullbright_start;i < fullbright_end;i++)
                palette_bgra_onlyfullbrights[i] = palette_bgra_complete[i];
+       for (i = 0;i < 256;i++)
+               palette_bgra_onlyfullbrights_transparent[i] = palette_bgra_onlyfullbrights[i];
+       palette_bgra_onlyfullbrights_transparent[transparentcolor] = 0;
 
        for (i = 0;i < 256;i++)
                palette_bgra_nocolormapnofullbrights[i] = palette_bgra_complete[i];
index 1b2cd2e77ca760879aeb4de67f88e4d1a682eab9..8658f128442514be1083dc22715235bfcb88c998 100644 (file)
--- a/palette.h
+++ b/palette.h
@@ -22,7 +22,9 @@ extern unsigned int palette_bgra_alpha[256];
 extern unsigned int palette_bgra_nocolormap[256];
 extern unsigned int palette_bgra_nocolormapnofullbrights[256];
 extern unsigned int palette_bgra_nofullbrights[256];
+extern unsigned int palette_bgra_nofullbrights_transparent[256];
 extern unsigned int palette_bgra_onlyfullbrights[256];
+extern unsigned int palette_bgra_onlyfullbrights_transparent[256];
 extern unsigned int palette_bgra_pantsaswhite[256];
 extern unsigned int palette_bgra_shirtaswhite[256];
 extern unsigned int palette_bgra_transparent[256];