marauder2k7 1 рік тому
батько
коміт
58119a4f82

+ 6 - 4
Engine/source/T3D/assets/ImageAsset.h

@@ -598,7 +598,7 @@ public:
                                                                                                                                                                               \
       if(!AssetDatabase.isDeclaredAsset(_in))                                                                                                                                 \
       {                                                                                                                                                                       \
-         StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback;                                                                                                  \
+         StringTableEntry imageAssetId = StringTable->EmptyString();                                                                                                          \
          AssetQuery query;                                                                                                                                                    \
          S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in);                                                                                                 \
          if (foundAssetcount != 0)                                                                                                                                            \
@@ -629,7 +629,7 @@ public:
                                                                                                                                                                               \
       if(!AssetDatabase.isDeclaredAsset(_in))                                                                                                                                 \
       {                                                                                                                                                                       \
-         StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback;                                                                                                  \
+         StringTableEntry imageAssetId = StringTable->EmptyString();                                                                                                          \
          AssetQuery query;                                                                                                                                                    \
          S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in);                                                                                                 \
          if (foundAssetcount != 0)                                                                                                                                            \
@@ -665,7 +665,7 @@ public:
                                                                                                                                                                               \
       if(!AssetDatabase.isDeclaredAsset(_in))                                                                                                                                 \
       {                                                                                                                                                                       \
-         StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback;                                                                                                  \
+         StringTableEntry imageAssetId = StringTable->EmptyString();                                                                                                          \
          AssetQuery query;                                                                                                                                                    \
          S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in);                                                                                                 \
          if (foundAssetcount != 0)                                                                                                                                            \
@@ -682,6 +682,7 @@ public:
                                                                                                                                                                               \
    inline StringTableEntry _get##name(const U32& index) const { return m##name##Asset[index].getAssetId(); }                                                                  \
    GFXTexHandle get##name(const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(&profile) : NULL; }                                  \
+   GFXTexHandle get##name(GFXTextureProfile* requestedProfile, const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(requestedProfile) : NULL; }\
    AssetPtr<ImageAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; }                                                                                  \
    static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}
 
@@ -696,7 +697,7 @@ public:
                                                                                                                                                                               \
       if(!AssetDatabase.isDeclaredAsset(_in))                                                                                                                                 \
       {                                                                                                                                                                       \
-         StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback;                                                                                                  \
+         StringTableEntry imageAssetId = StringTable->EmptyString();                                                                                                          \
          AssetQuery query;                                                                                                                                                    \
          S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in);                                                                                                 \
          if (foundAssetcount != 0)                                                                                                                                            \
@@ -714,6 +715,7 @@ public:
                                                                                                                                                                               \
    inline StringTableEntry _get##name(const U32& index) const { return m##name##Asset[index].getAssetId(); }                                                                  \
    GFXTexHandle get##name(const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(&profile) : NULL; }                                  \
+   GFXTexHandle get##name(GFXTextureProfile* requestedProfile, const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(requestedProfile) : NULL; }\
    AssetPtr<ImageAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; }                                                                                  \
    static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}
 

+ 1 - 1
Engine/source/T3D/assets/assetImporter.cpp

@@ -2996,7 +2996,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
          }
          else if (imageType == ImageAsset::ImageTypes::ORMConfig)
          {
-            newMat->mORMConfigMapAssetId[0] = assetMapFillInStr;
+            newMat->_setORMConfigMap(assetMapFillInStr, 0);
          }
          else if (imageType == ImageAsset::ImageTypes::Metalness)
          {

+ 11 - 22
Engine/source/materials/materialDefinition.cpp

@@ -142,11 +142,6 @@ Material::Material()
       mAccuCoverage[i] = 0.9f;
       mAccuSpecular[i] = 16.0f;
 
-      INIT_IMAGEASSET_ARRAY(OverlayMap, GFXStaticTextureProfile, i);
-      INIT_IMAGEASSET_ARRAY(LightMap, GFXStaticTextureProfile, i);
-      INIT_IMAGEASSET_ARRAY(ToneMap, GFXStaticTextureProfile, i);
-      INIT_IMAGEASSET_ARRAY(DetailMap, GFXStaticTextureProfile, i);
-      INIT_IMAGEASSET_ARRAY(ORMConfigMap, GFXStaticTextureProfile, i);
       INIT_IMAGEASSET_ARRAY(RoughMap, GFXStaticTextureProfile, i);
       INIT_IMAGEASSET_ARRAY(AOMap, GFXStaticTextureProfile, i);
       INIT_IMAGEASSET_ARRAY(MetalMap, GFXStaticTextureProfile, i);
@@ -282,7 +277,7 @@ void Material::initPersistFields()
       addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES,
          "The input channel metalness maps use.");
 
-      INITPERSISTFIELD_IMAGEASSET_ARRAY(ORMConfigMap, MAX_STAGES, Material, "AO|Roughness|metalness map");
+      INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(ORMConfigMap, MAX_STAGES, Material, "AO|Roughness|metalness map");
       addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES,
          "Substance Designer Workaround.");
 
@@ -296,7 +291,7 @@ void Material::initPersistFields()
    endGroup("Light Influence Maps");
 
    addGroup("Advanced Texture Maps");
-      INITPERSISTFIELD_IMAGEASSET_ARRAY(DetailMap, MAX_STAGES, Material, "DetailMap");
+      INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(DetailMap, MAX_STAGES, Material, "DetailMap");
       addField("detailScale", TypePoint2F, Offset(mDetailScale, Material), MAX_STAGES,
          "The scale factor for the detail map.");
 
@@ -304,9 +299,9 @@ void Material::initPersistFields()
       addField("detailNormalMapStrength", TypeF32, Offset(mDetailNormalMapStrength, Material), MAX_STAGES,
          "Used to scale the strength of the detail normal map when blended with the base normal map.");
 
-      INITPERSISTFIELD_IMAGEASSET_ARRAY(OverlayMap, MAX_STAGES, Material, "Overlay");
-      INITPERSISTFIELD_IMAGEASSET_ARRAY(LightMap, MAX_STAGES, Material, "LightMap");
-      INITPERSISTFIELD_IMAGEASSET_ARRAY(ToneMap, MAX_STAGES, Material, "ToneMap");
+      INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(OverlayMap, MAX_STAGES, Material, "Overlay");
+      INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(LightMap, MAX_STAGES, Material, "LightMap");
+      INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(ToneMap, MAX_STAGES, Material, "ToneMap");
    endGroup("Advanced Texture Maps");
    
    addGroup("Accumulation Properties");
@@ -503,12 +498,6 @@ void Material::initPersistFields()
    // They point at the new 'map' fields, but reads always return
    // an empty string and writes only apply if the value is not empty.
    //
-   addProtectedField("detailTex", TypeImageFilename, Offset(mDetailMapName, Material),
-      defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
-      "For backwards compatibility.\n@see detailMap\n", AbstractClassRep::FIELD_HideInInspectors);
-   addProtectedField("overlayTex", TypeImageFilename, Offset(mOverlayMapName, Material),
-      defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
-      "For backwards compatibility.\n@see overlayMap\n", AbstractClassRep::FIELD_HideInInspectors);
    addProtectedField("colorMultiply", TypeColorF, Offset(mDiffuse, Material),
       defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
       "For backwards compatibility.\n@see diffuseColor\n", AbstractClassRep::FIELD_HideInInspectors);
@@ -614,7 +603,7 @@ bool Material::isLightmapped() const
 {
    bool ret = false;
    for (U32 i = 0; i < MAX_STAGES; i++)
-      ret |= mLightMapName[i] != StringTable->EmptyString() || mToneMapName[i] != StringTable->EmptyString() || mVertLit[i];
+      ret |= mLightMapAsset[i].notNull() || mToneMapAsset[i].notNull() || mVertLit[i];
    return ret;
 }
 
@@ -829,11 +818,11 @@ bool Material::_setAccuEnabled(void* object, const char* index, const char* data
 DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, DiffuseMap, Material::Constants::MAX_STAGES)
 DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, NormalMap, Material::Constants::MAX_STAGES)
 DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, DetailNormalMap, Material::Constants::MAX_STAGES)
-DEF_IMAGEASSET_ARRAY_BINDS(Material, OverlayMap);
-DEF_IMAGEASSET_ARRAY_BINDS(Material, LightMap);
-DEF_IMAGEASSET_ARRAY_BINDS(Material, ToneMap);
-DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailMap);
-DEF_IMAGEASSET_ARRAY_BINDS(Material, ORMConfigMap);
+DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, OverlayMap, Material::Constants::MAX_STAGES)
+DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, LightMap, Material::Constants::MAX_STAGES)
+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);

+ 5 - 15
Engine/source/materials/materialDefinition.h

@@ -213,21 +213,11 @@ public:
    DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DetailNormalMap, GFXNormalMapProfile, MAX_STAGES)
 
    bool     mDiffuseMapSRGB[MAX_STAGES];   // SRGB diffuse
-   DECLARE_IMAGEASSET_ARRAY(Material, OverlayMap, MAX_STAGES, onImageAssetChanged);
-   DECLARE_IMAGEASSET_ARRAY_SETGET(Material, OverlayMap);
-
-   DECLARE_IMAGEASSET_ARRAY(Material, LightMap, MAX_STAGES, onImageAssetChanged);
-   DECLARE_IMAGEASSET_ARRAY_SETGET(Material, LightMap);
-
-   DECLARE_IMAGEASSET_ARRAY(Material, ToneMap, MAX_STAGES, onImageAssetChanged);
-   DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ToneMap);
-
-   DECLARE_IMAGEASSET_ARRAY(Material, DetailMap, MAX_STAGES, onImageAssetChanged);
-   DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailMap);
-
-
-   DECLARE_IMAGEASSET_ARRAY(Material, ORMConfigMap, MAX_STAGES, onImageAssetChanged);
-   DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ORMConfigMap);
+   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)
 
    bool     mIsSRGb[MAX_STAGES];
    DECLARE_IMAGEASSET_ARRAY(Material, AOMap, MAX_STAGES, onImageAssetChanged);

+ 16 - 16
Engine/source/materials/processedMaterial.cpp

@@ -405,35 +405,35 @@ void ProcessedMaterial::_setStageData()
          }
       }
       // OverlayMap
-      if (mMaterial->getOverlayMap(i) != StringTable->EmptyString())
+      if (mMaterial->getOverlayMapAsset(i).notNull())
       {
-         mStages[i].setTex(MFT_OverlayMap, mMaterial->getOverlayMapResource(i));
+         mStages[i].setTex(MFT_OverlayMap, mMaterial->getOverlayMap(i));
          if (!mStages[i].getTex(MFT_OverlayMap))
-            mMaterial->logError("Failed to load overlay map %s for stage %i", mMaterial->getOverlayMap(i), i);
+            mMaterial->logError("Failed to load overlay map %s for stage %i", mMaterial->_getOverlayMap(i), i);
       }
 
       // LightMap
-      if (mMaterial->getLightMap(i) != StringTable->EmptyString())
+      if (mMaterial->getLightMapAsset(i).notNull())
       {
-         mStages[i].setTex(MFT_LightMap, mMaterial->getLightMapResource(i));
+         mStages[i].setTex(MFT_LightMap, mMaterial->getLightMap(i));
          if (!mStages[i].getTex(MFT_LightMap))
-            mMaterial->logError("Failed to load light map %s for stage %i", mMaterial->getLightMap(i), i);
+            mMaterial->logError("Failed to load light map %s for stage %i", mMaterial->_getLightMap(i), i);
       }
 
       // ToneMap
-      if (mMaterial->getToneMap(i) != StringTable->EmptyString())
+      if (mMaterial->getToneMapAsset(i).notNull())
       {
-         mStages[i].setTex(MFT_ToneMap, mMaterial->getToneMapResource(i));
+         mStages[i].setTex(MFT_ToneMap, mMaterial->getToneMap(i));
          if (!mStages[i].getTex(MFT_ToneMap))
-            mMaterial->logError("Failed to load tone map %s for stage %i", mMaterial->getToneMap(i), i);
+            mMaterial->logError("Failed to load tone map %s for stage %i", mMaterial->_getToneMap(i), i);
       }
 
       // DetailMap
-      if (mMaterial->getDetailMap(i) != StringTable->EmptyString())
+      if (mMaterial->getDetailMapAsset(i).notNull())
       {
-         mStages[i].setTex(MFT_DetailMap, mMaterial->getDetailMapResource(i));
+         mStages[i].setTex(MFT_DetailMap, mMaterial->getDetailMap(i));
          if (!mStages[i].getTex(MFT_DetailMap))
-            mMaterial->logError("Failed to load detail map %s for stage %i", mMaterial->getDetailMap(i), i);
+            mMaterial->logError("Failed to load detail map %s for stage %i", mMaterial->_getDetailMap(i), i);
       }
 
       // NormalMap
@@ -453,7 +453,7 @@ void ProcessedMaterial::_setStageData()
       {
          mStages[i].setTex(MFT_DetailNormalMap, mMaterial->getDetailNormalMap(i));
          if (!mStages[i].getTex(MFT_DetailNormalMap))
-            mMaterial->logError("Failed to load normal map %s for stage %i", mMaterial->getDetailNormalMapAsset(i), i);
+            mMaterial->logError("Failed to load normal map %s for stage %i", mMaterial->_getDetailNormalMap(i), i);
       }
 
       //depending on creation method this may or may not have been shoved into srgb space eroneously
@@ -462,11 +462,11 @@ void ProcessedMaterial::_setStageData()
          profile = &GFXStaticTextureSRGBProfile;
 
       // ORMConfig
-      if (mMaterial->getORMConfigMap(i) != StringTable->EmptyString())
+      if (mMaterial->getORMConfigMapAsset(i).notNull())
       {
-         mStages[i].setTex(MFT_OrmMap, _createTexture(mMaterial->getORMConfigMap(i), profile));
+         mStages[i].setTex(MFT_OrmMap, mMaterial->getORMConfigMap(profile, i));
          if (!mStages[i].getTex(MFT_OrmMap))
-            mMaterial->logError("Failed to load PBR Config map %s for stage %i", mMaterial->getORMConfigMap(i), i);
+            mMaterial->logError("Failed to load PBR Config map %s for stage %i", mMaterial->_getORMConfigMap(i), i);
       }
       else
       {