------------------------------------------------------------------------
r4230 | acceptthis | 2013-02-27 12:11:02 +0000 (Wed, 27 Feb 2013) | 2 lines Make sure s+t vectors are actually calculated on q3/rbsp, fixing rtlights. Resort shaders if the sort key changes, fixes issue with r_wateralpha changing without having to hack the other water shader alternatives, thereby fixing particles etc in front of standard water. ------------------------------------------------------------------------ git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4226 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
61b833e665
commit
e8e230d98c
4 changed files with 49 additions and 49 deletions
|
@ -341,6 +341,7 @@ int Mod_SkinNumForName(struct model_s *model, char *name);
|
||||||
int Mod_FrameNumForName(struct model_s *model, char *name);
|
int Mod_FrameNumForName(struct model_s *model, char *name);
|
||||||
float Mod_FrameDuration(struct model_s *model, int frameno);
|
float Mod_FrameDuration(struct model_s *model, int frameno);
|
||||||
|
|
||||||
|
void RMod_ResortShaders(void);
|
||||||
void RMod_ClearAll (void);
|
void RMod_ClearAll (void);
|
||||||
struct model_s *RMod_ForName (char *name, qboolean crash);
|
struct model_s *RMod_ForName (char *name, qboolean crash);
|
||||||
struct model_s *RMod_FindName (char *name);
|
struct model_s *RMod_FindName (char *name);
|
||||||
|
|
|
@ -127,6 +127,7 @@ void ClearBounds (vec3_t mins, vec3_t maxs)
|
||||||
|
|
||||||
void Mod_SortShaders(void)
|
void Mod_SortShaders(void)
|
||||||
{
|
{
|
||||||
|
//surely this isn't still needed?
|
||||||
texture_t *textemp;
|
texture_t *textemp;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
@ -2565,6 +2566,9 @@ void CModRBSP_BuildSurfMesh(model_t *mod, msurface_t *out, void *cookie)
|
||||||
Vector4Copy(mesh->colors4b_array[0], mesh->colors4b_array[3]);
|
Vector4Copy(mesh->colors4b_array[0], mesh->colors4b_array[3]);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mod_AccumulateMeshTextureVectors(out->mesh);
|
||||||
|
Mod_NormaliseTextureVectors(out->mesh->normals_array, out->mesh->snormals_array, out->mesh->tnormals_array, out->mesh->numvertexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModQ3_BuildSurfMesh(model_t *mod, msurface_t *out, void *cookie)
|
void CModQ3_BuildSurfMesh(model_t *mod, msurface_t *out, void *cookie)
|
||||||
|
@ -2575,15 +2579,7 @@ void CModQ3_BuildSurfMesh(model_t *mod, msurface_t *out, void *cookie)
|
||||||
|
|
||||||
if (LittleLong(in->facetype) == MST_PATCH)
|
if (LittleLong(in->facetype) == MST_PATCH)
|
||||||
{
|
{
|
||||||
// out->mesh->numindexes = 0;
|
|
||||||
// out->mesh->numvertexes = 0;
|
|
||||||
//FIXME
|
|
||||||
GL_CreateMeshForPatch(loadmodel, out->mesh, LittleLong(in->patchwidth), LittleLong(in->patchheight), LittleLong(in->num_vertices), LittleLong(in->firstvertex));
|
GL_CreateMeshForPatch(loadmodel, out->mesh, LittleLong(in->patchwidth), LittleLong(in->patchheight), LittleLong(in->num_vertices), LittleLong(in->firstvertex));
|
||||||
// if (out->mesh)
|
|
||||||
// {
|
|
||||||
// Mod_AccumulateMeshTextureVectors(out->mesh);
|
|
||||||
// Mod_NormaliseTextureVectors(out->mesh->normals_array, out->mesh->snormals_array, out->mesh->tnormals_array, out->mesh->numvertexes);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
else if (LittleLong(in->facetype) == MST_PLANAR || LittleLong(in->facetype) == MST_TRIANGLE_SOUP)
|
else if (LittleLong(in->facetype) == MST_PLANAR || LittleLong(in->facetype) == MST_TRIANGLE_SOUP)
|
||||||
{
|
{
|
||||||
|
@ -2602,35 +2598,6 @@ void CModQ3_BuildSurfMesh(model_t *mod, msurface_t *out, void *cookie)
|
||||||
{
|
{
|
||||||
out->mesh->indexes[i] = map_surfindexes[fv + i];
|
out->mesh->indexes[i] = map_surfindexes[fv + i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* numindexes = LittleLong(in->num_indexes);
|
|
||||||
numverts = LittleLong(in->num_vertices);
|
|
||||||
if (numindexes%3 || numindexes < 0 || numverts < 0)
|
|
||||||
{
|
|
||||||
Con_Printf(CON_ERROR "mesh indexes should be multiples of 3\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
out->mesh = Hunk_Alloc(sizeof(mesh_t));
|
|
||||||
out->mesh->normals_array= map_normals_array + LittleLong(in->firstvertex);
|
|
||||||
out->mesh->snormals_array = map_svector_array + LittleLong(in->firstvertex);
|
|
||||||
out->mesh->tnormals_array = map_tvector_array + LittleLong(in->firstvertex);
|
|
||||||
|
|
||||||
out->mesh->colors4f_array = map_colors4f_array + LittleLong(in->firstvertex);
|
|
||||||
out->mesh->indexes = map_surfindexes + LittleLong(in->firstindex);
|
|
||||||
out->mesh->xyz_array = map_verts + LittleLong(in->firstvertex);
|
|
||||||
out->mesh->st_array = map_vertstmexcoords + LittleLong(in->firstvertex);
|
|
||||||
out->mesh->lmst_array = map_vertlstmexcoords + LittleLong(in->firstvertex);
|
|
||||||
|
|
||||||
out->mesh->numindexes = numindexes;
|
|
||||||
out->mesh->numvertexes = numverts;
|
|
||||||
|
|
||||||
if (LittleLong(in->facetype) == MST_PLANAR)
|
|
||||||
if (out->mesh->numindexes == (out->mesh->numvertexes-2)*3)
|
|
||||||
out->mesh->istrifan = true;
|
|
||||||
|
|
||||||
Mod_AccumulateMeshTextureVectors(out->mesh);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2669,7 +2636,8 @@ void CModQ3_BuildSurfMesh(model_t *mod, msurface_t *out, void *cookie)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mod_AccumulateMeshTextureVectors(out->mesh);
|
||||||
|
Mod_NormaliseTextureVectors(out->mesh->normals_array, out->mesh->snormals_array, out->mesh->tnormals_array, out->mesh->numvertexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean CModQ3_LoadRFaces (lump_t *l)
|
qboolean CModQ3_LoadRFaces (lump_t *l)
|
||||||
|
@ -2783,10 +2751,7 @@ qboolean CModQ3_LoadRFaces (lump_t *l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod_NormaliseTextureVectors(map_normals_array, map_svector_array, map_tvector_array, numvertexes);
|
|
||||||
|
|
||||||
Mod_SortShaders();
|
Mod_SortShaders();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2900,7 +2865,8 @@ qboolean CModRBSP_LoadRFaces (lump_t *l)
|
||||||
out->mesh->numvertexes = 4;
|
out->mesh->numvertexes = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mod_SortShaders();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -365,6 +365,35 @@ void Mod_RebuildLightmaps (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RMod_ResortShaders(void)
|
||||||
|
{
|
||||||
|
//called when some shader changed its sort key.
|
||||||
|
//this means we have to hunt down all models and update their batches.
|
||||||
|
//really its only bsps that need this.
|
||||||
|
batch_t *oldlists[SHADER_SORT_COUNT], *b;
|
||||||
|
int i, j, bs;
|
||||||
|
model_t *mod;
|
||||||
|
for (i=0, mod=mod_known ; i<mod_numknown ; i++, mod++)
|
||||||
|
{
|
||||||
|
if (mod->needload)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memcpy(oldlists, mod->batches, sizeof(oldlists));
|
||||||
|
memset(mod->batches, 0, sizeof(oldlists));
|
||||||
|
|
||||||
|
for (j = 0; j < SHADER_SORT_COUNT; j++)
|
||||||
|
{
|
||||||
|
while((b=oldlists[j]))
|
||||||
|
{
|
||||||
|
oldlists[j] = b->next;
|
||||||
|
bs = b->shader?b->shader->sort:j;
|
||||||
|
|
||||||
|
b->next = mod->batches[bs];
|
||||||
|
mod->batches[bs] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
Mod_ClearAll
|
Mod_ClearAll
|
||||||
|
|
|
@ -4194,7 +4194,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case -1: //invisible
|
case -1: //invisible
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n"
|
|
||||||
"surfaceparm nodraw\n"
|
"surfaceparm nodraw\n"
|
||||||
"surfaceparm nodlight\n"
|
"surfaceparm nodlight\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
@ -4202,7 +4201,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case 0: //fastturb
|
case 0: //fastturb
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n"
|
|
||||||
"{\n"
|
"{\n"
|
||||||
"map $whiteimage\n"
|
"map $whiteimage\n"
|
||||||
"rgbgen const $r_fastturbcolour\n"
|
"rgbgen const $r_fastturbcolour\n"
|
||||||
|
@ -4214,7 +4212,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case 1: //vanilla style
|
case 1: //vanilla style
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n" /*make sure it always has the same sort order, so switching on/off wateralpha doesn't break stuff*/
|
|
||||||
"program defaultwarp\n"
|
"program defaultwarp\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"map $diffuse\n"
|
"map $diffuse\n"
|
||||||
|
@ -4231,7 +4228,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case 2: //refraction of the underwater surface, with a fresnel
|
case 2: //refraction of the underwater surface, with a fresnel
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n" /*make sure it always has the same sort order, so switching on/off wateralpha doesn't break stuff*/
|
|
||||||
"surfaceparm nodlight\n"
|
"surfaceparm nodlight\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"map $refraction\n"
|
"map $refraction\n"
|
||||||
|
@ -4248,7 +4244,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case 3: //reflections
|
case 3: //reflections
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n" /*make sure it always has the same sort order, so switching on/off wateralpha doesn't break stuff*/
|
|
||||||
"surfaceparm nodlight\n"
|
"surfaceparm nodlight\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"map $refraction\n"
|
"map $refraction\n"
|
||||||
|
@ -4265,7 +4260,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case 4: //ripples
|
case 4: //ripples
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n" /*make sure it always has the same sort order, so switching on/off wateralpha doesn't break stuff*/
|
|
||||||
"surfaceparm nodlight\n"
|
"surfaceparm nodlight\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"map $refraction\n"
|
"map $refraction\n"
|
||||||
|
@ -4285,7 +4279,6 @@ char *Shader_DefaultBSPWater(char *shortname)
|
||||||
case 5: //ripples+reflections
|
case 5: //ripples+reflections
|
||||||
return (
|
return (
|
||||||
"{\n"
|
"{\n"
|
||||||
"sort blend\n" /*make sure it always has the same sort order, so switching on/off wateralpha doesn't break stuff*/
|
|
||||||
"surfaceparm nodlight\n"
|
"surfaceparm nodlight\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"map $refraction\n"
|
"map $refraction\n"
|
||||||
|
@ -4931,6 +4924,8 @@ void Shader_DoReload(void)
|
||||||
shader_t *s;
|
shader_t *s;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char shortname[MAX_QPATH];
|
char shortname[MAX_QPATH];
|
||||||
|
int oldsort;
|
||||||
|
qboolean resort = false;
|
||||||
|
|
||||||
if (shader_rescan_needed && ruleset_allow_shaders.ival)
|
if (shader_rescan_needed && ruleset_allow_shaders.ival)
|
||||||
{
|
{
|
||||||
|
@ -4973,11 +4968,20 @@ void Shader_DoReload(void)
|
||||||
}
|
}
|
||||||
if (s->generator)
|
if (s->generator)
|
||||||
{
|
{
|
||||||
|
oldsort = s->sort;
|
||||||
Shader_Reset(s);
|
Shader_Reset(s);
|
||||||
|
|
||||||
s->generator(shortname, s, s->genargs);
|
s->generator(shortname, s, s->genargs);
|
||||||
|
|
||||||
|
if (s->sort != oldsort)
|
||||||
|
resort = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resort)
|
||||||
|
{
|
||||||
|
RMod_ResortShaders();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader_NeedReload(qboolean rescanfs)
|
void Shader_NeedReload(qboolean rescanfs)
|
||||||
|
|
Loading…
Reference in a new issue