Handle masked textures from post-release Half-Life MDL files. (#243)
Half-Life models did not have these flags, but games/mods starting in 2003 and later (Day of Defeat, Condition Zero etc.) use these for plants, trees, cars and anything else desiring masked textures.
This commit is contained in:
parent
76e4258ad3
commit
1c5e82bec7
2 changed files with 43 additions and 0 deletions
|
@ -397,6 +397,11 @@ qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize)
|
|||
Q_snprintfz(shaders[i].name, sizeof(shaders[i].name), "common/hlmodel_fullbright");
|
||||
}
|
||||
}
|
||||
else if ( (tex[i].flags & HLMDLFL_MASKED) || (tex[i].flags & (HLMDLFL_MASKED | HLMDLFL_ALPHASOLID)))
|
||||
{
|
||||
shader = HLSHADER_MASKED;
|
||||
Q_snprintfz(shaders[i].name, sizeof(shaders[i].name), "common/hlmodel_masked");
|
||||
}
|
||||
else if (tex[i].flags & HLMDLFL_CHROME)
|
||||
{
|
||||
shader = HLSHADER_CHROME;
|
||||
|
@ -549,6 +554,32 @@ qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize)
|
|||
Q_snprintfz(texname, sizeof(texname), "%s*%i", mod->name, shaders[i].atlasid);
|
||||
shaders[i].defaulttex.base = Image_GetTexture(texname, "", IF_NOALPHA|IF_NOREPLACE, in, pal, tex[i].w, tex[i].h, TF_8PAL24);
|
||||
}
|
||||
else if (tex[i].flags & HLMDLFL_MASKED)
|
||||
{
|
||||
int k = 0;
|
||||
qbyte *in = (qbyte *) texheader + tex[i].offset;
|
||||
qbyte *pal = (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset;
|
||||
qbyte alphaPal[1024]; /* 256 color 32-bit palette */
|
||||
|
||||
for (k = 0; k < 255; k+= 1) {
|
||||
int p = k * 4;
|
||||
int x = k * 3;
|
||||
alphaPal[p + 0] = pal[x + 0];
|
||||
alphaPal[p + 1] = pal[x + 1];
|
||||
alphaPal[p + 2] = pal[x + 2];
|
||||
alphaPal[p + 3] = 255;
|
||||
}
|
||||
|
||||
/* pal index 255 = always transparent ~eukara */
|
||||
alphaPal[255*4+0] = 0;
|
||||
alphaPal[255*4+1] = 0;
|
||||
alphaPal[255*4+2] = 0;
|
||||
alphaPal[255*4+3] = 0;
|
||||
|
||||
shaders[i].atlasid = j++;
|
||||
Q_snprintfz(texname, sizeof(texname), "%s*%i", mod->name, shaders[i].atlasid);
|
||||
shaders[i].defaulttex.base = Image_GetTexture(texname, "", IF_NOREPLACE, in, alphaPal, tex[i].w, tex[i].h, TF_8PAL32);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#define HLMDLFL_FLAT 0x0001
|
||||
#define HLMDLFL_CHROME 0x0002
|
||||
#define HLMDLFL_FULLBRIGHT 0x0004
|
||||
#define HLMDLFL_MASKED 0x0040
|
||||
#define HLMDLFL_ALPHASOLID 0x0800
|
||||
|
||||
#define HLSHADER_FULLBRIGHT \
|
||||
"{\n" \
|
||||
|
@ -37,6 +39,16 @@
|
|||
"}\n" \
|
||||
"}\n"
|
||||
|
||||
#define HLSHADER_MASKED \
|
||||
"{\n" \
|
||||
"program defaultskin#MASK=0.5\n" \
|
||||
"{\n" \
|
||||
"map $diffuse\n" \
|
||||
"rgbgen lightingdiffuse\n" \
|
||||
"alphaFunc GE128\n" \
|
||||
"}\n" \
|
||||
"}\n"
|
||||
|
||||
#define HLSHADER_FULLBRIGHTCHROME \
|
||||
"{\n" \
|
||||
"program defaultskin#CHROME\n" \
|
||||
|
|
Loading…
Reference in a new issue