- transitioned the GLDEFS parser to FGameTexture.

This commit is contained in:
Christoph Oelckers 2020-04-14 19:05:37 +02:00
parent 54f4267597
commit 72835c5462
6 changed files with 125 additions and 77 deletions

View file

@ -225,6 +225,7 @@ struct FTextureBuffer
// Base texture class // Base texture class
class FTexture class FTexture
{ {
friend class FGameTexture; // only for the porting work
friend class GLDefsParser; friend class GLDefsParser;
friend class FMultipatchTextureBuilder; friend class FMultipatchTextureBuilder;
@ -367,6 +368,7 @@ protected:
FTexture *OffsetLess = nullptr; FTexture *OffsetLess = nullptr;
// Front sky layer variant where color 0 is transparent // Front sky layer variant where color 0 is transparent
FTexture* FrontSkyLayer = nullptr; FTexture* FrontSkyLayer = nullptr;
public:
// Paletted variant // Paletted variant
FTexture *PalVersion = nullptr; FTexture *PalVersion = nullptr;
// Material layers // Material layers
@ -381,6 +383,8 @@ protected:
FTexture *CustomShaderTextures[MAX_CUSTOM_HW_SHADER_TEXTURES] = { nullptr }; // Custom texture maps for custom hardware shaders FTexture *CustomShaderTextures[MAX_CUSTOM_HW_SHADER_TEXTURES] = { nullptr }; // Custom texture maps for custom hardware shaders
protected:
FString Name; FString Name;
ETextureType UseType; // This texture's primary purpose ETextureType UseType; // This texture's primary purpose
@ -397,10 +401,12 @@ protected:
uint8_t bMultiPatch:2; // This is a multipatch texture (we really could use real type info for textures...) uint8_t bMultiPatch:2; // This is a multipatch texture (we really could use real type info for textures...)
uint8_t bFullNameTexture : 1; uint8_t bFullNameTexture : 1;
uint8_t bBrightmapChecked : 1; // Set to 1 if brightmap has been checked uint8_t bBrightmapChecked : 1; // Set to 1 if brightmap has been checked
public:
uint8_t bGlowing : 1; // Texture glow color uint8_t bGlowing : 1; // Texture glow color
uint8_t bAutoGlowing : 1; // Glow info is determined from texture image. uint8_t bAutoGlowing : 1; // Glow info is determined from texture image.
uint8_t bFullbright : 1; // always draw fullbright uint8_t bFullbright : 1; // always draw fullbright
uint8_t bDisableFullbright : 1; // This texture will not be displayed as fullbright sprite uint8_t bDisableFullbright : 1; // This texture will not be displayed as fullbright sprite
protected:
uint8_t bSkybox : 1; // is a cubic skybox uint8_t bSkybox : 1; // is a cubic skybox
uint8_t bNoCompress : 1; uint8_t bNoCompress : 1;
uint8_t bNoExpand : 1; uint8_t bNoExpand : 1;
@ -411,9 +417,10 @@ protected:
int16_t SkyOffset; int16_t SkyOffset;
FloatRect *areas = nullptr; FloatRect *areas = nullptr;
int areacount = 0; int areacount = 0;
public:
int GlowHeight = 128; int GlowHeight = 128;
PalEntry GlowColor = 0; PalEntry GlowColor = 0;
int HiresLump = -1; // For external hires textures. private:
float Glossiness = 10.f; float Glossiness = 10.f;
float SpecularLevel = 0.1f; float SpecularLevel = 0.1f;
float shaderspeed = 1.f; float shaderspeed = 1.f;
@ -557,6 +564,19 @@ public:
}; };
struct MaterialLayers
{
float Glossiness;
float SpecularLevel;
FGameTexture* Brightmap;
FGameTexture* Normal;
FGameTexture* Specular;
FGameTexture* Metallic;
FGameTexture* Roughness;
FGameTexture* AmbientOcclusion;
FGameTexture* CustomShaderTextures[MAX_CUSTOM_HW_SHADER_TEXTURES];
};
struct FTexCoordInfo struct FTexCoordInfo
{ {
int mRenderWidth; int mRenderWidth;
@ -581,6 +601,8 @@ class FGameTexture
FTexture wrapped; FTexture wrapped;
public: public:
FTexture* GetTexture() { return &wrapped; } FTexture* GetTexture() { return &wrapped; }
int GetSourceLump() const { return wrapped.GetSourceLump(); }
void SetBrightmap(FGameTexture* tex) { wrapped.Brightmap = tex->GetTexture(); }
double GetDisplayWidth() /*const*/ { return wrapped.GetDisplayWidthDouble(); } double GetDisplayWidth() /*const*/ { return wrapped.GetDisplayWidthDouble(); }
double GetDisplayHeight() /*const*/ { return wrapped.GetDisplayHeightDouble(); } double GetDisplayHeight() /*const*/ { return wrapped.GetDisplayHeightDouble(); }
@ -596,8 +618,10 @@ public:
bool isHardwareCanvas() const { return wrapped.isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later. bool isHardwareCanvas() const { return wrapped.isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later.
bool isSoftwareCanvas() const { return wrapped.isCanvas(); } bool isSoftwareCanvas() const { return wrapped.isCanvas(); }
bool isMiscPatch() const { return wrapped.GetUseType() == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not. bool isMiscPatch() const { return wrapped.GetUseType() == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not.
bool isFullbrightDisabled() const { return wrapped.isFullbrightDisabled(); }
bool useWorldPanning() const { return wrapped.UseWorldPanning(); } bool useWorldPanning() const { return wrapped.UseWorldPanning(); }
bool allowNoDecals() const { return wrapped.allowNoDecals(); } bool allowNoDecals() const { return wrapped.allowNoDecals(); }
void SetTranslucent(bool on) { wrapped.bTranslucent = on; }
ETextureType GetUseType() const { return wrapped.GetUseType(); } ETextureType GetUseType() const { return wrapped.GetUseType(); }
float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); } float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); }
uint16_t GetRotations() const { return wrapped.GetRotations(); } uint16_t GetRotations() const { return wrapped.GetRotations(); }
@ -608,6 +632,25 @@ public:
void SetSoftwareTexture(ISoftwareTexture* swtex) { wrapped.SetSoftwareTextue(swtex); } void SetSoftwareTexture(ISoftwareTexture* swtex) { wrapped.SetSoftwareTextue(swtex); }
void SetScale(DVector2 vec) { wrapped.SetScale(vec); } void SetScale(DVector2 vec) { wrapped.SetScale(vec); }
const FString& GetName() const { return wrapped.GetName(); } const FString& GetName() const { return wrapped.GetName(); }
void SetShaderSpeed(float speed) { wrapped.shaderspeed = speed; }
void SetShaderIndex(int index) { wrapped.shaderindex = index; }
void SetShaderLayers(MaterialLayers& lay)
{
// Only update layers that have something defind.
if (lay.Glossiness > -1000) wrapped.Glossiness = lay.Glossiness;
if (lay.SpecularLevel > -1000) wrapped.SpecularLevel = lay.SpecularLevel;
if (lay.Brightmap) wrapped.Brightmap = lay.Brightmap->GetTexture();
if (lay.Normal) wrapped.Normal = lay.Normal->GetTexture();
if (lay.Specular) wrapped.Specular = lay.Specular->GetTexture();
if (lay.Metallic) wrapped.Metallic = lay.Metallic->GetTexture();
if (lay.Roughness) wrapped.Roughness = lay.Roughness->GetTexture();
if (lay.AmbientOcclusion) wrapped.AmbientOcclusion = lay.AmbientOcclusion->GetTexture();
for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++)
{
if (lay.CustomShaderTextures[i]) wrapped.CustomShaderTextures[i] = lay.CustomShaderTextures[i]->GetTexture();
}
}
// These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place. // These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place.
FGameTexture* GetPalVersion() { return reinterpret_cast<FGameTexture*>(wrapped.GetPalVersion()); } FGameTexture* GetPalVersion() { return reinterpret_cast<FGameTexture*>(wrapped.GetPalVersion()); }
@ -619,6 +662,11 @@ public:
bool isGlowing() const { return wrapped.isGlowing(); } bool isGlowing() const { return wrapped.isGlowing(); }
bool isAutoGlowing() const { return wrapped.isAutoGlowing(); } bool isAutoGlowing() const { return wrapped.isAutoGlowing(); }
int GetGlowHeight() const { return wrapped.GetGlowHeight(); } int GetGlowHeight() const { return wrapped.GetGlowHeight(); }
void SetAutoGlowing() { auto tex = GetTexture(); tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true; }
void SetGlowHeight(int v) { wrapped.GlowHeight = v; }
void SetFullbright() { wrapped.bFullbright = true; }
void SetDisableFullbright(bool on) { wrapped.bDisableFullbright = on; }
void SetGlowing(PalEntry color) { auto tex = GetTexture(); tex->bAutoGlowing = false; tex->bGlowing = true; tex->GlowColor = color; }
bool isUserContent() const; bool isUserContent() const;
}; };

View file

@ -1034,8 +1034,8 @@ class GLDefsParser
{ {
sc.MustGetString(); sc.MustGetString();
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny);
FTexture *tex = TexMan.GetTexture(flump); auto tex = TexMan.GetGameTexture(flump);
if (tex) tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true; if (tex) tex->SetAutoGlowing();
} }
} }
else if (sc.Compare("WALLS")) else if (sc.Compare("WALLS"))
@ -1045,8 +1045,8 @@ class GLDefsParser
{ {
sc.MustGetString(); sc.MustGetString();
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Wall,FTextureManager::TEXMAN_TryAny); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Wall,FTextureManager::TEXMAN_TryAny);
FTexture *tex = TexMan.GetTexture(flump); auto tex = TexMan.GetGameTexture(flump);
if (tex) tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true; if (tex) tex->SetAutoGlowing();
} }
} }
else if (sc.Compare("TEXTURE")) else if (sc.Compare("TEXTURE"))
@ -1054,7 +1054,7 @@ class GLDefsParser
sc.SetCMode(true); sc.SetCMode(true);
sc.MustGetString(); sc.MustGetString();
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny);
FTexture *tex = TexMan.GetTexture(flump); auto tex = TexMan.GetGameTexture(flump);
sc.MustGetStringName(","); sc.MustGetStringName(",");
sc.MustGetString(); sc.MustGetString();
PalEntry color = V_GetColor(NULL, sc.String); PalEntry color = V_GetColor(NULL, sc.String);
@ -1064,21 +1064,19 @@ class GLDefsParser
{ {
if (sc.CheckNumber()) if (sc.CheckNumber())
{ {
if (tex) tex->GlowHeight = sc.Number; if (tex) tex->SetGlowHeight(sc.Number);
if (!sc.CheckString(",")) goto skip_fb; if (!sc.CheckString(",")) goto skip_fb;
} }
sc.MustGetStringName("fullbright"); sc.MustGetStringName("fullbright");
if (tex) tex->bFullbright = true; if (tex) tex->SetFullbright();
} }
skip_fb: skip_fb:
sc.SetCMode(false); sc.SetCMode(false);
if (tex && color != 0) if (tex && color != 0)
{ {
tex->bAutoGlowing = false; tex->SetGlowing(color);
tex->bGlowing = true;
tex->GlowColor = color;
} }
} }
} }
@ -1097,7 +1095,7 @@ class GLDefsParser
bool disable_fullbright=false; bool disable_fullbright=false;
bool thiswad = false; bool thiswad = false;
bool iwad = false; bool iwad = false;
FTexture *bmtex = NULL; FGameTexture *bmtex = NULL;
sc.MustGetString(); sc.MustGetString();
if (sc.Compare("texture")) type = ETextureType::Wall; if (sc.Compare("texture")) type = ETextureType::Wall;
@ -1107,7 +1105,7 @@ class GLDefsParser
sc.MustGetString(); sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable); FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable);
FTexture *tex = TexMan.GetTexture(no); auto tex = TexMan.GetGameTexture(no);
sc.MustGetToken('{'); sc.MustGetToken('{');
while (!sc.CheckToken('}')) while (!sc.CheckToken('}'))
@ -1136,13 +1134,13 @@ class GLDefsParser
if (bmtex != NULL) if (bmtex != NULL)
{ {
Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name.GetChars() : "(null)"); Printf("Multiple brightmap definitions in texture %s\n", tex? tex->GetName().GetChars() : "(null)");
} }
bmtex = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny); bmtex = TexMan.FindGameTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (bmtex == NULL) if (bmtex == NULL)
Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name.GetChars() : "(null)"); Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->GetName().GetChars() : "(null)");
} }
} }
if (!tex) if (!tex)
@ -1164,20 +1162,19 @@ class GLDefsParser
if (bmtex != NULL) if (bmtex != NULL)
{ {
bmtex->bMasked = false; tex->SetBrightmap(bmtex);
tex->Brightmap = bmtex;
} }
tex->bDisableFullbright = disable_fullbright; tex->SetDisableFullbright(disable_fullbright);
} }
void SetShaderIndex(FTexture *tex, unsigned index) void SetShaderIndex(FGameTexture *tex, unsigned index)
{ {
auto desc = usershaders[index - FIRST_USER_SHADER]; auto desc = usershaders[index - FIRST_USER_SHADER];
if (desc.disablealphatest) if (desc.disablealphatest)
{ {
tex->bTranslucent = true; tex->SetTranslucent(true);
} }
tex->shaderindex = index; tex->SetShaderIndex(index);
} }
//========================================================================== //==========================================================================
@ -1199,10 +1196,10 @@ class GLDefsParser
TArray<int> texNameIndex; TArray<int> texNameIndex;
float speed = 1.f; float speed = 1.f;
FTexture *textures[6]; MaterialLayers mlay = { -1000, -1000 };
FGameTexture* textures[6] = {};
const char *keywords[7] = { "brightmap", "normal", "specular", "metallic", "roughness", "ao", nullptr }; const char *keywords[7] = { "brightmap", "normal", "specular", "metallic", "roughness", "ao", nullptr };
const char *notFound[6] = { "Brightmap", "Normalmap", "Specular texture", "Metallic texture", "Roughness texture", "Ambient occlusion texture" }; const char *notFound[6] = { "Brightmap", "Normalmap", "Specular texture", "Metallic texture", "Roughness texture", "Ambient occlusion texture" };
memset(textures, 0, sizeof(textures));
sc.MustGetString(); sc.MustGetString();
if (sc.Compare("texture")) type = ETextureType::Wall; if (sc.Compare("texture")) type = ETextureType::Wall;
@ -1212,7 +1209,7 @@ class GLDefsParser
sc.MustGetString(); sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable); FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable);
FTexture *tex = TexMan.GetTexture(no); auto tex = TexMan.GetGameTexture(no);
if (tex == nullptr) if (tex == nullptr)
{ {
@ -1245,13 +1242,13 @@ class GLDefsParser
{ {
sc.MustGetFloat(); sc.MustGetFloat();
if (tex) if (tex)
tex->Glossiness = (float)sc.Float; mlay.Glossiness = (float)sc.Float;
} }
else if (sc.Compare("specularlevel")) else if (sc.Compare("specularlevel"))
{ {
sc.MustGetFloat(); sc.MustGetFloat();
if (tex) if (tex)
tex->SpecularLevel = (float)sc.Float; mlay.SpecularLevel = (float)sc.Float;
} }
else if (sc.Compare("speed")) else if (sc.Compare("speed"))
{ {
@ -1271,7 +1268,7 @@ class GLDefsParser
{ {
if (!texName.Compare(textureName)) if (!texName.Compare(textureName))
{ {
sc.ScriptError("Trying to redefine custom hardware shader texture '%s' in texture '%s'\n", textureName.GetChars(), tex ? tex->Name.GetChars() : "(null)"); sc.ScriptError("Trying to redefine custom hardware shader texture '%s' in texture '%s'\n", textureName.GetChars(), tex ? tex->GetName().GetChars() : "(null)");
} }
} }
sc.MustGetString(); sc.MustGetString();
@ -1280,12 +1277,12 @@ class GLDefsParser
bool okay = false; bool okay = false;
for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++) for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++)
{ {
if (!tex->CustomShaderTextures[i]) if (!mlay.CustomShaderTextures[i])
{ {
tex->CustomShaderTextures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny); mlay.CustomShaderTextures[i] = TexMan.FindGameTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (!tex->CustomShaderTextures[i]) if (!mlay.CustomShaderTextures[i])
{ {
sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex->Name.GetChars()); sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex->GetName().GetChars());
} }
texNameList.Push(textureName); texNameList.Push(textureName);
@ -1296,7 +1293,7 @@ class GLDefsParser
} }
if (!okay) if (!okay)
{ {
sc.ScriptError("Error: out of texture units in texture '%s'", tex->Name.GetChars()); sc.ScriptError("Error: out of texture units in texture '%s'", tex->GetName().GetChars());
} }
} }
} }
@ -1320,10 +1317,10 @@ class GLDefsParser
{ {
sc.MustGetString(); sc.MustGetString();
if (textures[i]) if (textures[i])
Printf("Multiple %s definitions in texture %s\n", keywords[i], tex? tex->Name.GetChars() : "(null)"); Printf("Multiple %s definitions in texture %s\n", keywords[i], tex? tex->GetName().GetChars() : "(null)");
textures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny); textures[i] = TexMan.FindGameTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (!textures[i]) if (!textures[i])
Printf("%s '%s' not found in texture '%s'\n", notFound[i], sc.String, tex? tex->Name.GetChars() : "(null)"); Printf("%s '%s' not found in texture '%s'\n", notFound[i], sc.String, tex? tex->GetName().GetChars() : "(null)");
break; break;
} }
} }
@ -1346,36 +1343,35 @@ class GLDefsParser
if (!useme) return; if (!useme) return;
} }
FTexture **bindings[6] = FGameTexture **bindings[6] =
{ {
&tex->Brightmap, &mlay.Brightmap,
&tex->Normal, &mlay.Normal,
&tex->Specular, &mlay.Specular,
&tex->Metallic, &mlay.Metallic,
&tex->Roughness, &mlay.Roughness,
&tex->AmbientOcclusion &mlay.AmbientOcclusion
}; };
for (int i = 0; keywords[i] != nullptr; i++) for (int i = 0; keywords[i] != nullptr; i++)
{ {
if (textures[i]) if (textures[i])
{ {
textures[i]->bMasked = false;
*bindings[i] = textures[i]; *bindings[i] = textures[i];
} }
} }
if (disable_fullbright_specified) if (disable_fullbright_specified)
tex->bDisableFullbright = disable_fullbright; tex->SetDisableFullbright(disable_fullbright);
if (usershader.shader.IsNotEmpty()) if (usershader.shader.IsNotEmpty())
{ {
int firstUserTexture; int firstUserTexture;
if (tex->Normal && tex->Specular) if (mlay.Normal && mlay.Specular)
{ {
usershader.shaderType = SHADER_Specular; usershader.shaderType = SHADER_Specular;
firstUserTexture = 7; firstUserTexture = 7;
} }
else if (tex->Normal && tex->Metallic && tex->Roughness && tex->AmbientOcclusion) else if (mlay.Normal && mlay.Metallic && mlay.Roughness && mlay.AmbientOcclusion)
{ {
usershader.shaderType = SHADER_PBR; usershader.shaderType = SHADER_PBR;
firstUserTexture = 9; firstUserTexture = 9;
@ -1393,10 +1389,10 @@ class GLDefsParser
if (tex->isWarped() != 0) if (tex->isWarped() != 0)
{ {
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->GetName().GetChars());
return; return;
} }
tex->shaderspeed = speed; tex->SetShaderSpeed(speed);
for (unsigned i = 0; i < usershaders.Size(); i++) for (unsigned i = 0; i < usershaders.Size(); i++)
{ {
if (!usershaders[i].shader.CompareNoCase(usershader.shader) && if (!usershaders[i].shader.CompareNoCase(usershader.shader) &&
@ -1409,6 +1405,7 @@ class GLDefsParser
} }
SetShaderIndex(tex, usershaders.Push(usershader) + FIRST_USER_SHADER); SetShaderIndex(tex, usershaders.Push(usershader) + FIRST_USER_SHADER);
} }
tex->SetShaderLayers(mlay);
} }
@ -1523,7 +1520,8 @@ class GLDefsParser
sc.MustGetString(); sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type); FTextureID no = TexMan.CheckForTexture(sc.String, type);
FTexture *tex = TexMan.GetTexture(no); auto tex = TexMan.GetGameTexture(no);
MaterialLayers mlay = { -1000, -1000 };
sc.MustGetToken('{'); sc.MustGetToken('{');
while (!sc.CheckToken('}')) while (!sc.CheckToken('}'))
@ -1567,19 +1565,19 @@ class GLDefsParser
{ {
if(!texName.Compare(textureName)) if(!texName.Compare(textureName))
{ {
sc.ScriptError("Trying to redefine custom hardware shader texture '%s' in texture '%s'\n", textureName.GetChars(), tex? tex->Name.GetChars() : "(null)"); sc.ScriptError("Trying to redefine custom hardware shader texture '%s' in texture '%s'\n", textureName.GetChars(), tex? tex->GetName().GetChars() : "(null)");
} }
} }
sc.MustGetString(); sc.MustGetString();
bool okay = false; bool okay = false;
for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++) for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++)
{ {
if (!tex->CustomShaderTextures[i]) if (!mlay.CustomShaderTextures[i])
{ {
tex->CustomShaderTextures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny); mlay.CustomShaderTextures[i] = TexMan.FindGameTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (!tex->CustomShaderTextures[i]) if (!mlay.CustomShaderTextures[i])
{ {
sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex? tex->Name.GetChars() : "(null)"); sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex? tex->GetName().GetChars() : "(null)");
} }
texNameList.Push(textureName); texNameList.Push(textureName);
@ -1590,7 +1588,7 @@ class GLDefsParser
} }
if(!okay) if(!okay)
{ {
sc.ScriptError("Error: out of texture units in texture '%s'", tex? tex->Name.GetChars() : "(null)"); sc.ScriptError("Error: out of texture units in texture '%s'", tex? tex->GetName().GetChars() : "(null)");
} }
} }
else if(sc.Compare("define")) else if(sc.Compare("define"))
@ -1633,10 +1631,10 @@ class GLDefsParser
{ {
if (tex->isWarped() != 0) if (tex->isWarped() != 0)
{ {
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->GetName().GetChars());
return; return;
} }
tex->shaderspeed = speed; tex->SetShaderSpeed(speed);
for (unsigned i = 0; i < usershaders.Size(); i++) for (unsigned i = 0; i < usershaders.Size(); i++)
{ {
if (!usershaders[i].shader.CompareNoCase(desc.shader) && if (!usershaders[i].shader.CompareNoCase(desc.shader) &&
@ -1649,6 +1647,7 @@ class GLDefsParser
} }
SetShaderIndex(tex, usershaders.Push(desc) + FIRST_USER_SHADER); SetShaderIndex(tex, usershaders.Push(desc) + FIRST_USER_SHADER);
} }
tex->SetShaderLayers(mlay);
} }
} }

View file

@ -209,7 +209,7 @@ void HWWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
flipy = !!(decal->RenderFlags & RF_YFLIP); flipy = !!(decal->RenderFlags & RF_YFLIP);
FTexture *texture = TexMan.GetTexture(decalTile); auto texture = TexMan.GetGameTexture(decalTile);
if (texture == NULL) return; if (texture == NULL) return;
@ -265,14 +265,13 @@ void HWWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling);
} }
} }
FMaterial *tex = FMaterial::ValidateTexture(texture, false);
// now clip the decal to the actual polygon // now clip the decal to the actual polygon
float decalwidth = tex->TextureWidth() * decal->ScaleX; float decalwidth = texture->GetDisplayWidth() * decal->ScaleX;
float decalheight = tex->TextureHeight() * decal->ScaleY; float decalheight = texture->GetDisplayHeight() * decal->ScaleY;
float decallefto = tex->GetLeftOffset() * decal->ScaleX; float decallefto = texture->GetDisplayLeftOffset() * decal->ScaleX;
float decaltopo = tex->GetTopOffset() * decal->ScaleY; float decaltopo = texture->GetDisplayTopOffset() * decal->ScaleY;
float leftedge = glseg.fracleft * side->TexelLength; float leftedge = glseg.fracleft * side->TexelLength;
float linelength = glseg.fracright * side->TexelLength - leftedge; float linelength = glseg.fracright * side->TexelLength - leftedge;
@ -314,6 +313,8 @@ void HWWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
float vx = (glseg.x2 - glseg.x1) / linelength; float vx = (glseg.x2 - glseg.x1) / linelength;
float vy = (glseg.y2 - glseg.y1) / linelength; float vy = (glseg.y2 - glseg.y1) / linelength;
FMaterial* tex = FMaterial::ValidateTexture(texture->GetTexture(), false);
DecalVertex dv[4]; DecalVertex dv[4];
enum enum
{ {

View file

@ -118,7 +118,7 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
// now check for closed sectors! // now check for closed sectors!
if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2) if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2)
{ {
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::top), true); auto tex = TexMan.GetGameTexture(sidedef->GetTexture(side_t::top), true);
if (!tex || !tex->isValid()) return false; if (!tex || !tex->isValid()) return false;
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum && if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false; frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
@ -127,7 +127,7 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2) if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2)
{ {
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::bottom), true); auto tex = TexMan.GetGameTexture(sidedef->GetTexture(side_t::bottom), true);
if (!tex || !tex->isValid()) return false; if (!tex || !tex->isValid()) return false;
// properly render skies (consider door "open" if both floors are sky): // properly render skies (consider door "open" if both floors are sky):
@ -141,12 +141,12 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
// preserve a kind of transparent door/lift special effect: // preserve a kind of transparent door/lift special effect:
if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2) if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2)
{ {
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::top), true); auto tex = TexMan.GetGameTexture(sidedef->GetTexture(side_t::top), true);
if (!tex || !tex->isValid()) return false; if (!tex || !tex->isValid()) return false;
} }
if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2) if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2)
{ {
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::bottom), true); auto tex = TexMan.GetGameTexture(sidedef->GetTexture(side_t::bottom), true);
if (!tex || !tex->isValid()) return false; if (!tex || !tex->isValid()) return false;
} }
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum && if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&

View file

@ -61,9 +61,9 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
} }
FTextureID texno = s->GetTexture(pos); FTextureID texno = s->GetTexture(pos);
FTexture* tex = TexMan.GetTexture(texno, true); auto tex = TexMan.GetGameTexture(texno, true);
if (!tex || !tex->isValid()) goto normalsky; if (!tex || !tex->isValid()) goto normalsky;
texture[0] = FMaterial::ValidateTexture(tex, false); texture[0] = FMaterial::ValidateTexture(tex->GetTexture(), false);
skytexno1 = texno; skytexno1 = texno;
x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f); x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f);
y_offset = s->GetTextureYOffset(pos); y_offset = s->GetTextureYOffset(pos);
@ -74,9 +74,9 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
normalsky: normalsky:
if (di->Level->flags&LEVEL_DOUBLESKY) if (di->Level->flags&LEVEL_DOUBLESKY)
{ {
auto tex1 = TexMan.GetTexture(di->Level->skytexture1, true); auto tex1 = TexMan.GetGameTexture(di->Level->skytexture1, true);
if (tex1) tex1 = tex1->GetFrontSkyLayer(); if (tex1) tex1 = tex1->GetFrontSkyLayer();
texture[1] = FMaterial::ValidateTexture(tex1, false); texture[1] = FMaterial::ValidateTexture(tex1->GetTexture(), false);
x_offset[1] = di->Level->hw_sky1pos; x_offset[1] = di->Level->hw_sky1pos;
doublesky = true; doublesky = true;
} }
@ -247,13 +247,13 @@ void HWWall::SkyTop(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,vert
{ {
if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.) if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.)
{ {
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom), true); auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::bottom), true);
if (!tex || !tex->isValid()) return; if (!tex || !tex->isValid()) return;
// very, very, very ugly special case (See Icarus MAP14) // very, very, very ugly special case (See Icarus MAP14)
// It is VERY important that this is only done for a floor height difference of 1 // It is VERY important that this is only done for a floor height difference of 1
// or it will cause glitches elsewhere. // or it will cause glitches elsewhere.
tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::mid), true); tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::mid), true);
if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) && if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) &&
seg->sidedef->GetTextureYOffset(side_t::mid) > 0) seg->sidedef->GetTextureYOffset(side_t::mid) > 0)
{ {
@ -269,7 +269,7 @@ void HWWall::SkyTop(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,vert
ztop[0]=ztop[1]=32768.0f; ztop[0]=ztop[1]=32768.0f;
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::top), true); auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::top), true);
if (bs->GetTexture(sector_t::ceiling) != skyflatnum) if (bs->GetTexture(sector_t::ceiling) != skyflatnum)
{ {
@ -329,7 +329,7 @@ void HWWall::SkyBottom(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,v
if (fs->GetTexture(sector_t::floor)==skyflatnum) if (fs->GetTexture(sector_t::floor)==skyflatnum)
{ {
if (bs->special == GLSector_NoSkyDraw || (bs->MoreFlags & SECMF_NOSKYWALLS) != 0 || (seg->linedef->flags & ML_NOSKYWALLS) != 0) return; if (bs->special == GLSector_NoSkyDraw || (bs->MoreFlags & SECMF_NOSKYWALLS) != 0 || (seg->linedef->flags & ML_NOSKYWALLS) != 0) return;
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom), true); auto tex = TexMan.GetGameTexture(seg->sidedef->GetTexture(side_t::bottom), true);
// For lower skies the normal logic only applies to walls with no lower texture. // For lower skies the normal logic only applies to walls with no lower texture.
if (!tex->isValid()) if (!tex->isValid())

View file

@ -109,7 +109,7 @@ namespace swrenderer
FTextureID lump = sprites[psp->GetSprite()].GetSpriteFrame(psp->GetFrame(), 0, 0., nullptr); FTextureID lump = sprites[psp->GetSprite()].GetSpriteFrame(psp->GetFrame(), 0, 0., nullptr);
if (lump.isValid()) if (lump.isValid())
{ {
FTexture * tex = TexMan.GetTexture(lump, true); auto tex = TexMan.GetGameTexture(lump, true);
if (tex) disablefullbright = tex->isFullbrightDisabled(); if (tex) disablefullbright = tex->isFullbrightDisabled();
} }
return psp->GetState()->GetFullbright() && !disablefullbright; return psp->GetState()->GetFullbright() && !disablefullbright;