diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index 4e8a9c192..dee0afbe3 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -3000,15 +3000,15 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem) } else if (imageType == ImageAsset::ImageTypes::Metalness) { - newMat->mMetalMapAssetId[0] = assetMapFillInStr; + newMat->_setMetalMap(assetMapFillInStr, 0); } else if (imageType == ImageAsset::ImageTypes::AO) { - newMat->mAOMapAssetId[0] = assetMapFillInStr; + newMat->_setAOMap(assetMapFillInStr, 0); } else if (imageType == ImageAsset::ImageTypes::Roughness) { - newMat->mRoughMapAssetId[0] = assetMapFillInStr; + newMat->_setRoughMap(assetMapFillInStr, 0); hasRoughness = true; } } diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 80a1e46c1..486ecbd1d 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -142,11 +142,6 @@ Material::Material() mAccuCoverage[i] = 0.9f; mAccuSpecular[i] = 16.0f; - INIT_IMAGEASSET_ARRAY(RoughMap, GFXStaticTextureProfile, i); - INIT_IMAGEASSET_ARRAY(AOMap, GFXStaticTextureProfile, i); - INIT_IMAGEASSET_ARRAY(MetalMap, GFXStaticTextureProfile, i); - INIT_IMAGEASSET_ARRAY(GlowMap, GFXStaticTextureProfile, i); - mParallaxScale[i] = 0.0f; mVertLit[i] = false; @@ -281,10 +276,10 @@ void Material::initPersistFields() addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES, "Substance Designer Workaround."); - INITPERSISTFIELD_IMAGEASSET_ARRAY(AOMap, MAX_STAGES, Material, "AOMap"); - INITPERSISTFIELD_IMAGEASSET_ARRAY(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)"); - INITPERSISTFIELD_IMAGEASSET_ARRAY(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)"); - INITPERSISTFIELD_IMAGEASSET_ARRAY(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)"); + INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(AOMap, MAX_STAGES, Material, "AOMap"); + INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)"); + INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)"); + INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)"); addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES, "glow mask multiplier"); @@ -823,7 +818,7 @@ DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, LightMap, Material::Constants::MAX DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, ToneMap, Material::Constants::MAX_STAGES) DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, DetailMap, Material::Constants::MAX_STAGES) DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, ORMConfigMap, Material::Constants::MAX_STAGES) -DEF_IMAGEASSET_ARRAY_BINDS(Material, RoughMap); -DEF_IMAGEASSET_ARRAY_BINDS(Material, AOMap); -DEF_IMAGEASSET_ARRAY_BINDS(Material, MetalMap); -DEF_IMAGEASSET_ARRAY_BINDS(Material, GlowMap); +DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, RoughMap, Material::Constants::MAX_STAGES) +DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, AOMap, Material::Constants::MAX_STAGES) +DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, MetalMap, Material::Constants::MAX_STAGES) +DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, GlowMap, Material::Constants::MAX_STAGES) diff --git a/Engine/source/materials/materialDefinition.h b/Engine/source/materials/materialDefinition.h index 4ef870aa3..db8312d3a 100644 --- a/Engine/source/materials/materialDefinition.h +++ b/Engine/source/materials/materialDefinition.h @@ -211,36 +211,26 @@ public: DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DiffuseMap, GFXStaticTextureSRGBProfile, MAX_STAGES) DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, NormalMap, GFXNormalMapProfile, MAX_STAGES) DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DetailNormalMap, GFXNormalMapProfile, MAX_STAGES) - - bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, OverlayMap, GFXStaticTextureProfile, MAX_STAGES) DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, LightMap, GFXStaticTextureProfile, MAX_STAGES) DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, ToneMap, GFXStaticTextureProfile, MAX_STAGES) DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DetailMap, GFXStaticTextureProfile, MAX_STAGES) DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, ORMConfigMap, GFXStaticTextureProfile, MAX_STAGES) + DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, AOMap, GFXStaticTextureProfile, MAX_STAGES) + DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, RoughMap, GFXStaticTextureProfile, MAX_STAGES) + DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, MetalMap, GFXStaticTextureProfile, MAX_STAGES) + DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, GlowMap, GFXStaticTextureProfile, MAX_STAGES) - bool mIsSRGb[MAX_STAGES]; - DECLARE_IMAGEASSET_ARRAY(Material, AOMap, MAX_STAGES, onImageAssetChanged); - DECLARE_IMAGEASSET_ARRAY_SETGET(Material, AOMap); + bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse + bool mIsSRGb[MAX_STAGES]; // SRGB ORM F32 mAOChan[MAX_STAGES]; - - DECLARE_IMAGEASSET_ARRAY(Material, RoughMap, MAX_STAGES, onImageAssetChanged); - DECLARE_IMAGEASSET_ARRAY_SETGET(Material, RoughMap); bool mInvertRoughness[MAX_STAGES]; F32 mRoughnessChan[MAX_STAGES]; - - DECLARE_IMAGEASSET_ARRAY(Material, MetalMap, MAX_STAGES, onImageAssetChanged); - DECLARE_IMAGEASSET_ARRAY_SETGET(Material, MetalMap); - F32 mMetalChan[MAX_STAGES]; - DECLARE_IMAGEASSET_ARRAY(Material, GlowMap, MAX_STAGES, onImageAssetChanged); - DECLARE_IMAGEASSET_ARRAY_SETGET(Material, GlowMap); - F32 mGlowMul[MAX_STAGES]; /// The strength scalar for the detail normal map. - F32 mDetailNormalMapStrength[MAX_STAGES]; - + F32 mDetailNormalMapStrength[MAX_STAGES]; bool mAccuEnabled[MAX_STAGES]; F32 mAccuScale[MAX_STAGES]; F32 mAccuDirection[MAX_STAGES]; diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index 031ffb58c..41242c9b1 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -470,25 +470,25 @@ void ProcessedMaterial::_setStageData() } else { - if ((mMaterial->getAOMap(i) != StringTable->EmptyString()) || (mMaterial->getRoughMap(i) != StringTable->EmptyString()) || (mMaterial->getMetalMap(i) != StringTable->EmptyString())) + if ((mMaterial->getAOMapAsset(i).notNull()) || (mMaterial->getRoughMapAsset(i).notNull()) || (mMaterial->getMetalMapAsset(i).notNull())) { U32 inputKey[4]; inputKey[0] = mMaterial->mAOChan[i]; inputKey[1] = mMaterial->mRoughnessChan[i]; inputKey[2] = mMaterial->mMetalChan[i]; inputKey[3] = 0; - mStages[i].setTex(MFT_OrmMap, _createCompositeTexture( mMaterial->getAOMap(i), mMaterial->getRoughMap(i), - mMaterial->getMetalMap(i), "", + mStages[i].setTex(MFT_OrmMap, _createCompositeTexture( mMaterial->getAOMapAsset(i)->getImageFile(), mMaterial->getRoughMapAsset(i)->getImageFile(), + mMaterial->getMetalMapAsset(i)->getImageFile(), "", inputKey, profile)); if (!mStages[i].getTex(MFT_OrmMap)) mMaterial->logError("Failed to dynamically create ORM Config map for stage %i", i); } } - if (mMaterial->getGlowMap(i) != StringTable->EmptyString()) + if (mMaterial->getGlowMapAsset(i).notNull()) { - mStages[i].setTex(MFT_GlowMap, mMaterial->getGlowMapResource(i)); + mStages[i].setTex(MFT_GlowMap, mMaterial->getGlowMap(i)); if (!mStages[i].getTex(MFT_GlowMap)) - mMaterial->logError("Failed to load glow map %s for stage %i", mMaterial->getGlowMap(i), i); + mMaterial->logError("Failed to load glow map %s for stage %i", mMaterial->_getGlowMap(i), i); } } diff --git a/Engine/source/ts/assimp/assimpAppMaterial.cpp b/Engine/source/ts/assimp/assimpAppMaterial.cpp index 71526e9c0..d761f1a18 100644 --- a/Engine/source/ts/assimp/assimpAppMaterial.cpp +++ b/Engine/source/ts/assimp/assimpAppMaterial.cpp @@ -194,20 +194,20 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co { // If we have either map, fill all three slots if (rmName.isNotEmpty()) { - mat->mRoughMapName[0] = cleanTextureName(rmName, cleanFile, path, false); // Roughness + mat->_setRoughMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Roughness mat->mRoughnessChan[0] = 1.0f; mat->mInvertRoughness[0] = (floatVal == 1.0f); - mat->mMetalMapName[0] = cleanTextureName(rmName, cleanFile, path, false); // Metallic + mat->_setMetalMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Metallic mat->mMetalChan[0] = 2.0f; } if (aoName.isNotEmpty()) { - mat->mAOMapName[0] = cleanTextureName(aoName, cleanFile, path, false); // occlusion + mat->_setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion mat->mAOChan[0] = 0.0f; } else { - mat->mAOMapName[0] = cleanTextureName(rmName, cleanFile, path, false); // occlusion + mat->_setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion mat->mAOChan[0] = 0.0f; } }