From 7865011806cf994c9d8abed8049359d46f8e1091 Mon Sep 17 00:00:00 2001 From: Eukara Date: Tue, 22 Jan 2019 00:52:35 +0000 Subject: [PATCH] hlmdl: added "support" for fullbright and chrome materials. still requires GLSL additions upstream. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5389 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/gl/gl_hlmdl.c | 27 +++++++++++++++++++++++---- engine/gl/model_hl.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/engine/gl/gl_hlmdl.c b/engine/gl/gl_hlmdl.c index b6cefd7ac..fbab891df 100644 --- a/engine/gl/gl_hlmdl.c +++ b/engine/gl/gl_hlmdl.c @@ -320,10 +320,29 @@ qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize) for(i = 0; i < texheader->numtextures; i++) { Q_snprintfz(shaders[i].name, sizeof(shaders[i].name), "%s/%s", mod->name, COM_SkipPath(tex[i].name)); - memset(&shaders[i].defaulttex, 0, sizeof(shaders[i].defaulttex)); - shaders[i].defaulttex.base = Image_GetTexture(shaders[i].name, "", IF_NOALPHA, (qbyte *) texheader + tex[i].offset, (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset, tex[i].w, tex[i].h, TF_8PAL24); - shaders[i].w = tex[i].w; - shaders[i].h = tex[i].h; + + /* handle the special textures - eukara */ + if (tex[i].flags) { + char *shader; + if (tex[i].flags & HLMDLFL_FULLBRIGHT) { + if (tex[i].flags & HLMDLFL_CHROME) { + shader = HLSHADER_FULLBRIGHTCHROME; + } else { + shader = HLSHADER_FULLBRIGHT; + } + } else if (tex[i].flags & HLMDLFL_CHROME) { + shader = HLSHADER_CHROME; + } + shaders[i].shader = R_RegisterShader(shaders[i].name, SUF_NONE, shader); + shaders[i].shader->defaulttextures->base = Image_GetTexture(shaders[i].name, "", IF_NOALPHA, (qbyte *) texheader + tex[i].offset, (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset, tex[i].w, tex[i].h, TF_8PAL24); + shaders[i].shader->width = tex[i].w; + shaders[i].shader->height = tex[i].h; + } else { + memset(&shaders[i].defaulttex, 0, sizeof(shaders[i].defaulttex)); + shaders[i].defaulttex.base = Image_GetTexture(shaders[i].name, "", IF_NOALPHA, (qbyte *) texheader + tex[i].offset, (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset, tex[i].w, tex[i].h, TF_8PAL24); + shaders[i].w = tex[i].w; + shaders[i].h = tex[i].h; + } } model->numskinrefs = texheader->skinrefs; diff --git a/engine/gl/model_hl.h b/engine/gl/model_hl.h index d498f4d8e..db7583781 100644 --- a/engine/gl/model_hl.h +++ b/engine/gl/model_hl.h @@ -14,6 +14,38 @@ #define HLPOLYHEADER (('T' << 24) + ('S' << 16) + ('D' << 8) + 'I') /* little-endian "IDST" */ #define HLMDLHEADER "IDST" +/* flags - eukara */ +#define HLMDLFL_FLAT 0x0001 +#define HLMDLFL_CHROME 0x0002 +#define HLMDLFL_FULLBRIGHT 0x0004 + +#define HLSHADER_FULLBRIGHT \ + "{\n" \ + "program defaultskin\n" \ + "{\n" \ + "map $diffuse\n" \ + "}\n" \ + "}\n" + +#define HLSHADER_CHROME \ + "{\n" \ + "program defaultskin#CHROME\n" \ + "{\n" \ + "map $diffuse\n" \ + "tcgen environment\n" \ + "rgbgen lightingdiffuse\n" \ + "}\n" \ + "}\n" + +#define HLSHADER_FULLBRIGHTCHROME \ + "{\n" \ + "program defaultskin#CHROME\n" \ + "{\n" \ + "map $diffuse\n" \ + "tcgen environment\n" \ + "}\n" \ + "}\n" + /* ----------------------------------------------------------------------------------------------------------------------- main model header