WAD3: Handle decals with their 255-index hack.
At least I *think* how this is meant to be handled - looks okay. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5664 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
b8a81d1868
commit
00479d0567
1 changed files with 21 additions and 9 deletions
|
@ -385,7 +385,7 @@ qbyte *W_ConvertWAD3Texture(miptex_t *tex, size_t lumpsize, int *width, int *hei
|
|||
if (tex->width > 0x10000 || tex->height > 0x10000)
|
||||
return NULL;
|
||||
|
||||
//use malloc here if you want, but you'll have to free it again... NUR!
|
||||
//use malloc here if you want, but you'll have to free it again... NUR!
|
||||
data = out = BZ_Malloc(tex->width * tex->height * 4);
|
||||
|
||||
if (!data)
|
||||
|
@ -412,6 +412,12 @@ qbyte *W_ConvertWAD3Texture(miptex_t *tex, size_t lumpsize, int *width, int *hei
|
|||
else
|
||||
pal = host_basepal;
|
||||
|
||||
/* handle decals type textures -eukara */
|
||||
if (alpha == 1 && (pal[765] == 255 && pal[766] == 255 && pal[767] == 255))
|
||||
alpha = 3;
|
||||
if (alpha == 1 && !(pal[765] == 0 && pal[766] == 0 && pal[767] == 255))
|
||||
alpha = 2;
|
||||
|
||||
if (tex->offsets[0] + tex->width * tex->height > lumpsize)
|
||||
{ //fucked texture.
|
||||
for (d = 0;d < tex->width * tex->height;d++)
|
||||
|
@ -423,22 +429,28 @@ qbyte *W_ConvertWAD3Texture(miptex_t *tex, size_t lumpsize, int *width, int *hei
|
|||
out += 4;
|
||||
}
|
||||
}
|
||||
else for (d = 0;d < tex->width * tex->height;d++)
|
||||
else for (d = 0;d < tex->width * tex->height;d++)
|
||||
{
|
||||
p = *in++;
|
||||
if (alpha==1 && p == 255) //only allow alpha on '{' textures
|
||||
if (alpha == 1 && p == 255) {
|
||||
out[0] = out[1] = out[2] = out[3] = 0;
|
||||
else if (alpha == 2)
|
||||
{
|
||||
} else if (alpha == 2) {
|
||||
p *= 3;
|
||||
/* this will be a blended decal -eukara */
|
||||
out[0] = pal[765];
|
||||
out[1] = pal[766];
|
||||
out[2] = pal[767];
|
||||
out[3] = 255 - pal[p];
|
||||
} else if (alpha == 3) {
|
||||
p *= 3;
|
||||
/* this is used for glass and so on -eukara */
|
||||
out[0] = pal[p];
|
||||
out[1] = pal[p+1];
|
||||
out[2] = pal[p+2];
|
||||
out[3] = (out[0]+out[1]+out[2])/3;
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = pal[p];
|
||||
} else {
|
||||
p *= 3;
|
||||
/* non transparent -eukara */
|
||||
out[0] = pal[p];
|
||||
out[1] = pal[p+1];
|
||||
out[2] = pal[p+2];
|
||||
|
|
Loading…
Reference in a new issue