named targets for image assets

image assets can now be bound to a named texture target
if used in a material the target needs to exist before the material is initialized
This commit is contained in:
marauder2k7 2024-12-13 00:26:39 +00:00
parent ad9da79e91
commit 85463c85ac
3 changed files with 88 additions and 17 deletions

View file

@ -410,12 +410,21 @@ void ProcessedMaterial::_setStageData()
{
//If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass. So we'll
//pass on the error rather than spamming the console
if (!String(mMaterial->mDiffuseMapName[i]).startsWith("#"))
mMaterial->logError("Failed to load diffuse map %s for stage %i", mMaterial->mDiffuseMapName[i], i);
if (String(mMaterial->mDiffuseMapName[i]).startsWith("#") || String(mMaterial->mDiffuseMapName[i]).startsWith("$"))
{
NamedTexTarget* namedTarget = NamedTexTarget::find(mMaterial->mDiffuseMapName[i] + 1);
if(namedTarget)
mStages[i].setTex(MFT_DiffuseMap, namedTarget->getTexture(0));
}
else
{
if (!String(mMaterial->mDiffuseMapName[i]).startsWith("#"))
mMaterial->logError("Failed to load diffuse map %s for stage %i", mMaterial->mDiffuseMapName[i], i);
// Load a debug texture to make it clear to the user
// that the texture for this stage was missing.
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
// Load a debug texture to make it clear to the user
// that the texture for this stage was missing.
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
}
}
}