OpenGL2: automatically load textures with a _s suffix as specular.

This commit is contained in:
SmileTheory 2015-12-02 17:08:40 -08:00
parent f663104cfc
commit 2954bdfa65

View file

@ -2212,12 +2212,33 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse,
if (r_specularMapping->integer)
{
image_t *diffuseImg;
if (specular)
{
//ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName);
diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0];
VectorCopy4(specular->specularScale, diffuse->specularScale);
}
else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0]))
{
char specularName[MAX_QPATH];
image_t *specularImg;
imgFlags_t specularFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE;
COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH);
Q_strcat(specularName, MAX_QPATH, "_s");
specularImg = R_FindImageFile(specularName, IMGTYPE_COLORALPHA, specularFlags);
if (specularImg)
{
diffuse->bundle[TB_SPECULARMAP] = diffuse->bundle[0];
diffuse->bundle[TB_SPECULARMAP].numImageAnimations = 0;
diffuse->bundle[TB_SPECULARMAP].image[0] = specularImg;
VectorSet4(diffuse->specularScale, 1.0f, 1.0f, 1.0f, 1.0f);
}
}
}
if (tcgen || diffuse->bundle[0].numTexMods)