fixes for reload and flush

This commit is contained in:
marauder2k7 2024-12-14 13:37:23 +00:00
parent f6dc694bd4
commit 1edfbcf447
7 changed files with 88 additions and 39 deletions

View file

@ -395,30 +395,42 @@ void ProcessedMaterial::_setStageData()
if (mMaterial->mDiffuseMapAsset[i] && !mMaterial->mDiffuseMapAsset[i].isNull())
{
mStages[i].setTex(MFT_DiffuseMap, mMaterial->getDiffuseMapResource(i));
//mStages[i].setTex(MFT_DiffuseMap, _createTexture(mMaterial->getDiffuseMap(i), &GFXStaticTextureSRGBProfile));
if (!mStages[i].getTex(MFT_DiffuseMap))
{
// 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.
if (String(mMaterial->mDiffuseMapAsset[i]->getImageFileName()).startsWith("#") || String(mMaterial->mDiffuseMapAsset[i]->getImageFileName()).startsWith("$"))
{
NamedTexTarget* namedTarget = NamedTexTarget::find(mMaterial->mDiffuseMapAsset[i]->getImageFileName() + 1);
if (namedTarget)
mStages[i].setTex(MFT_DiffuseMap, namedTarget->getTexture(0));
if (mStages[i].getTex(MFT_DiffuseMap))
{
mMaterial->mDiffuseMap[i] = namedTarget->getTexture(0);
}
if (!mStages[i].getTex(MFT_DiffuseMap))
mHasSetStageData = false;
mMaterial->logError("Named Target not ready %s for stage %i", mMaterial->mDiffuseMapAsset[i]->getImageFileName(), i);
mHasSetStageData = false;
}
else {
else
{
// 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));
}
}
}
else if (mMaterial->mDiffuseMapName[i] != StringTable->EmptyString())
{
mStages[i].setTex(MFT_DiffuseMap, _createTexture(mMaterial->mDiffuseMapName[i], &GFXStaticTextureSRGBProfile));
if (!mStages[i].getTex(MFT_DiffuseMap))
{
//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("#") || String(mMaterial->mDiffuseMapName[i]).startsWith("$"))
{
mMaterial->logError("Named Target not ready %s for stage %i", mMaterial->mDiffuseMapName[i], i);
mHasSetStageData = false;
}
else
{
// 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));
}
}
}
// OverlayMap
if (mMaterial->getOverlayMap(i) != StringTable->EmptyString())
{