- made some changes so that material definitions can properly check automatic layers when determining their material type.

Most importantly this means that any texture with a custom material definition needs to load its automatic layers before applying the definition.
This commit is contained in:
Christoph Oelckers 2020-06-03 21:15:32 +02:00
commit 720853cff8
5 changed files with 12 additions and 8 deletions

View file

@ -1216,6 +1216,7 @@ class GLDefsParser
{
sc.ScriptMessage("Material definition refers nonexistent texture '%s'\n", sc.String);
}
else tex->AddAutoMaterials(); // We need these before setting up the texture.
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
@ -1242,14 +1243,12 @@ class GLDefsParser
else if (sc.Compare("glossiness"))
{
sc.MustGetFloat();
if (tex)
mlay.Glossiness = (float)sc.Float;
mlay.Glossiness = (float)sc.Float;
}
else if (sc.Compare("specularlevel"))
{
sc.MustGetFloat();
if (tex)
mlay.SpecularLevel = (float)sc.Float;
mlay.SpecularLevel = (float)sc.Float;
}
else if (sc.Compare("speed"))
{
@ -1367,12 +1366,12 @@ class GLDefsParser
if (usershader.shader.IsNotEmpty())
{
int firstUserTexture;
if (mlay.Normal && mlay.Specular)
if ((mlay.Normal || tex->Normal.get()) && (mlay.Specular || tex->Specular.get()))
{
usershader.shaderType = SHADER_Specular;
firstUserTexture = 7;
}
else if (mlay.Normal && mlay.Metallic && mlay.Roughness && mlay.AmbientOcclusion)
else if ((mlay.Normal || tex->Normal.get()) && (mlay.Metallic || tex->Metallic.get()) && (mlay.Roughness || tex->Roughness.get()) && (mlay.AmbientOcclusion || tex->AmbientOcclusion.get()))
{
usershader.shaderType = SHADER_PBR;
firstUserTexture = 9;
@ -1523,6 +1522,7 @@ class GLDefsParser
sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type);
auto tex = TexMan.GetGameTexture(no);
if (tex) tex->AddAutoMaterials();
MaterialLayers mlay = { -1000, -1000 };
sc.MustGetToken('{');