mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- 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:
parent
8ab6575bd1
commit
720853cff8
5 changed files with 12 additions and 8 deletions
|
@ -12,7 +12,7 @@ struct FStartupInfo
|
|||
int Type;
|
||||
int LoadLights = -1;
|
||||
int LoadBrightmaps = -1;
|
||||
int modern = -1;
|
||||
int modern = 0;
|
||||
enum
|
||||
{
|
||||
DefaultStartup,
|
||||
|
|
|
@ -149,6 +149,7 @@ void FGameTexture::AddAutoMaterials()
|
|||
{ "materials/ao/", &FGameTexture::AmbientOcclusion }
|
||||
};
|
||||
|
||||
if (flags & GTexf_AutoMaterialsAdded) return; // do this only once
|
||||
|
||||
bool fullname = !!(flags & GTexf_FullNameTexture);
|
||||
FString searchname = GetName();
|
||||
|
@ -177,6 +178,7 @@ void FGameTexture::AddAutoMaterials()
|
|||
}
|
||||
}
|
||||
}
|
||||
flags |= GTexf_AutoMaterialsAdded;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -57,12 +57,14 @@ enum EGameTexFlags
|
|||
GTexf_RenderFullbright = 32, // always draw fullbright
|
||||
GTexf_DisableFullbrightSprites = 64, // This texture will not be displayed as fullbright sprite
|
||||
GTexf_BrightmapChecked = 128, // Check for a colormap-based brightmap was already done.
|
||||
GTexf_AutoMaterialsAdded = 256, // AddAutoMaterials has been called on this texture.
|
||||
};
|
||||
|
||||
// Refactoring helper to allow piece by piece adjustment of the API
|
||||
class FGameTexture
|
||||
{
|
||||
friend class FMaterial;
|
||||
friend class GLDefsParser; // this needs access to set up the texture properly
|
||||
|
||||
// Material layers. These are shared so reference counting is used.
|
||||
RefCountedPtr<FTexture> Base;
|
||||
|
|
|
@ -114,7 +114,7 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags)
|
|||
if (index >= FIRST_USER_SHADER)
|
||||
{
|
||||
const UserShaderDesc &usershader = usershaders[index - FIRST_USER_SHADER];
|
||||
//if (usershader.shaderType == mShaderIndex) // Only apply user shader if it matches the expected material
|
||||
if (usershader.shaderType == mShaderIndex) // Only apply user shader if it matches the expected material
|
||||
{
|
||||
for (auto &texture : tx->CustomShaderTextures)
|
||||
{
|
||||
|
|
|
@ -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('{');
|
||||
|
|
Loading…
Reference in a new issue