shithub: qk1

Download patch

ref: 879855920811b9ac702ba76da9d3c8639b103f2b
parent: ded5393bc7cf05e361bddc4cb5e3d4a8fb08edcd
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Dec 13 18:20:59 EST 2023

bsp30: support fullbrights on textures with ~

--- a/model_bsp30.c
+++ b/model_bsp30.c
@@ -156,9 +156,17 @@
 			if((palsz = le16(x)) > 0){
 				pal3torgbx(p, tx->pixels, pixels, x, palsz);
 				if(tx->name[0] == '{'){
+					/* last color is transparent */
 					for(j = 0; j < pixels; j++){
 						if(p[j] == palsz-1)
 							tx->pixels[j] = 0;
+					}
+				}
+				if(strchr(tx->name, '~') != nil){
+					/* last 32 colors are fullbright */
+					for(j = 0; j < pixels; j++){
+						if(p[j] >= 256-32)
+							tx->pixels[j] &= 0xffffff;
 					}
 				}
 			}
--- a/wad.c
+++ b/wad.c
@@ -159,7 +159,7 @@
 static int
 W_ReadPixelsAt(Wad *wad, char *name, int off, int sz, pixel_t *out, int num)
 {
-	int n, palsz, x;
+	int n, palsz, x, fb;
 	byte *t, *pal;
 
 	num = min(num, sz);
@@ -181,12 +181,13 @@
 			goto err;
 		}
 		palsz *= 3;
-		for(n = 0; n < num; n++, out++){
-			x = (*t++)*3;
-			if(x >= palsz || (wad->ver == WAD_VER3 && name[0] == '{' && x == palsz-3))
+		fb = strchr(name, '~') != nil;
+		for(n = 0; n < num; n++, t++, out++){
+			x = *t*3;
+			if(x >= palsz || (name[0] == '{' && x == palsz-3))
 				*out = 0;
 			else
-				*out = 0xff<<24 | pal[x+0]<<16 | pal[x+1]<<8 | pal[x+2];
+				*out = ((fb && x >= (256-32)*3) ? 0 : 0xff)<<24 | pal[x+0]<<16 | pal[x+1]<<8 | pal[x+2];
 		}
 	}
 	return num;