If texture names can have map-specific prefixes, shaders must also.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5912 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-06-22 14:40:53 +00:00
parent 27831f7265
commit 2363b05216
23 changed files with 77 additions and 69 deletions

View file

@ -1038,7 +1038,7 @@ static qboolean QDECL Plug_Con_SetConsoleString(const char *conname, const char
if (con->backshader)
R_UnloadShader(con->backshader);
if (qrenderer != QR_NONE)
con->backshader = R_RegisterCustom(va("consolevid_%s", con->name), SUF_NONE, Shader_DefaultCinematic, value);
con->backshader = R_RegisterCustom(NULL, va("consolevid_%s", con->name), SUF_NONE, Shader_DefaultCinematic, value);
else
con->backshader = NULL;
}

View file

@ -746,7 +746,7 @@ int UI_Cin_Play(const char *name, int x, int y, int w, int h, unsigned int flags
break; //this slot is usable
}
mediashader = R_RegisterCustom(name, SUF_NONE, Shader_DefaultCinematic, va("video/%s", name));
mediashader = R_RegisterCustom(NULL, name, SUF_NONE, Shader_DefaultCinematic, va("video/%s", name));
if (!mediashader)
return -1; //wtf?
cin = R_ShaderGetCinematic(mediashader);

View file

@ -2121,7 +2121,7 @@ static void CLQ2_AddPacketEntities (q2frame_t *frame)
ent.shaderRGBAf[0] = (!!(renderfx & Q2RF_SHELL_RED));
ent.shaderRGBAf[1] = (!!(renderfx & Q2RF_SHELL_GREEN));
ent.shaderRGBAf[2] = (!!(renderfx & Q2RF_SHELL_BLUE));
ent.forcedshader = R_RegisterCustom("q2/shell", SUF_NONE, Shader_DefaultSkinShell, NULL);
ent.forcedshader = R_RegisterCustom(NULL, "q2/shell", SUF_NONE, Shader_DefaultSkinShell, NULL);
ent.fatness = 2;
V_AddEntity (&ent);
ent.fatness = 0;

View file

@ -2296,7 +2296,7 @@ static int Con_DrawConsoleLines(console_t *con, conline_t *l, float displayscrol
{
char *fl = Info_ValueForKey(linkinfo, "imgtype");
if (*fl)
pic = R_RegisterCustom(imgname, atoi(fl), NULL, NULL);
pic = R_RegisterCustom(NULL, imgname, atoi(fl), NULL, NULL);
else
pic = R_RegisterPic(imgname, NULL);
if (pic)
@ -2844,7 +2844,7 @@ static void Con_DrawMouseOver(console_t *mouseconsole)
{
char *fl = Info_ValueForKey(info, "tipimgtype");
if (*fl)
shader = R_RegisterCustom(key, atoi(fl), NULL, NULL);
shader = R_RegisterCustom(NULL, key, atoi(fl), NULL, NULL);
else
shader = R2D_SafeCachePic(key);
}

View file

@ -2583,7 +2583,7 @@ static qboolean Media_BeginNextFilm(void)
return false;
}
videoshader = R_RegisterCustom(sname, SUF_NONE, Shader_DefaultCinematic, p->name);
videoshader = R_RegisterCustom(NULL, sname, SUF_NONE, Shader_DefaultCinematic, p->name);
cin = R_ShaderGetCinematic(videoshader);
if (cin)
@ -2885,7 +2885,7 @@ void Media_PlayVideoWindowed_f (void)
console_t *con;
if (!qrenderer)
return;
s = R_RegisterCustom(va("consolevid_%s", videomap), SUF_NONE, Shader_DefaultCinematic, videomap);
s = R_RegisterCustom(NULL, va("consolevid_%s", videomap), SUF_NONE, Shader_DefaultCinematic, videomap);
if (!R_ShaderGetCinematic(s))
{
R_UnloadShader(s);

View file

@ -719,7 +719,7 @@ static void P_LoadTexture(part_type_t *ptype, qboolean warn)
case BM_RTSMOKE: bmpostfix = "#RTSMOKE"; break;
}
/*try and load the shader, fail if we would need to generate one*/
ptype->looks.shader = R_RegisterCustom(va("%s%s", ptype->texname, bmpostfix), SUF_NONE, NULL, NULL);
ptype->looks.shader = R_RegisterCustom(NULL, va("%s%s", ptype->texname, bmpostfix), SUF_NONE, NULL, NULL);
}
else
ptype->looks.shader = NULL;

View file

@ -910,7 +910,7 @@ void QCBUILTIN PF_shaderforname (pubprogfuncs_t *prinst, struct globalvars_s *pr
if (*defaultbody)
shad = R_RegisterShader(str, SUF_NONE, defaultbody);
else
shad = R_RegisterSkin(str, NULL);
shad = R_RegisterSkin(NULL, str);
if (shad)
G_FLOAT(OFS_RETURN) = shad->id+1;
else

View file

@ -1589,7 +1589,7 @@ static shader_t *PR_R_PolygonShader(const char *shadername, qboolean twod)
else if (twod)
shader = R_RegisterPic(shadername, NULL);
else
shader = R_RegisterCustom(shadername, 0, Shader_PolygonShader, NULL);
shader = R_RegisterCustom(NULL, shadername, 0, Shader_PolygonShader, NULL);
return shader;
}

View file

@ -803,7 +803,7 @@ void QCBUILTIN PF_CL_is_cached_pic (pubprogfuncs_t *prinst, struct globalvars_s
{
const char *str;
str = PR_GetStringOfs(prinst, OFS_PARM0);
G_FLOAT(OFS_RETURN) = !!R_RegisterCustom(str, SUF_2D, NULL, NULL);
G_FLOAT(OFS_RETURN) = !!R_RegisterCustom(NULL, str, SUF_2D, NULL, NULL);
}
void QCBUILTIN PF_CL_precache_pic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -1231,7 +1231,7 @@ void QCBUILTIN PF_SubConGetSet (pubprogfuncs_t *prinst, struct globalvars_s *pr_
Q_strncpyz(con->backimage, "", sizeof(con->backimage));
if (con->backshader)
R_UnloadShader(con->backshader);
con->backshader = R_RegisterCustom(va("consolevid_%s", con->name), SUF_NONE, Shader_DefaultCinematic, value);
con->backshader = R_RegisterCustom(NULL, va("consolevid_%s", con->name), SUF_NONE, Shader_DefaultCinematic, value);
}
}
}

View file

@ -464,7 +464,7 @@ mpic_t *R2D_SafePicFromWad (const char *name)
shader_t *s;
if (!qrenderer)
return NULL;
s = R_RegisterCustom (va("gfx/%s", name), SUF_2D, Shader_Default2D, "wad");
s = R_RegisterCustom (NULL, va("gfx/%s", name), SUF_2D, Shader_Default2D, "wad");
return s;
}
@ -1032,7 +1032,7 @@ void QDECL R2D_Conback_Callback(struct cvar_s *var, char *oldvalue)
if (!R_GetShaderSizes(conback, NULL, NULL, true))
{
conback = R_RegisterCustom("console", SUF_2D, NULL, NULL); //quake3
conback = R_RegisterCustom(NULL, "console", SUF_2D, NULL, NULL); //quake3
if (!R_GetShaderSizes(conback, NULL, NULL, true))
{
#ifdef HEXEN2

View file

@ -3150,7 +3150,7 @@ void R_GeneratedWorldEBO(void *ctx, void *data, size_t a_, size_t b_)
//while we could figure out this info, there would be a lot of vertexes that are not referenced, which would be horrendously slow.
if (b->shader->flags & SHADER_SKY)
continue;
b->shader = R_RegisterShader_Vertex("unsupported");
b->shader = R_RegisterShader_Vertex(mod, "unsupported");
}
m->numvertexes = webostate->batches[i].b.vbo->vertcount;

View file

@ -3301,7 +3301,7 @@ void Mod_LoadAliasShaders(model_t *mod)
if ((ai->csurface.flags & 0x80) || dpcompat_skinfiles.ival) //nodraw
f->shader = R_RegisterShader(f->shadername, SUF_NONE, "{\nsurfaceparm nodraw\nsurfaceparm nodlight\nsurfaceparm nomarks\nsurfaceparm noshadows\n}\n");
else
f->shader = R_RegisterSkin(f->shadername, mod->name);
f->shader = R_RegisterSkin(mod, f->shadername);
}
else
f->shader = R_RegisterShader(f->shadername, SUF_NONE, f->defaultshader);

View file

@ -2090,6 +2090,8 @@ float MSG_ReadCoord (void)
coorddata c = {{0}};
if (net_message.prim.coordtype == COORDTYPE_UNDEFINED)
net_message.prim.coordtype = COORDTYPE_FIXED_13_3;
if ((net_message.prim.coordtype&COORDTYPE_SIZE_MASK)>sizeof(c))
return 0;
MSG_ReadData(c.b, net_message.prim.coordtype&COORDTYPE_SIZE_MASK);
return MSG_FromCoord(c, net_message.prim.coordtype);
}

View file

@ -2276,13 +2276,13 @@ bspx_header_t *BSPX_Setup(model_t *mod, char *filebase, size_t filelen, lump_t *
if (h->lumps[i].fileofs + h->lumps[i].filelen > filelen)
return NULL; //some sort of corruption/truncation.
if (offs < lumps->fileofs + lumps->filelen)
offs = lumps->fileofs + lumps->filelen;
if (offs < h->lumps[i].fileofs + h->lumps[i].filelen)
offs = h->lumps[i].fileofs + h->lumps[i].filelen;
}
}
}
if (offs < filelen && !mod->archive && mod_loadmappackages.ival)
if (offs < filelen && mod && !mod->archive && mod_loadmappackages.ival)
{ //we have some sort of trailing junk... is it a zip?...
vfsfile_t *f = VFSPIPE_Open(1,true);
if (f)

View file

@ -295,7 +295,7 @@ skinid_t Mod_ReadSkinFile(const char *skinname, const char *skintext)
Q_strncpyz(skin->mappings[skin->nummappings].surface, com_token, sizeof(skin->mappings[skin->nummappings].surface));
skintext = COM_ParseToken(skintext, NULL);
Q_strncpyz(shadername, com_token, sizeof(shadername));
skin->mappings[skin->nummappings].shader = R_RegisterSkin(shadername, skin->skinname);
skin->mappings[skin->nummappings].shader = R_RegisterSkin(NULL, shadername);
R_BuildDefaultTexnums(NULL, skin->mappings[skin->nummappings].shader, 0);
skin->mappings[skin->nummappings].texnums = *skin->mappings[skin->nummappings].shader->defaulttextures;
skin->mappings[skin->nummappings].needsfree = false;
@ -317,7 +317,7 @@ skinid_t Mod_ReadSkinFile(const char *skinname, const char *skintext)
Q_strncpyz(skin->mappings[skin->nummappings].surface, com_token, sizeof(skin->mappings[skin->nummappings].surface));
skintext = COM_ParseToken(skintext, NULL);
Q_strncpyz(shadername, com_token, sizeof(shadername));
skin->mappings[skin->nummappings].shader = R_RegisterSkin(shadername, skin->skinname);
skin->mappings[skin->nummappings].shader = R_RegisterSkin(NULL, shadername);
R_BuildDefaultTexnums(NULL, skin->mappings[skin->nummappings].shader, 0);
skin->mappings[skin->nummappings].texnums = *skin->mappings[skin->nummappings].shader->defaulttextures;
@ -396,7 +396,7 @@ skinid_t Mod_ReadSkinFile(const char *skinname, const char *skintext)
Q_strncpyz(skin->mappings[skin->nummappings].surface, com_token, sizeof(skin->mappings[skin->nummappings].surface));
skintext = COM_ParseToken(skintext+1, NULL);
Q_strncpyz(shadername, com_token, sizeof(shadername));
skin->mappings[skin->nummappings].shader = R_RegisterCustom (shadername, 0, Shader_DefaultSkin, NULL);
skin->mappings[skin->nummappings].shader = R_RegisterCustom (NULL, shadername, 0, Shader_DefaultSkin, NULL);
R_BuildDefaultTexnums(NULL, skin->mappings[skin->nummappings].shader, 0);
skin->mappings[skin->nummappings].texnums = *skin->mappings[skin->nummappings].shader->defaulttextures;
skin->mappings[skin->nummappings].needsfree = false;
@ -661,7 +661,7 @@ static shader_t *GL_ChooseSkin(galiasinfo_t *inf, model_t *model, int surfnum, e
if (inf->numskins < e->skinnum && e->skinnum >= r_globalskin_first.ival && e->skinnum < r_globalskin_first.ival+r_globalskin_count.ival)
{
shader_t *s;
s = R_RegisterSkin(va("gfx/skin%d.lmp", e->skinnum), NULL);
s = R_RegisterSkin(NULL, va("gfx/skin%d.lmp", e->skinnum));
if (s)
{
if (!TEXVALID(s->defaulttextures->base))
@ -813,7 +813,7 @@ static shader_t *GL_ChooseSkin(galiasinfo_t *inf, model_t *model, int surfnum, e
{
*forcedtex = &cm->texnum;
if (!shader)
shader = R_RegisterSkin(skinname, NULL);
shader = R_RegisterSkin(model, skinname);
return shader;
}
}
@ -847,7 +847,7 @@ static shader_t *GL_ChooseSkin(galiasinfo_t *inf, model_t *model, int surfnum, e
//q2 has no surfaces in its player models, so don't crash from that
//note that q2 should also always have a custom skin set. its not our problem (here) if it doesn't.
if (!shader)
shader = R_RegisterSkin(skinname, NULL);
shader = R_RegisterSkin(model, skinname);
cm->texnum.bump = shader->defaulttextures->bump; //can't colour bumpmapping
if (plskin)

View file

@ -4203,7 +4203,7 @@ static qboolean GLBE_RegisterLightShader(int mode)
);
shaderstate.inited_shader_light[mode] = true;
shaderstate.shader_light[mode] = R_RegisterCustom(name, SUF_NONE, Shader_LightPass, NULL);
shaderstate.shader_light[mode] = R_RegisterCustom(NULL, name, SUF_NONE, Shader_LightPass, NULL);
}
if (shaderstate.shader_light[mode])

View file

@ -159,7 +159,7 @@ static void QDECL Terr_LoadSectionTextures(hmsection_t *s)
}
for (w = s->water; w; w = w->next)
{
w->shader = R_RegisterCustom (w->shadername, SUF_NONE, Shader_DefaultWaterShader, NULL);
w->shader = R_RegisterCustom (NULL, w->shadername, SUF_NONE, Shader_DefaultWaterShader, NULL);
R_BuildDefaultTexnums(NULL, w->shader, IF_WORLDTEX); //this might get expensive. hideously so.
}
#endif
@ -5505,7 +5505,7 @@ void Terr_FinishTerrain(model_t *mod)
{
if (*hm->skyname)
{
hm->skyshader = R_RegisterCustom(va("skybox_%s", hm->skyname), SUF_NONE, Shader_DefaultSkybox, NULL);
hm->skyshader = R_RegisterCustom(mod, va("skybox_%s", hm->skyname), SUF_NONE, Shader_DefaultSkybox, NULL);
if (!hm->skyshader->skydome)
hm->skyshader = NULL;
}
@ -5930,13 +5930,13 @@ void Terr_Brush_Draw(heightmap_t *hm, batch_t **batches, entity_t *e)
const miptex_t *tx = NULL;
#endif
bt->shader = R_RegisterCustom (va("textures/%s", bt->shadername), SUF_LIGHTMAP, NULL, NULL);
bt->shader = R_RegisterCustom (NULL, va("textures/%s", bt->shadername), SUF_LIGHTMAP, NULL, NULL);
if (!bt->shader)
{
if (!Q_strcasecmp(bt->shadername, "clip") || !Q_strcasecmp(bt->shadername, "hint") || !Q_strcasecmp(bt->shadername, "skip"))
bt->shader = R_RegisterShader(bt->shadername, SUF_LIGHTMAP, "{\nsurfaceparm nodraw\n}");
else
bt->shader = R_RegisterCustom (bt->shadername, SUF_LIGHTMAP, Shader_DefaultBSPQ1, NULL);
bt->shader = R_RegisterCustom (NULL, bt->shadername, SUF_LIGHTMAP, Shader_DefaultBSPQ1, NULL);
// bt->shader = R_RegisterShader_Lightmap(bt->shadername);
}

View file

@ -1592,7 +1592,7 @@ void R_HalfLife_GenerateBatches(entity_t *rent, batch_t **batches)
if (s->defaultshadertext)
s->shader = R_RegisterShader(s->name, SUF_NONE, s->defaultshadertext);
else
s->shader = R_RegisterSkin(s->name, rent->model->name);
s->shader = R_RegisterSkin(rent->model, s->name);
// R_BuildDefaultTexnums(&s->defaulttex, s->shader, 0);
}

View file

@ -1439,7 +1439,7 @@ static const char *Mod_RemapBuggyTexture(const char *name, const qbyte *data, un
return NULL;
}
static void Mod_FinishTexture(texture_t *tx, const char *loadname, qboolean safetoloadfromwads)
static void Mod_FinishTexture(model_t *mod, texture_t *tx, const char *loadname, qboolean safetoloadfromwads)
{
extern cvar_t gl_shadeq1_name;
char altname[MAX_QPATH];
@ -1470,7 +1470,7 @@ static void Mod_FinishTexture(texture_t *tx, const char *loadname, qboolean safe
shadername = altname;
}
tx->shader = R_RegisterCustom (shadername, SUF_LIGHTMAP, Shader_DefaultBSPQ1, NULL);
tx->shader = R_RegisterCustom (mod, shadername, SUF_LIGHTMAP, Shader_DefaultBSPQ1, NULL);
if (!tx->srcdata && !safetoloadfromwads)
return;
@ -1523,7 +1523,7 @@ void Mod_NowLoadExternal(model_t *loadmodel)
if (tx->srcdata)
continue;
Mod_FinishTexture(tx, loadname, true);
Mod_FinishTexture(loadmodel, tx, loadname, true);
}
#endif
}
@ -5073,7 +5073,7 @@ void ModBrush_LoadGLStuff(void *ctx, void *data, size_t a, size_t b)
{ //submodels share textures, so only do this if 'a' is 0 (inline index, 0 = world).
for (a = 0; a < mod->numfogs; a++)
{
mod->fogs[a].shader = R_RegisterShader_Lightmap(mod->fogs[a].shadername);
mod->fogs[a].shader = R_RegisterShader_Lightmap(mod, mod->fogs[a].shadername);
R_BuildDefaultTexnums(NULL, mod->fogs[a].shader, IF_WORLDTEX);
if (!mod->fogs[a].shader->fog_dist)
{
@ -5090,10 +5090,10 @@ void ModBrush_LoadGLStuff(void *ctx, void *data, size_t a, size_t b)
{
for(a = 0; a < mod->numtexinfo; a++)
{
mod->textures[a]->shader = R_RegisterShader_Lightmap(va("%s#BUMPMODELSPACE", mod->textures[a]->name));
mod->textures[a]->shader = R_RegisterShader_Lightmap(mod, va("%s#BUMPMODELSPACE", mod->textures[a]->name));
R_BuildDefaultTexnums(NULL, mod->textures[a]->shader, IF_WORLDTEX);
mod->textures[a+mod->numtexinfo]->shader = R_RegisterShader_Vertex (va("%s#VERTEXLIT", mod->textures[a+mod->numtexinfo]->name));
mod->textures[a+mod->numtexinfo]->shader = R_RegisterShader_Vertex (mod, va("%s#VERTEXLIT", mod->textures[a+mod->numtexinfo]->name));
R_BuildDefaultTexnums(NULL, mod->textures[a+mod->numtexinfo]->shader, IF_WORLDTEX);
}
}
@ -5101,14 +5101,14 @@ void ModBrush_LoadGLStuff(void *ctx, void *data, size_t a, size_t b)
{
for(a = 0; a < mod->numtexinfo; a++)
{
mod->textures[a]->shader = R_RegisterShader_Lightmap(mod->textures[a]->name);
mod->textures[a]->shader = R_RegisterShader_Lightmap(mod, mod->textures[a]->name);
R_BuildDefaultTexnums(NULL, mod->textures[a]->shader, IF_WORLDTEX);
mod->textures[a+mod->numtexinfo]->shader = R_RegisterShader_Vertex (va("%s#VERTEXLIT", mod->textures[a+mod->numtexinfo]->name));
mod->textures[a+mod->numtexinfo]->shader = R_RegisterShader_Vertex (mod, va("%s#VERTEXLIT", mod->textures[a+mod->numtexinfo]->name));
R_BuildDefaultTexnums(NULL, mod->textures[a+mod->numtexinfo]->shader, IF_WORLDTEX);
}
}
mod->textures[2*mod->numtexinfo]->shader = R_RegisterShader_Flare("noshader");
mod->textures[2*mod->numtexinfo]->shader = R_RegisterShader_Flare(mod, "noshader");
}
else
#endif
@ -5119,7 +5119,7 @@ void ModBrush_LoadGLStuff(void *ctx, void *data, size_t a, size_t b)
for(a = 0; a < mod->numtextures; a++)
{
unsigned int maps = 0;
mod->textures[a]->shader = R_RegisterCustom (mod->textures[a]->name, SUF_LIGHTMAP, Shader_DefaultBSPQ2, NULL);
mod->textures[a]->shader = R_RegisterCustom (mod, mod->textures[a]->name, SUF_LIGHTMAP, Shader_DefaultBSPQ2, NULL);
maps |= SHADER_HASPALETTED;
maps |= SHADER_HASDIFFUSE;
@ -5141,7 +5141,7 @@ void ModBrush_LoadGLStuff(void *ctx, void *data, size_t a, size_t b)
if (!strncmp(loadname, "b_", 2))
Q_strncpyz(loadname, "bmodels", sizeof(loadname));
for(a = 0; a < mod->numtextures; a++)
Mod_FinishTexture(mod->textures[a], loadname, false);
Mod_FinishTexture(mod, mod->textures[a], loadname, false);
}
}
Mod_Batches_Build(mod, data);

View file

@ -2074,7 +2074,7 @@ void GLR_RenderView (void)
if (r_fxaa.ival)
r_refdef.flags |= RDF_ANTIALIAS;
if (*r_postprocshader.string)
custompostproc = R_RegisterCustom(r_postprocshader.string, SUF_NONE, NULL, NULL);
custompostproc = R_RegisterCustom(NULL, r_postprocshader.string, SUF_NONE, NULL, NULL);
else if (!r_graphics.ival)
custompostproc = R_RegisterShader("postproc_ascii", 0,
"{\n"

View file

@ -2787,12 +2787,12 @@ static void Shader_BEMode(parsestate_t *ps, const char **ptr)
""
#endif
);
shader->bemoverrides[mode] = R_RegisterCustom(subname, shader->usageflags|(embed?SUR_FORCEFALLBACK:0), embed?Shader_DefaultScript:NULL, embed);
shader->bemoverrides[mode] = R_RegisterCustom(shader->model, subname, shader->usageflags|(embed?SUR_FORCEFALLBACK:0), embed?Shader_DefaultScript:NULL, embed);
}
}
else
{
shader->bemoverrides[mode] = R_RegisterCustom(tokencopy, shader->usageflags|(embed?SUR_FORCEFALLBACK:0), embed?Shader_DefaultScript:NULL, embed);
shader->bemoverrides[mode] = R_RegisterCustom(shader->model, tokencopy, shader->usageflags|(embed?SUR_FORCEFALLBACK:0), embed?Shader_DefaultScript:NULL, embed);
}
if (embed)
BZ_Free(embed);
@ -4363,6 +4363,7 @@ void Shader_Reset(shader_t *s)
float dtrate = s->defaulttextures_fps; //FIXME!
int w = s->width;
int h = s->height;
model_t *mod = s->model;
unsigned int uf = s->usageflags;
Q_strncpyz(name, s->name, sizeof(name));
s->genargs = NULL;
@ -4375,6 +4376,7 @@ void Shader_Reset(shader_t *s)
s->id = id;
s->width = w;
s->height = h;
s->model = mod;
s->defaulttextures = dt;
s->numdefaulttextures = dtcount;
s->defaulttextures_fps = dtrate;
@ -7339,7 +7341,7 @@ void R_UnloadShader(shader_t *shader)
if (--shader->uses == 0)
Shader_Free(shader);
}
static shader_t *R_LoadShader (const char *name, unsigned int usageflags, shader_gen_t *defaultgen, const char *genargs)
static shader_t *R_LoadShader (model_t *mod, const char *name, unsigned int usageflags, shader_gen_t *defaultgen, const char *genargs)
{
int i, f = -1;
char cleanname[MAX_QPATH];
@ -7357,6 +7359,7 @@ static shader_t *R_LoadShader (const char *name, unsigned int usageflags, shader
s = Hash_Get(&shader_active_hash, cleanname);
while (s)
{
if (!mod || s->model == mod)
//make sure the same texture can be used as either a lightmap or vertexlit shader
//if it has an explicit shader overriding it then that still takes precidence. we might just have multiple copies of it.
//q3 has a separate (internal) shader for every lightmap.
@ -7432,6 +7435,7 @@ static shader_t *R_LoadShader (const char *name, unsigned int usageflags, shader
memset(s->defaulttextures, 0, sizeof(*s->defaulttextures));
s->numdefaulttextures = 0;
Q_strncpyz(s->name, cleanname, sizeof(s->name));
s->model = mod;
s->usageflags = usageflags;
s->generator = defaultgen;
s->width = 0;
@ -7904,11 +7908,11 @@ char *Shader_GetShaderBody(shader_t *s, char *fname, size_t fnamesize)
void Shader_ShowShader_f(void)
{
char *sourcename = Cmd_Argv(1);
shader_t *o = R_LoadShader(sourcename, SUF_NONE, NULL, NULL);
shader_t *o = R_LoadShader(NULL, sourcename, SUF_NONE, NULL, NULL);
if (!o)
o = R_LoadShader(sourcename, SUF_LIGHTMAP, NULL, NULL);
o = R_LoadShader(NULL, sourcename, SUF_LIGHTMAP, NULL, NULL);
if (!o)
o = R_LoadShader(sourcename, SUF_2D, NULL, NULL);
o = R_LoadShader(NULL, sourcename, SUF_2D, NULL, NULL);
if (o)
{
char fname[256];
@ -8144,7 +8148,7 @@ void R_RemapShader(const char *sourcename, const char *destname, float timeoffse
{
if (!strncmp(o->name, cleansrcname, l) && (!o->name[l] || o->name[l]=='#'))
{
n = R_LoadShader (va("%s%s", destname, o->name+l), o->usageflags, NULL, NULL);
n = R_LoadShader (o->model, va("%s%s", destname, o->name+l), o->usageflags, NULL, NULL);
if (!n)
{ //if it isn't actually available on disk then don't care about usageflags, just find ANY that's already loaded.
// check the hash first
@ -8305,31 +8309,31 @@ int R_GetShaderSizes(shader_t *shader, int *width, int *height, qboolean blockti
shader_t *R_RegisterPic (const char *name, const char *subdirs)
{
shader_t *shader;
shader = R_LoadShader (name, SUF_2D, Shader_Default2D, subdirs);
shader = R_LoadShader (NULL, name, SUF_2D, Shader_Default2D, subdirs);
return shader;
}
shader_t *QDECL R_RegisterShader (const char *name, unsigned int usageflags, const char *shaderscript)
{
return R_LoadShader (name, usageflags, Shader_DefaultScript, shaderscript);
return R_LoadShader (NULL, name, usageflags, Shader_DefaultScript, shaderscript);
}
shader_t *R_RegisterShader_Lightmap (const char *name)
shader_t *R_RegisterShader_Lightmap (model_t *mod, const char *name)
{
return R_LoadShader (name, SUF_LIGHTMAP, Shader_DefaultBSPLM, NULL);
return R_LoadShader (mod, name, SUF_LIGHTMAP, Shader_DefaultBSPLM, NULL);
}
shader_t *R_RegisterShader_Vertex (const char *name)
shader_t *R_RegisterShader_Vertex (model_t *mod, const char *name)
{
return R_LoadShader (name, 0, Shader_DefaultBSPVertex, NULL);
return R_LoadShader (mod, name, 0, Shader_DefaultBSPVertex, NULL);
}
shader_t *R_RegisterShader_Flare (const char *name)
shader_t *R_RegisterShader_Flare (model_t *mod, const char *name)
{
return R_LoadShader (name, 0, Shader_DefaultBSPFlare, NULL);
return R_LoadShader (mod, name, 0, Shader_DefaultBSPFlare, NULL);
}
shader_t *QDECL R_RegisterSkin (const char *shadername, const char *modname)
shader_t *QDECL R_RegisterSkin (model_t *mod, const char *shadername)
{
char newsname[MAX_QPATH];
shader_t *shader;
@ -8339,8 +8343,9 @@ shader_t *QDECL R_RegisterSkin (const char *shadername, const char *modname)
#endif
newsname[0] = 0;
if (modname && !strchr(shadername, '/') && *shadername)
if (mod && !strchr(shadername, '/') && *shadername)
{
char *modname = mod->name;
char *b = COM_SkipPath(modname);
if (b != modname && b-modname + strlen(shadername)+1 < sizeof(newsname))
{
@ -8356,11 +8361,11 @@ shader_t *QDECL R_RegisterSkin (const char *shadername, const char *modname)
}
else
Q_strncpyz(newsname, "models", sizeof(newsname));
shader = R_LoadShader (shadername, 0, Shader_DefaultSkin, newsname);
shader = R_LoadShader (mod, shadername, 0, Shader_DefaultSkin, newsname);
return shader;
}
shader_t *R_RegisterCustom (const char *name, unsigned int usageflags, shader_gen_t *defaultgen, const void *args)
shader_t *R_RegisterCustom (model_t *mod, const char *name, unsigned int usageflags, shader_gen_t *defaultgen, const void *args)
{
return R_LoadShader (name, usageflags, defaultgen, args);
return R_LoadShader (mod, name, usageflags, defaultgen, args);
}
#endif //SERVERONLY

View file

@ -600,6 +600,7 @@ enum
struct shader_s
{
char name[MAX_QPATH];
struct model_s *model;
enum {
SUF_NONE = 0,
SUF_LIGHTMAP = 1<<0, //$lightmap passes are valid. otherwise collapsed to an rgbgen
@ -720,11 +721,11 @@ void R_UnloadShader(shader_t *shader);
int R_GetShaderSizes(shader_t *shader, int *width, int *height, qboolean blocktillloaded);
shader_t *R_RegisterPic (const char *name, const char *subdirs);
shader_t *QDECL R_RegisterShader (const char *name, unsigned int usageflags, const char *shaderscript);
shader_t *R_RegisterShader_Lightmap (const char *name);
shader_t *R_RegisterShader_Vertex (const char *name);
shader_t *R_RegisterShader_Flare (const char *name);
shader_t *QDECL R_RegisterSkin (const char *shadername, const char *modname);
shader_t *R_RegisterCustom (const char *name, unsigned int usageflags, shader_gen_t *defaultgen, const void *args);
shader_t *R_RegisterShader_Lightmap (model_t *mod, const char *name);
shader_t *R_RegisterShader_Vertex (model_t *mod, const char *name);
shader_t *R_RegisterShader_Flare (model_t *mod, const char *name);
shader_t *QDECL R_RegisterSkin (model_t *mod, const char *shadername);
shader_t *R_RegisterCustom (model_t *mod, const char *name, unsigned int usageflags, shader_gen_t *defaultgen, const void *args);
//once loaded, most shaders should have one of the following two calls used upon it
void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader, unsigned int imageflags);
void QDECL R_BuildLegacyTexnums(shader_t *shader, const char *fallbackname, const char *subpath, unsigned int loadflags, unsigned int imageflags, uploadfmt_t basefmt, size_t width, size_t height, qbyte *mipdata, qbyte *palette);

View file

@ -2756,7 +2756,7 @@ void VK_R_RenderView (void)
{
if (*r_postprocshader.string)
{
custompostproc = R_RegisterCustom(r_postprocshader.string, SUF_NONE, NULL, NULL);
custompostproc = R_RegisterCustom(NULL, r_postprocshader.string, SUF_NONE, NULL, NULL);
if (custompostproc)
r_refdef.flags |= RDF_CUSTOMPOSTPROC;
}