mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-07 17:11:17 +00:00
- Implement auto textures for materials
This commit is contained in:
parent
4e7ca68bd6
commit
05827ffcda
2 changed files with 36 additions and 12 deletions
|
@ -68,7 +68,7 @@ CUSTOM_CVAR(Bool, gl_notexturefill, false, 0)
|
||||||
|
|
||||||
|
|
||||||
void gl_CreateSections();
|
void gl_CreateSections();
|
||||||
void AddAutoBrightmaps();
|
void AddAutoMaterials();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -364,7 +364,7 @@ void gl_RecalcVertexHeights(vertex_t * v)
|
||||||
void gl_InitData()
|
void gl_InitData()
|
||||||
{
|
{
|
||||||
AdjustSpriteOffsets();
|
AdjustSpriteOffsets();
|
||||||
AddAutoBrightmaps();
|
AddAutoMaterials();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -763,26 +763,50 @@ void gl_ParseBrightmap(FScanner &sc, int deflump)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
// Search auto paths for extra material textures
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void AddAutoBrightmaps()
|
struct AutoTextureSearchPath
|
||||||
|
{
|
||||||
|
const char *path;
|
||||||
|
ptrdiff_t offset;
|
||||||
|
|
||||||
|
void SetTexture(FTexture *material, FTexture *texture) const
|
||||||
|
{
|
||||||
|
*reinterpret_cast<FTexture**>(reinterpret_cast<uint8_t*>(&material->gl_info) + offset) = texture;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static AutoTextureSearchPath autosearchpaths[] =
|
||||||
|
{
|
||||||
|
{ "brightmaps/auto/", offsetof(FTexture::MiscGLInfo, Brightmap) },
|
||||||
|
{ "normalmaps/auto/", offsetof(FTexture::MiscGLInfo, Normal) },
|
||||||
|
{ "specular/auto/", offsetof(FTexture::MiscGLInfo, Specular) },
|
||||||
|
{ "metallic/auto/", offsetof(FTexture::MiscGLInfo, Metallic) },
|
||||||
|
{ "roughness/auto/", offsetof(FTexture::MiscGLInfo, Roughness) },
|
||||||
|
{ "ao/auto/", offsetof(FTexture::MiscGLInfo, AmbientOcclusion) }
|
||||||
|
};
|
||||||
|
|
||||||
|
void AddAutoMaterials()
|
||||||
{
|
{
|
||||||
int num = Wads.GetNumLumps();
|
int num = Wads.GetNumLumps();
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
const char *name = Wads.GetLumpFullName(i);
|
const char *name = Wads.GetLumpFullName(i);
|
||||||
if (strstr(name, "brightmaps/auto/") == name)
|
for (const AutoTextureSearchPath &searchpath : autosearchpaths)
|
||||||
{
|
{
|
||||||
TArray<FTextureID> list;
|
if (strstr(name, searchpath.path) == name)
|
||||||
FString texname = ExtractFileBase(name, false);
|
|
||||||
TexMan.ListTextures(texname, list);
|
|
||||||
auto bmtex = TexMan.FindTexture(name, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny);
|
|
||||||
for (auto texid : list)
|
|
||||||
{
|
{
|
||||||
bmtex->bMasked = false;
|
TArray<FTextureID> list;
|
||||||
TexMan[texid]->gl_info.Brightmap = bmtex;
|
FString texname = ExtractFileBase(name, false);
|
||||||
|
TexMan.ListTextures(texname, list);
|
||||||
|
auto bmtex = TexMan.FindTexture(name, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny);
|
||||||
|
for (auto texid : list)
|
||||||
|
{
|
||||||
|
bmtex->bMasked = false;
|
||||||
|
searchpath.SetTexture(TexMan[texid], bmtex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue