}
}
-void Mod_GetTerrainVertex3fTexCoord2fFromRGBA(const unsigned char *imagepixels, int imagewidth, int imageheight, int ix, int iy, float *vertex3f, float *texcoord2f, matrix4x4_t *pixelstepmatrix, matrix4x4_t *pixeltexturestepmatrix)
+void Mod_GetTerrainVertex3fTexCoord2fFromBGRA(const unsigned char *imagepixels, int imagewidth, int imageheight, int ix, int iy, float *vertex3f, float *texcoord2f, matrix4x4_t *pixelstepmatrix, matrix4x4_t *pixeltexturestepmatrix)
{
float v[3], tc[3];
v[0] = ix;
texcoord2f[1] = tc[1];
}
-void Mod_GetTerrainVertexFromRGBA(const unsigned char *imagepixels, int imagewidth, int imageheight, int ix, int iy, float *vertex3f, float *svector3f, float *tvector3f, float *normal3f, float *texcoord2f, matrix4x4_t *pixelstepmatrix, matrix4x4_t *pixeltexturestepmatrix)
+void Mod_GetTerrainVertexFromBGRA(const unsigned char *imagepixels, int imagewidth, int imageheight, int ix, int iy, float *vertex3f, float *svector3f, float *tvector3f, float *normal3f, float *texcoord2f, matrix4x4_t *pixelstepmatrix, matrix4x4_t *pixeltexturestepmatrix)
{
float vup[3], vdown[3], vleft[3], vright[3];
float tcup[3], tcdown[3], tcleft[3], tcright[3];
float sv[3], tv[3], nl[3];
- Mod_GetTerrainVertex3fTexCoord2fFromRGBA(imagepixels, imagewidth, imageheight, ix, iy, vertex3f, texcoord2f, pixelstepmatrix, pixeltexturestepmatrix);
- Mod_GetTerrainVertex3fTexCoord2fFromRGBA(imagepixels, imagewidth, imageheight, ix, iy - 1, vup, tcup, pixelstepmatrix, pixeltexturestepmatrix);
- Mod_GetTerrainVertex3fTexCoord2fFromRGBA(imagepixels, imagewidth, imageheight, ix, iy + 1, vdown, tcdown, pixelstepmatrix, pixeltexturestepmatrix);
- Mod_GetTerrainVertex3fTexCoord2fFromRGBA(imagepixels, imagewidth, imageheight, ix - 1, iy, vleft, tcleft, pixelstepmatrix, pixeltexturestepmatrix);
- Mod_GetTerrainVertex3fTexCoord2fFromRGBA(imagepixels, imagewidth, imageheight, ix + 1, iy, vright, tcright, pixelstepmatrix, pixeltexturestepmatrix);
+ Mod_GetTerrainVertex3fTexCoord2fFromBGRA(imagepixels, imagewidth, imageheight, ix, iy, vertex3f, texcoord2f, pixelstepmatrix, pixeltexturestepmatrix);
+ Mod_GetTerrainVertex3fTexCoord2fFromBGRA(imagepixels, imagewidth, imageheight, ix, iy - 1, vup, tcup, pixelstepmatrix, pixeltexturestepmatrix);
+ Mod_GetTerrainVertex3fTexCoord2fFromBGRA(imagepixels, imagewidth, imageheight, ix, iy + 1, vdown, tcdown, pixelstepmatrix, pixeltexturestepmatrix);
+ Mod_GetTerrainVertex3fTexCoord2fFromBGRA(imagepixels, imagewidth, imageheight, ix - 1, iy, vleft, tcleft, pixelstepmatrix, pixeltexturestepmatrix);
+ Mod_GetTerrainVertex3fTexCoord2fFromBGRA(imagepixels, imagewidth, imageheight, ix + 1, iy, vright, tcright, pixelstepmatrix, pixeltexturestepmatrix);
Mod_BuildBumpVectors(vertex3f, vup, vright, texcoord2f, tcup, tcright, svector3f, tvector3f, normal3f);
Mod_BuildBumpVectors(vertex3f, vright, vdown, texcoord2f, tcright, tcdown, sv, tv, nl);
VectorAdd(svector3f, sv, svector3f);
VectorAdd(normal3f, nl, normal3f);
}
-void Mod_ConstructTerrainPatchFromRGBA(const unsigned char *imagepixels, int imagewidth, int imageheight, int x1, int y1, int width, int height, int *element3i, int *neighbor3i, float *vertex3f, float *svector3f, float *tvector3f, float *normal3f, float *texcoord2f, matrix4x4_t *pixelstepmatrix, matrix4x4_t *pixeltexturestepmatrix)
+void Mod_ConstructTerrainPatchFromBGRA(const unsigned char *imagepixels, int imagewidth, int imageheight, int x1, int y1, int width, int height, int *element3i, int *neighbor3i, float *vertex3f, float *svector3f, float *tvector3f, float *normal3f, float *texcoord2f, matrix4x4_t *pixelstepmatrix, matrix4x4_t *pixeltexturestepmatrix)
{
int x, y, ix, iy, *e;
e = element3i;
Mod_BuildTriangleNeighbors(neighbor3i, element3i, width*height*2);
for (y = 0, iy = y1;y < height + 1;y++, iy++)
for (x = 0, ix = x1;x < width + 1;x++, ix++, vertex3f += 3, texcoord2f += 2, svector3f += 3, tvector3f += 3, normal3f += 3)
- Mod_GetTerrainVertexFromRGBA(imagepixels, imagewidth, imageheight, ix, iy, vertex3f, texcoord2f, svector3f, tvector3f, normal3f, pixelstepmatrix, pixeltexturestepmatrix);
+ Mod_GetTerrainVertexFromBGRA(imagepixels, imagewidth, imageheight, ix, iy, vertex3f, texcoord2f, svector3f, tvector3f, normal3f, pixelstepmatrix, pixeltexturestepmatrix);
}
q3wavefunc_t Mod_LoadQ3Shaders_EnumerateWaveFunc(const char *s)
shader = q3shaders_shaders + q3shaders_numshaders++;
memset(shader, 0, sizeof(*shader));
- VectorSet(shader->reflectcolor, 1, 1, 1);
- VectorSet(shader->refractcolor, 1, 1, 1);
- shader->refractmin = 0;
- shader->refractmax = 1;
+ shader->reflectmin = 0;
+ shader->reflectmax = 1;
shader->refractfactor = 1;
+ Vector4Set(shader->refractcolor4f, 1, 1, 1, 1);
+ shader->reflectfactor = 1;
+ Vector4Set(shader->reflectcolor4f, 1, 1, 1, 1);
strlcpy(shader->name, com_token, sizeof(shader->name));
if (!COM_ParseToken_QuakeC(&text, false) || strcasecmp(com_token, "{"))
break;
if (!strcasecmp(com_token, "{"))
{
+ static q3shaderinfo_layer_t dummy;
if (shader->numlayers < Q3SHADER_MAXLAYERS)
{
layer = shader->layers + shader->numlayers++;
- layer->rgbgen.rgbgen = Q3RGBGEN_IDENTITY;
- layer->alphagen.alphagen = Q3ALPHAGEN_IDENTITY;
- layer->tcgen.tcgen = Q3TCGEN_TEXTURE;
- layer->blendfunc[0] = GL_ONE;
- layer->blendfunc[1] = GL_ZERO;
}
else
- layer = NULL;
+ {
+ // parse and process it anyway, just don't store it (so a map $lightmap or such stuff still is found)
+ memset(&dummy, 0, sizeof(dummy));
+ layer = &dummy;
+ }
+ layer->rgbgen.rgbgen = Q3RGBGEN_IDENTITY;
+ layer->alphagen.alphagen = Q3ALPHAGEN_IDENTITY;
+ layer->tcgen.tcgen = Q3TCGEN_TEXTURE;
+ layer->blendfunc[0] = GL_ONE;
+ layer->blendfunc[1] = GL_ZERO;
while (COM_ParseToken_QuakeC(&text, false))
{
if (!strcasecmp(com_token, "}"))
break;
if (!strcasecmp(com_token, "\n"))
continue;
- if (layer == NULL)
- continue;
numparameters = 0;
for (j = 0;strcasecmp(com_token, "\n") && strcasecmp(com_token, "}");j++)
{
else
Con_DPrintf("%s parsing warning: too many tcmods on one layer\n", search->filenames[fileindex]);
}
- // break out a level if it was }
+ // break out a level if it was a closing brace (not using the character here to not confuse vim)
if (!strcasecmp(com_token, "}"))
break;
}
shader->textureflags |= Q3TEXTUREFLAG_NOPICMIP;
else if (!strcasecmp(parameter[0], "polygonoffset"))
shader->textureflags |= Q3TEXTUREFLAG_POLYGONOFFSET;
- else if (!strcasecmp(parameter[0], "dp_reflect"))
+ else if (!strcasecmp(parameter[0], "dp_refract") && numparameters >= 5)
+ {
+ shader->textureflags |= Q3TEXTUREFLAG_REFRACTION;
+ shader->refractfactor = atof(parameter[1]);
+ Vector4Set(shader->refractcolor4f, atof(parameter[2]), atof(parameter[3]), atof(parameter[4]), 1);
+ }
+ else if (!strcasecmp(parameter[0], "dp_reflect") && numparameters >= 6)
{
shader->textureflags |= Q3TEXTUREFLAG_REFLECTION;
- if(numparameters >= 2)
- VectorSet(shader->reflectcolor, atof(parameter[1]), atof(parameter[1]), atof(parameter[1])); // grey
- if(numparameters >= 4)
- VectorSet(shader->reflectcolor, atof(parameter[1]), atof(parameter[2]), atof(parameter[3]));
+ shader->reflectfactor = atof(parameter[1]);
+ Vector4Set(shader->reflectcolor4f, atof(parameter[2]), atof(parameter[3]), atof(parameter[4]), atof(parameter[5]));
}
- else if (!strcasecmp(parameter[0], "dp_refract"))
+ else if (!strcasecmp(parameter[0], "dp_water") && numparameters >= 11)
{
shader->textureflags |= Q3TEXTUREFLAG_WATERSHADER;
- if(numparameters >= 2)
- shader->refractmin = atof(parameter[1]);
- if(numparameters >= 3)
- shader->refractmax = atof(parameter[2]);
- if(numparameters >= 4)
- shader->refractfactor = atof(parameter[3]);
- if(numparameters >= 5)
- VectorSet(shader->refractcolor, atof(parameter[4]), atof(parameter[4]), atof(parameter[4])); // grey
- if(numparameters >= 7)
- VectorSet(shader->refractcolor, atof(parameter[4]), atof(parameter[5]), atof(parameter[6]));
+ shader->reflectmin = atof(parameter[1]);
+ shader->reflectmax = atof(parameter[2]);
+ shader->refractfactor = atof(parameter[3]);
+ shader->reflectfactor = atof(parameter[4]);
+ Vector4Set(shader->refractcolor4f, atof(parameter[5]), atof(parameter[6]), atof(parameter[7]), 1);
+ Vector4Set(shader->reflectcolor4f, atof(parameter[8]), atof(parameter[9]), atof(parameter[10]), 1);
}
else if (!strcasecmp(parameter[0], "deformvertexes") && numparameters >= 2)
{
}
// fix up multiple reflection types
if(shader->textureflags & Q3TEXTUREFLAG_WATERSHADER)
- shader->textureflags &= ~Q3TEXTUREFLAG_REFLECTION;
+ shader->textureflags &= ~(Q3TEXTUREFLAG_REFRACTION | Q3TEXTUREFLAG_REFLECTION);
}
Mem_Free(f);
}
q3shaderinfo_t *Mod_LookupQ3Shader(const char *name)
{
int i;
- for (i = 0;i < Q3SHADER_MAXSHADERS;i++)
+ for (i = 0;i < q3shaders_numshaders;i++)
if (!strcasecmp(q3shaders_shaders[i].name, name))
return q3shaders_shaders + i;
return NULL;
texture->basematerialflags |= MATERIALFLAG_NOSHADOW | MATERIALFLAG_NOCULLFACE;
if (shader->textureflags & Q3TEXTUREFLAG_POLYGONOFFSET)
texture->basepolygonoffset -= 2;
+ if (shader->textureflags & Q3TEXTUREFLAG_REFRACTION)
+ texture->basematerialflags |= MATERIALFLAG_REFRACTION;
if (shader->textureflags & Q3TEXTUREFLAG_REFLECTION)
texture->basematerialflags |= MATERIALFLAG_REFLECTION;
if (shader->textureflags & Q3TEXTUREFLAG_WATERSHADER)
texflags |= TEXF_CLAMP;
if (!(texture->skinframes[j] = R_SkinFrame_LoadExternal(shader->primarylayer->texturename[j], texflags, false)))
{
- Con_DPrintf("%s: could not load texture \"%s\" (frame %i) for shader \"%s\"\n", loadmodel->name, shader->primarylayer->texturename[j], j, texture->name);
+ Con_Printf("^1%s:^7 could not load texture ^3\"%s\"^7 (frame %i) for shader ^2\"%s\"\n", loadmodel->name, shader->primarylayer->texturename[j], j, texture->name);
texture->skinframes[j] = R_SkinFrame_LoadMissing();
}
}
{
if (!(texture->backgroundskinframes[j] = R_SkinFrame_LoadExternal(shader->backgroundlayer->texturename[j], ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | ((!r_picmipworld.integer || (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP)) ? 0 : (TEXF_PICMIP | TEXF_COMPRESS)) | (shader->backgroundlayer->clampmap ? TEXF_CLAMP : 0), false)))
{
- Con_DPrintf("%s: could not load texture \"%s\" (frame %i) for shader \"%s\"\n", loadmodel->name, shader->backgroundlayer->texturename[j], j, texture->name);
+ Con_Printf("^1%s:^7 could not load texture ^3\"%s\"^7 (frame %i) for shader ^2\"%s\"\n", loadmodel->name, shader->backgroundlayer->texturename[j], j, texture->name);
texture->backgroundskinframes[j] = R_SkinFrame_LoadMissing();
}
}
}
memcpy(texture->deforms, shader->deforms, sizeof(texture->deforms));
- texture->refractmin = shader->refractmin;
- texture->refractmax = shader->refractmax;
+ texture->reflectmin = shader->reflectmin;
+ texture->reflectmax = shader->reflectmax;
texture->refractfactor = shader->refractfactor;
- VectorCopy(shader->reflectcolor, texture->reflectcolor);
- VectorCopy(shader->refractcolor, texture->refractcolor);
+ Vector4Copy(shader->refractcolor4f, texture->refractcolor4f);
+ texture->reflectfactor = shader->reflectfactor;
+ Vector4Copy(shader->reflectcolor4f, texture->reflectcolor4f);
}
else if (!strcmp(texture->name, "noshader"))
{
texture->basematerialflags |= MATERIALFLAG_WALL;
texture->numskinframes = 1;
if (!(texture->skinframes[0] = R_SkinFrame_LoadExternal(texture->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | (r_picmipworld.integer ? TEXF_PICMIP : 0) | TEXF_COMPRESS, false)))
- Con_DPrintf("%s: could not load texture for missing shader \"%s\"\n", loadmodel->name, texture->name);
+ if(developer.integer || q3bsp) // only the Q3BSP path provides no alternative (like loading image directly, or internal texture)
+ Con_Printf("^1%s:^7 could not load texture for missing shader ^3\"%s\"\n", loadmodel->name, texture->name);
}
// init the animation variables
texture->currentframe = texture;