Browse Source

Merge remote-tracking branch 'main/Preview4_0' into adjustment-unix-platform

Robert MacGregor 3 years ago
parent
commit
b986589804
33 changed files with 364 additions and 479 deletions
  1. 14 1
      Engine/source/T3D/assets/ImageAsset.cpp
  2. 74 7
      Engine/source/T3D/assets/assetImporter.cpp
  3. 8 2
      Engine/source/T3D/assets/assetImporter.h
  4. 7 3
      Engine/source/console/astNodes.cpp
  5. 3 3
      Engine/source/console/codeBlock.cpp
  6. 2 1
      Engine/source/console/compiledEval.cpp
  7. 43 4
      Engine/source/console/compiler.cpp
  8. 2 0
      Engine/source/console/compiler.h
  9. 3 1
      Engine/source/console/console.cpp
  10. 1 1
      Engine/source/postFx/postEffect.cpp
  11. 1 1
      Engine/source/renderInstance/renderProbeMgr.cpp
  12. 1 1
      Engine/source/ts/assimp/assimpShapeLoader.cpp
  13. 2 3
      Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl
  14. 4 6
      Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl
  15. 2 3
      Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl
  16. 1 2
      Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl
  17. 10 0
      Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript
  18. 7 5
      Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml
  19. 47 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript
  20. 12 3
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript
  21. 2 2
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript
  22. 2 2
      Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.tscript
  23. 5 5
      Templates/BaseGame/game/tools/convexEditor/convexEditorGui.tscript
  24. 11 22
      Templates/BaseGame/game/tools/decalEditor/decalEditorGui.tscript
  25. 7 6
      Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript
  26. 2 1
      Templates/BaseGame/game/tools/gui/uvEditor.ed.gui
  27. 63 148
      Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript
  28. 8 18
      Templates/BaseGame/game/tools/particleEditor/particleParticleEditor.ed.tscript
  29. 1 1
      Templates/BaseGame/game/tools/settings.xml
  30. 0 2
      Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript
  31. 0 142
      Templates/BaseGame/game/tools/worldEditor/scripts/editorSettingsWindow.ed.tscript
  32. 2 2
      Templates/BaseGame/game/tools/worldEditor/scripts/editors/terrainEditor.ed.tscript
  33. 17 81
      Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript

+ 14 - 1
Engine/source/T3D/assets/ImageAsset.cpp

@@ -549,7 +549,20 @@ bool GuiInspectorTypeImageAssetPtr::renderTooltip(const Point2I& hoverPos, const
    if (!filename || !filename[0])
       return false;
 
-   GFXTexHandle texture(filename, &GFXStaticTextureSRGBProfile, avar("%s() - tooltip texture (line %d)", __FUNCTION__, __LINE__));
+   StringTableEntry previewFilename = filename;
+   if (Con::isFunction("getAssetPreviewImage"))
+   {
+      ConsoleValue consoleRet = Con::executef("getAssetPreviewImage", filename);
+      previewFilename = StringTable->insert(consoleRet.getString());
+
+      if (AssetDatabase.isDeclaredAsset(previewFilename))
+      {
+         ImageAsset* previewAsset = AssetDatabase.acquireAsset<ImageAsset>(previewFilename);
+         previewFilename = previewAsset->getImagePath();
+      }
+   }
+
+   GFXTexHandle texture(previewFilename, &GFXStaticTextureSRGBProfile, avar("%s() - tooltip texture (line %d)", __FUNCTION__, __LINE__));
    if (texture.isNull())
       return false;
 

+ 74 - 7
Engine/source/T3D/assets/assetImporter.cpp

@@ -1158,12 +1158,76 @@ static bool enumColladaForImport(const char* shapePath, GuiTreeViewCtrl* tree, b
       {
          domImage* img = libraryImages->getImage_array()[j];
 
-         S32 materialID = tree->findItemByName(_GetNameOrId(img));
+         String imageName = _GetNameOrId(img);
+
+         S32 materialID = tree->findItemByName(imageName.c_str());
 
          if (materialID == 0)
-            continue;
+         {
+            bool materialFound = false;
+            String matName = "";
+
+            //If we don't have an immediate name match, we'll have to actually go look it up
+            for (S32 e = 0; e < root->getLibrary_effects_array().getCount(); e++)
+            {
+               const domLibrary_effects* libraryEffects = root->getLibrary_effects_array()[e];
+
+               for (S32 f = 0; f < libraryEffects->getEffect_array().getCount(); f++)
+               {
+                  domEffect* efct = libraryEffects->getEffect_array()[f];
+
+                  String effectName = efct->getID();
+
+                  for (S32 p = 0; p < efct->getFx_profile_abstract_array().getCount(); p++)
+                  {
+                     domProfile_COMMON* profile = daeSafeCast<domProfile_COMMON>(efct->getFx_profile_abstract_array()[p]);
+
+                     for (S32 n = 0; n < profile->getNewparam_array().getCount(); n++)
+                     {
+                        domCommon_newparam_typeRef param = profile->getNewparam_array()[n];
+                        String paramName = param->getSid();
+                        if (paramName.endsWith("-surface"))
+                        {
+                           //ok it's surface data, parse out the name
+                           String surfaceName = paramName.substr(0, paramName.length() - 8);
+                           if (surfaceName == imageName)
+                           {
+                              //got a match!
+                              matName = effectName;
+                              if (matName.endsWith("-effect"))
+                              {
+                                 matName = matName.substr(0, matName.length() - 7);
+                                 materialFound = true;
+                                 break;
+                              }
+                           }
+                        }
+                     }
 
-         tree->setItemValue(materialID, img->getInit_from()->getValue().str().c_str());
+                     if (materialFound)
+                        break;
+                  }
+
+                  if (materialFound)
+                  {
+                     materialID = tree->findItemByName(matName.c_str());
+                  }
+
+                  if (materialID != 0)
+                     break;
+               }
+            }
+
+            //if we STILL haven't found a match, then yes, we've failed
+            if (materialID == 0)
+               continue;
+         }
+
+         String imagePath = img->getInit_from()->getValue().str().c_str();
+         if (imagePath.startsWith("/"))
+            imagePath = imagePath.substr(1, imagePath.length() - 1);
+
+         tree->setItemValue(materialID, StringTable->insert(imagePath.c_str()));
       }
    }
 
@@ -2317,6 +2381,9 @@ void AssetImporter::resetImportConfig()
       Settings* importConfigs;
       if (Sim::findObject("AssetImportSettings", importConfigs))
       {
+         dSprintf(importLogBuffer, sizeof(importLogBuffer), "Loading import config: %s!", defaultImportConfig.c_str());
+         activityLog.push_back(importLogBuffer);
+
          //Now load the editor setting-deigned config!
          activeImportConfig->loadImportConfig(importConfigs, defaultImportConfig.c_str());
       }
@@ -2734,7 +2801,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
                }
                else if (imageType == ImageAsset::ImageTypes::Metalness)
                {
-                  mapFieldName = "MetalnessMap";
+                  mapFieldName = "MetalMap";
                }
                else if (imageType == ImageAsset::ImageTypes::AO)
                {
@@ -2742,7 +2809,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
                }
                else if (imageType == ImageAsset::ImageTypes::Roughness)
                {
-                  mapFieldName = "RoughnessMap";
+                  mapFieldName = "RoughMap";
                }
 
                assetFieldName = mapFieldName + "Asset[0]";
@@ -2810,7 +2877,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
          }
          else if (imageType == ImageAsset::ImageTypes::Metalness)
          {
-            mapFieldName = "MetalnessMap";
+            mapFieldName = "MetalMap";
          }
          else if (imageType == ImageAsset::ImageTypes::AO)
          {
@@ -2818,7 +2885,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
          }
          else if (imageType == ImageAsset::ImageTypes::Roughness)
          {
-            mapFieldName = "RoughnessMap";
+            mapFieldName = "RoughMap";
             hasRoughness = true;
          }
 

+ 8 - 2
Engine/source/T3D/assets/assetImporter.h

@@ -905,9 +905,15 @@ public:
    /// </summary>
    AssetImportConfig* getImportConfig() { return activeImportConfig; }
 
-   void setImportConfig(AssetImportConfig* importConfig) {
-      if(importConfig != nullptr)
+   void setImportConfig(AssetImportConfig* importConfig)
+   {
+      if (importConfig != nullptr)
+      {
+         dSprintf(importLogBuffer, sizeof(importLogBuffer), "Loading import config: %s!", importConfig->getName());
+         activityLog.push_back(importLogBuffer);
+
          activeImportConfig = importConfig;
+      }
    }
 
    /// <summary>

+ 7 - 3
Engine/source/console/astNodes.cpp

@@ -57,11 +57,16 @@ namespace Compiler
 using namespace Compiler;
 
 FuncVars gEvalFuncVars;
+FuncVars gGlobalScopeFuncVars;
 FuncVars* gFuncVars = NULL;
 
 inline FuncVars* getFuncVars(S32 lineNumber)
 {
-   AssertISV(gFuncVars, avar("Attemping to use local variable in global scope. File: %s Line: %d", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
+   if (gFuncVars == &gGlobalScopeFuncVars)
+   {
+      const char* str = avar("Attemping to use local variable in global scope. File: %s Line: %d", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber);
+      scriptErrorHandler(str);
+   }
    return gFuncVars;
 }
 
@@ -1552,8 +1557,7 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
       tbl->add(fnName, nameSpace, varName);
    }
 
-   // In eval mode, global func vars are allowed.
-   gFuncVars = gIsEvalCompile ? &gEvalFuncVars : NULL;
+   gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars;
 
    return ip;
 }

+ 3 - 3
Engine/source/console/codeBlock.cpp

@@ -38,6 +38,7 @@ CodeBlock *    CodeBlock::smCurrentCodeBlock = NULL;
 ConsoleParser *CodeBlock::smCurrentParser = NULL;
 
 extern FuncVars gEvalFuncVars;
+extern FuncVars gGlobalScopeFuncVars;
 extern FuncVars* gFuncVars;
 
 //-------------------------------------------------------------------------
@@ -637,8 +638,7 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
    
    // we are an eval compile if we don't have a file name associated (no exec)
    gIsEvalCompile = fileName == NULL;
-   // In eval mode, global func vars are allowed.
-   gFuncVars = gIsEvalCompile ? &gEvalFuncVars : NULL;
+   gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars;
 
    // Set up the parser.
    smCurrentParser = getParserForFile(fileName);
@@ -678,7 +678,7 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
    codeStream.emit(OP_RETURN_VOID);
    codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
    
-   S32 localRegisterCount = gIsEvalCompile ? gEvalFuncVars.count() : 0;
+   S32 localRegisterCount = gIsEvalCompile ? gEvalFuncVars.count() : gGlobalScopeFuncVars.count();
 
    consoleAllocReset();
 

+ 2 - 1
Engine/source/console/compiledEval.cpp

@@ -691,7 +691,8 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
          setFrame = -1;
 
       // Do we want this code to execute using a new stack frame?
-      if (setFrame < 0)
+      // compiling a file will force setFrame to 0, forcing us to get a new frame.
+      if (setFrame <= 0)
       {
          // argc is the local count for eval
          gEvalState.pushFrame(NULL, NULL, argc);

+ 43 - 4
Engine/source/console/compiler.cpp

@@ -35,6 +35,13 @@
 #include "console/simBase.h"
 
 extern FuncVars gEvalFuncVars;
+extern FuncVars gGlobalScopeFuncVars;
+extern FuncVars *gFuncVars;
+
+namespace Con
+{
+extern bool scriptWarningsAsAsserts;
+};
 
 namespace Compiler
 {
@@ -124,12 +131,24 @@ namespace Compiler
       getFunctionStringTable().reset();
       getIdentTable().reset();
       getFunctionVariableMappingTable().reset();
-      gEvalFuncVars.clear();
+      gGlobalScopeFuncVars.clear();
+      gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars;
    }
 
    void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }
    void consoleAllocReset() { gConsoleAllocator.freeBlocks(); }
 
+   void scriptErrorHandler(const char* str)
+   {
+      if (Con::scriptWarningsAsAsserts)
+      {
+         AssertISV(false, str);
+      }
+      else
+      {
+         Con::warnf(ConsoleLogEntry::Type::Script, "%s", str);
+      }
+   }
 }
 
 //-------------------------------------------------------------------------
@@ -141,7 +160,11 @@ S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber,
    std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
    if (found != vars.end())
    {
-      AssertISV(!found->second.isConstant, avar("Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
+      if (found->second.isConstant)
+      {
+         const char* str = avar("Script Warning: Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber);
+         scriptErrorHandler(str);
+      }
       return found->second.reg;
    }
 
@@ -155,7 +178,15 @@ S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber,
 S32 FuncVars::lookup(StringTableEntry var, S32 lineNumber)
 {
    std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
-   AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
+   
+   if (found == vars.end())
+   {
+      const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber);
+      scriptErrorHandler(str);
+      
+      return assign(var, TypeReqString, lineNumber, false);
+   }
+   
    return found->second.reg;
 }
 
@@ -163,7 +194,15 @@ TypeReq FuncVars::lookupType(StringTableEntry var, S32 lineNumber)
 {
    std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
 
-   AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
+   if (found == vars.end())
+   {
+      const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber);
+      scriptErrorHandler(str);
+      
+      assign(var, TypeReqString, lineNumber, false);
+      return vars.find(var)->second.currentType;
+   }
+   
    return found->second.currentType;
 }
 

+ 2 - 0
Engine/source/console/compiler.h

@@ -275,6 +275,8 @@ namespace Compiler
    void *consoleAlloc(U32 size);
    void consoleAllocReset();
 
+   void scriptErrorHandler(const char* str);
+
    extern bool gSyntaxError;
    extern bool gIsEvalCompile;
 };

+ 3 - 1
Engine/source/console/console.cpp

@@ -274,6 +274,7 @@ static Vector< String > sInstantGroupStack( __FILE__, __LINE__ );
 static DataChunker consoleLogChunker;
 static Vector<ConsoleLogEntry> consoleLog(__FILE__, __LINE__);
 static bool consoleLogLocked;
+bool scriptWarningsAsAsserts = true;
 static bool logBufferEnabled=true;
 static S32 printLevel = 10;
 static FileStream consoleLogFile;
@@ -353,7 +354,7 @@ void init()
    ConsoleConstructor::setup();
 
    // Set up the parser(s)
-   CON_ADD_PARSER(CMD, TORQUE_SCRIPT_EXTENSION,   true);   // TorqueScript
+   CON_ADD_PARSER(CMD, (char*)TORQUE_SCRIPT_EXTENSION, true);   // TorqueScript
 
    // Setup the console types.
    ConsoleBaseType::initialize();
@@ -377,6 +378,7 @@ void init()
    addVariable("Con::objectCopyFailures", TypeS32, &gObjectCopyFailures, "If greater than zero then it counts the number of object creation "
       "failures based on a missing copy object and does not report an error..\n"
       "@ingroup Console\n");
+   addVariable("Con::scriptWarningsAsAsserts", TypeBool, &scriptWarningsAsAsserts, "If true, script warnings (outside of syntax errors) will be treated as fatal asserts.");
 
    // Current script file name and root
    addVariable( "Con::File", TypeString, &gCurrentFile, "The currently executing script file.\n"

+ 1 - 1
Engine/source/postFx/postEffect.cpp

@@ -1644,7 +1644,7 @@ void PostEffect::setTexture( U32 index, const String &texFilePath )
 void PostEffect::setTexture(U32 index, const GFXTexHandle& texHandle)
 {
    // Set the new texture name.
-   mTextureName[index] = "";
+   mTextureName[index] = StringTable->EmptyString();
    mTexture[index].free();
 
    // Skip empty stages or ones with variable or target names.

+ 1 - 1
Engine/source/renderInstance/renderProbeMgr.cpp

@@ -290,7 +290,7 @@ bool RenderProbeMgr::onAdd()
    }
 
    String brdfTexturePath = GFXTextureManager::getBRDFTexturePath();
-   if (!mBRDFTexture.set(brdfTexturePath, &GFXTexturePersistentSRGBProfile, "BRDFTexture"))
+   if (!mBRDFTexture.set(brdfTexturePath, &GFXTexturePersistentProfile, "BRDFTexture"))
    {
       Con::errorf("RenderProbeMgr::onAdd: Failed to load BRDF Texture");
       return false;

+ 1 - 1
Engine/source/ts/assimp/assimpShapeLoader.cpp

@@ -179,7 +179,7 @@ void AssimpShapeLoader::enumerateScene()
       String importFormat;
 
       const aiImporterDesc* importerDescription = aiGetImporterDesc(shapePath.getExtension().c_str());
-      if (importerDescription->mName == "Autodesk FBX Importer")
+      if (StringTable->insert(importerDescription->mName) == StringTable->insert("Autodesk FBX Importer"))
       {
          ColladaUtils::getOptions().formatScaleFactor = 0.01f;
       }

+ 2 - 3
Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl

@@ -106,7 +106,7 @@ struct Surface
 
 void updateSurface(inout Surface surface)
 {
-	surface.NdotV = abs(dot(surface.N, surface.V)) + 1e-5f; // avoid artifact
+	surface.NdotV = clamp( dot(surface.N, surface.V), 0.0009765625f,0.9990234375f);  //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
 
     surface.linearRoughness = surface.roughness * surface.roughness;
     surface.linearRoughnessSq = surface.linearRoughness * surface.linearRoughness;
@@ -650,8 +650,7 @@ vec4 debugVizForwardProbes(Surface surface,
    vec3 kD = 1.0f - F;
    kD *= 1.0f - surface.metalness;
 
-   float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
-   vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
+   vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
    specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
    irradiance *= kD * surface.baseColor.rgb;
 

+ 4 - 6
Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl

@@ -105,10 +105,9 @@ struct Surface
 
 	inline void Update()
 	{
-		NdotV = abs(dot(N, V)) + 1e-5f; // avoid artifact
-   
-      linearRoughness = roughness * roughness;
-      linearRoughnessSq = linearRoughness * linearRoughness;
+		NdotV = clamp( dot(N, V), 0.0009765625f,0.9990234375f); // avoid artifact
+        linearRoughness = roughness * roughness;
+        linearRoughnessSq = linearRoughness * linearRoughness;
 
 		albedo = baseColor.rgb * (1.0f - metalness);
 		f0 = lerp(0.04f, baseColor.rgb, metalness);
@@ -654,8 +653,7 @@ float4 debugVizForwardProbes(Surface surface,
    float3 kD = 1.0f - F;
    kD *= 1.0f - surface.metalness;
 
-   float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
-   float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
+   float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
    specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
    irradiance *= kD * surface.baseColor.rgb;
 

+ 2 - 3
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl

@@ -202,14 +202,13 @@ void main()
    return;
 #endif
 
-
+   
    //energy conservation
    vec3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
    vec3 kD = 1.0f - F;
    kD *= 1.0f - surface.metalness;
 
-   float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
-   vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
+   vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
    specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
    irradiance *= kD * surface.baseColor.rgb;
 

+ 1 - 2
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl

@@ -197,8 +197,7 @@ float4 main(PFXVertToPix IN) : SV_TARGET
    float3 kD = 1.0f - F;
    kD *= 1.0f - surface.metalness;
 
-   float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
-   float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
+   float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
    specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
    irradiance *= kD * surface.baseColor.rgb;
 

+ 10 - 0
Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript

@@ -642,4 +642,14 @@ function populateAllFonts(%font)
    populateFontCacheRange(%font,24,0,65535);
    populateFontCacheRange(%font,32,0,65535);
    populateFontCacheRange(%font,36,0,65535);
+}
+
+//------------------------------------------------------------------------------
+function playSoundAsset(%soundAssetId)
+{
+   %assetDef = AssetDatabase.acquireAsset(%soundAssetId);
+   if(isObject(%assetDef))
+      %assetDef.playSound();
+   
+   AssetDatabase.releaseAsset(%soundAssetId);
 }

+ 7 - 5
Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml

@@ -26,18 +26,18 @@
             <Setting name="AddedImageSuffix">_image</Setting>
             <Setting name="AlwaysAddImageSuffix">1</Setting>
             <Setting name="AOTypeSuffixes">_AO,_AMBIENT,_AMBIENTOCCLUSION</Setting>
-            <Setting name="CompositeTypeSuffixes">_COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM</Setting>
+            <Setting name="CompositeTypeSuffixes">_COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM,_C</Setting>
             <Setting name="Compressed">1</Setting>
             <Setting name="DiffuseTypeSuffixes">_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL</Setting>
             <Setting name="GenerateMaterialOnImport">0</Setting>
             <Setting name="ImageType">N/A</Setting>
             <Setting name="ImportImages">1</Setting>
             <Setting name="IsHDR">0</Setting>
-            <Setting name="MetalnessTypeSuffixes">_METAL,_MET,_METALNESS,_METALLIC</Setting>
-            <Setting name="NormalTypeSuffixes">_NORMAL,_NORM</Setting>
-            <Setting name="RoughnessTypeSuffixes">_ROUGH,_ROUGHNESS</Setting>
+            <Setting name="MetalnessTypeSuffixes">_METAL,_MET,_METALNESS,_METALLIC,_M</Setting>
+            <Setting name="NormalTypeSuffixes">_NORMAL,_NORM,_N</Setting>
+            <Setting name="RoughnessTypeSuffixes">_ROUGH,_ROUGHNESS,_R</Setting>
             <Setting name="Scaling">1.0</Setting>
-            <Setting name="SmoothnessTypeSuffixes">_SMOOTH,_SMOOTHNESS</Setting>
+            <Setting name="SmoothnessTypeSuffixes">_SMOOTH,_SMOOTHNESS,_S</Setting>
             <Setting name="TextureFilteringMode">Bilinear</Setting>
             <Setting name="UseMips">1</Setting>
         </Group>
@@ -45,6 +45,8 @@
             <Setting name="AddedMaterialSuffix">_mat</Setting>
             <Setting name="AlwaysAddMaterialSuffix">0</Setting>
             <Setting name="CreateComposites">1</Setting>
+            <Setting name="CreateORMConfig">1</Setting>
+            <Setting name="IgnoreMaterials">DefaultMaterial</Setting>
             <Setting name="ImportMaterials">1</Setting>
             <Setting name="PopulateMaterialMaps">1</Setting>
             <Setting name="UseDiffuseSuffixOnOriginImage">1</Setting>

+ 47 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript

@@ -2488,3 +2488,50 @@ function AssetBrowser::importLooseFiles(%this)
    echo("Adding loose files at directory " @ %this.dirHandler.currentAddress);
    LooseFileAuditWindow.showDialog(%this.dirHandler.currentAddress);  
 }
+
+//
+function getAssetPreviewImage(%asset)
+{
+   if(isFile(%asset))
+   {
+      %aq = new AssetQuery();
+      %assetsFound = AssetDatabase.findAssetLooseFile(%aq, %asset);
+      if(%assetsFound != 0)
+      {
+         %asset = %aq.getAsset(0);
+      }
+      else
+      {
+         %previewPath = %asset;
+      }
+      
+      %aq.delete();
+   }
+   
+   if(AssetDatabase.isDeclaredAsset(%asset))
+   {
+      %moduleName = AssetDatabase.getAssetModule(%asset).ModuleId;
+      %assetName = AssetDatabase.getAssetName(%asset);
+      %previewAssetName = "ToolsModule:" @ %moduleName @ "_" @ %assetName @ "_PreviewImage";
+      
+      if(AssetDatabase.isDeclaredAsset(%previewAssetName))
+      {
+         %previewDef = AssetDatabase.acquireAsset(%previewAssetName);  
+         %previewPath = %previewDef.getImagePath();
+         AssetDatabase.releaseAsset(%previewAssetName);
+      }
+      else
+      {
+         %previewPath = %asset;  
+      }
+   }
+   else
+   {
+      %previewPath = %asset;
+   }
+   
+   if(%previewPath $= "")
+      %previewPath = "ToolsModule:unknownImage_image";
+   
+   return %previewPath;
+}

+ 12 - 3
Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript

@@ -86,6 +86,8 @@ function ImportAssetWindow::onWake(%this)
    %this.importer.targetModuleId = AssetImportTargetModule.getText();
    
    %this.refresh();
+   
+   toggleImportWindowVizBtn.setStateOn(EditorSettings.value("Assets/AutoImport"));
 }
 
 //
@@ -469,9 +471,7 @@ function ImportAssetWindow::doRefresh(%this)
    ImportAssetWindow.importer.processImportingAssets();
    //%this.processImportAssets();
    
-   //ImportAssetWindow.hasImportIssues = %this.validateAssets();
-   
-   ImportAssetWindow.importer.validateImportingAssets();
+   ImportAssetWindow.hasImportIssues = ImportAssetWindow.importer.hasImportIssues();
    
    AssetImportCtrl-->NewAssetsTree.clear();
    AssetImportCtrl-->NewAssetsTree.insertItem(0, "Importing Assets");
@@ -947,3 +947,12 @@ function ImportAssetModuleList::refresh(%this)
    }
 }
 //
+
+//
+function toggleImportWindowViz()
+{
+   %value = EditorSettings.value("Assets/AutoImport");
+   EditorSettings.setValue("Assets/AutoImport", !%value);
+  
+}
+//

+ 2 - 2
Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript

@@ -66,7 +66,7 @@ function setupImportConfigSettingsList()
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/ImportMaterials", "Import Materials", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/AlwaysAddMaterialSuffix", "Always Add Material Suffix", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/AddedMaterialSuffix", "Added Material Suffix", "string", "", "_mat", "");
-      ImportAssetConfigSettingsList.addNewConfigSetting("Materials/CreateComposites", "Create Composites", "bool", "", "1", "");
+      ImportAssetConfigSettingsList.addNewConfigSetting("Materials/CreateORMConfig", "Create ORM Map", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseDiffuseSuffixOnOriginImage", "Use Diffuse Suffix for Origin Image", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/IgnoreMaterials", "Ignore Materials", "command", "", "", "");
@@ -185,7 +185,7 @@ function ImportAssetOptionsWindow::editImportSettings(%this, %assetItem)
    else if(%assetType $= "MaterialAsset")
    {
       ImportOptionsList.startGroup("Material");
-      ImportOptionsList.addField("CreateComposites", "Create Composite Textures", "bool", "", "1", "", %assetConfigObj);
+      ImportOptionsList.addField("CreateORMConfig", "Create ORM Map", "bool", "", "1", "", %assetConfigObj);
       ImportOptionsList.endGroup();
    }
    else if(%assetType $= "ImageAsset")

+ 2 - 2
Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.tscript

@@ -25,7 +25,7 @@ function AssetBrowser::buildPopupMenus(%this)
 
          item[ 0 ] = "Edit Asset" TAB "" TAB "AssetBrowser.editAsset();";
          item[ 1 ] = "Rename Asset" TAB "" TAB "AssetBrowser.renameAsset();";
-         item[ 2 ] = "Refresh Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
+         item[ 2 ] = "Reload Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
          item[ 3 ] = "Asset Properties" TAB "" TAB "AssetBrowser.editAssetInfo();";
          item[ 4 ] = "-";
          Item[ 5 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";
@@ -50,7 +50,7 @@ function AssetBrowser::buildPopupMenus(%this)
          item[ 0 ] = "Edit Level" TAB "" TAB "AssetBrowser.editAsset();";
          item[ 1 ] = "Append as Sublevel" TAB "" TAB "AssetBrowser.appendSublevel();";
          item[ 2 ] = "Rename Asset" TAB "" TAB "AssetBrowser.renameAsset();";
-         item[ 3 ] = "Refresh Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
+         item[ 3 ] = "Reload Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
          item[ 4 ] = "Asset Properties" TAB "" TAB "AssetBrowser.editAssetInfo();";
          item[ 5 ] = "-";
          Item[ 6 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";

+ 5 - 5
Templates/BaseGame/game/tools/convexEditor/convexEditorGui.tscript

@@ -38,7 +38,7 @@ function ConvexEditorGui::onWake( %this )
 		   %mat = %matName;
 		}
 		
-		ConvexEditorOptionsWindow-->matPreviewBtn.setBitmap(%mat.getDiffuseMap(0));
+		ConvexEditorOptionsWindow-->matPreviewBtn.setBitmap( getAssetPreviewImage(%mat.getDiffuseMap(0)));
 		
 		ConvexEditorOptionsWindow.activeMaterial = %mat;
 	}
@@ -76,7 +76,7 @@ function ConvexEditorGui::onSelectionChanged( %this, %shape, %face )
 
    ConvexEditorOptionsWindow-->defMatPreviewBtn.setText("");
    %shapeMat = %shape.getMaterial();
-   ConvexEditorOptionsWindow-->defMatPreviewBtn.setBitmap(%shapeMat.getDiffuseMap(0));
+   ConvexEditorOptionsWindow-->defMatPreviewBtn.setBitmap(getAssetPreviewImage(%shapeMat.getDiffuseMap(0)));
 
    ConvexEditorOptionsWindow.activeShape = %shape;
       
@@ -175,7 +175,7 @@ function ConvexEditorMaterialBtn::gotMaterialName(%this, %name)
       }
    }
 
-   ConvexEditorOptionsWindow-->matPreviewBtn.setBitmap(%diffusemap);
+   ConvexEditorOptionsWindow-->matPreviewBtn.setBitmap(getAssetPreviewImage(%diffusemap));
 
    ConvexEditorOptionsWindow.activeMaterial = %materialAsset.materialDefinitionName;
 }
@@ -191,7 +191,7 @@ function ConvexEditorMaterialLiftBtn::onClick(%this)
 {
    %mat = ConvexEditorGui.getSelectedFaceMaterial();
    ConvexEditorOptionsWindow.activeMaterial = %mat;
-   ConvexEditorOptionsWindow-->matPreviewBtn.setBitmap(%mat.getDiffuseMap(0));
+   ConvexEditorOptionsWindow-->matPreviewBtn.setBitmap(getAssetPreviewImage(%mat.getDiffuseMap(0)));
 }
 
 function ConvexEditorMaterialResetBtn::onClick(%this)
@@ -240,7 +240,7 @@ function ConvexEditorDefaultMaterialBtn::gotMaterialName(%this, %name)
       }
    }
 
-   ConvexEditorOptionsWindow-->defMatPreviewBtn.setBitmap(%diffusemap);
+   ConvexEditorOptionsWindow-->defMatPreviewBtn.setBitmap(getAssetPreviewImage(%diffusemap));
 
    ConvexEditorOptionsWindow.activeShape.setMaterial(%name);
 

+ 11 - 22
Templates/BaseGame/game/tools/decalEditor/decalEditorGui.tscript

@@ -326,51 +326,40 @@ function DecalInspector::removeDirty()
 
 function DecalEditorGui::updateDecalPreview( %this, %material )
 {
+   %previewImage = "";
+   
    if( isObject( %material ) )
    {
-      DecalPreviewWindow-->decalPreview.setBitmap( %material.getDiffuseMap(0) );
+      %previewImage = %material.getDiffuseMap(0);
    }
    else
    {
       if(AssetDatabase.isDeclaredAsset(%material))
       {
-         %assetDef = AssetDatabase.acquireAsset(%material);
-         %difMap = %assetDef.materialDefinitionName.getDiffuseMap(0);
-         AssetDatabase.acquireAsset(%material);
-         
-         if(%difMap !$= "" && %difMap !$= "Core_Rendering:missingTexture")
-         {
-            DecalPreviewWindow-->decalPreview.setBitmap( %difMap );
-            return;
+         %previewImage = %material;
          }
       }
-      DecalPreviewWindow-->decalPreview.setBitmap("ToolsModule:unknownImage_image");
+   
+   DecalPreviewWindow-->decalPreview.setBitmap( getAssetPreviewImage(%previewImage) );
    }
-}
 
 function DecalEditorGui::updateInstancePreview( %this, %material )
 {
+   %previewImage = "";
+   
    if( isObject( %material ) )
    {
-      DecalPreviewWindow-->instancePreview.setBitmap( %material.getDiffuseMap(0) );      
+      %previewImage = %material.getDiffuseMap(0);
    }
    else
    {
       if(AssetDatabase.isDeclaredAsset(%material))
       {
-         %assetDef = AssetDatabase.acquireAsset(%material);
-         %difMap = %assetDef.materialDefinitionName.getDiffuseMap(0);
-         AssetDatabase.acquireAsset(%material);
-         
-         if(%difMap !$= "" && %difMap !$= "Core_Rendering:missingTexture")
-         {
-            DecalPreviewWindow-->instancePreview.setBitmap( %difMap );
-            return;
+         %previewImage = %material;
          }
       }
       
-      DecalPreviewWindow-->instancePreview.setBitmap("ToolsModule:unknownImage_image");   
-}
+   DecalPreviewWindow-->instancePreview.setBitmap( getAssetPreviewImage(%previewImage) ); 
 }
 
 function DecalEditorGui::rebuildInstanceTree( %this )

+ 7 - 6
Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript

@@ -53,26 +53,27 @@ function ESettingsWindow::onWake( %this )
 
 function ESettingsWindow::hideDialog( %this )
 {
-   %this.setVisible(false);
+   Canvas.popDialog(EditorSettingsWindow);
 }
 
 function ESettingsWindow::ToggleVisibility()
 {
-   if ( ESettingsWindow.visible )
+   if(ESettingsWindow.isAwake())
    {
-      ESettingsWindow.setVisible(false);
+      Canvas.popDialog(EditorSettingsWindow);
    }
    else
    {
-      ESettingsWindow.setVisible(true);
+      Canvas.pushDialog(EditorSettingsWindow); 
+      
       ESettingsWindow.selectWindow();
       ESettingsWindow.setCollapseGroup(false);
       
       ESettingsWindowList.clear();
-   }
    
    ESettingsWindowList.setSelectedById( 1 );
 }
+}
 
 function ESettingsWindow::toggleProjectSettings(%this)
 {
@@ -528,7 +529,7 @@ function ESettingsWindow::getAssetEditingSettings(%this)
    }
    
    SettingsInspector.startGroup("Assets Importing");
-   SettingsInspector.addField("Edit Asset Configs", "Edit Asset Import Configs", "button", "Open Asset Import Config Editor", "", "Canvas.pushDialog(AssetImportConfigEditor);");
+   SettingsInspector.addField("Edit Import Configs", "Edit Asset Import Configs", "button", "Open Asset Import Config Editor", "", "Canvas.pushDialog(AssetImportConfigEditor);");
    SettingsInspector.addSettingsField("Assets/AssetImporDefaultConfig", "Default Asset Import Config", "list", "", %formattedConfigList); 
    SettingsInspector.addSettingsField("Assets/AutoImport", "Automatically Import using default config", "bool", "If on, the asset importing process" @
                                                                                                                         "will attempt to automatically import any inbound assets"@

+ 2 - 1
Templates/BaseGame/game/tools/gui/uvEditor.ed.gui

@@ -512,7 +512,8 @@ function UVEditor::showDialog( %this, %applyCallback, %obj, %uv)
       else if( %material.cubemap.cubeFace[0] !$= "" )
          %previewImage = %material.cubemap.cubeFace[0];
          }
-   UVEditor-->bitmapPreview.setBitmap(%previewImage);
+   
+   UVEditor-->bitmapPreview.setBitmap(getAssetPreviewImage(%previewImage));
    
    // Set up the color popup
    %popup = UVEditor-->colorPopup;

+ 63 - 148
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript

@@ -804,174 +804,92 @@ function MaterialEditorGui::guiSync( %this, %material )
    %layer = MaterialEditorGui.currentLayer;
    
    //Diffuse
-   if((%material).getDiffuseMap(%layer) !$= "" && (%material).getDiffuseMapAsset(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      %difAsset = (%material).getDiffuseMapAsset(%layer);
-      MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( (%material).getDiffuseMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( (%material).getDiffuseMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %diffuseMap = (%material).getDiffuseMap(%layer);
+   %diffuseMapText = %diffuseMap !$= "" && %diffuseMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getDiffuseMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( %diffuseMapText );      
+   MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( getAssetPreviewImage(%diffuseMap) );
  
    //Normal
-   if((%material).getNormalMap(%layer) !$= "" && (%material).getNormalMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->normalMapNameText.setText( (%material).getNormalMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( (%material).getNormalMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->normalMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %normalMap = (%material).getNormalMap(%layer);
+   %normalMapText = %normalMap !$= "" && %normalMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getNormalMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->normalMapNameText.setText( %normalMapText );      
+   MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( getAssetPreviewImage(%normalMap) );
    
    //ORM Config
-   if((%material).getORMConfigMap(%layer) !$= "" && (%material).getORMConfigMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( (%material).getORMConfigMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( (%material).getORMConfigMap(%layer) );
-      //hide unused
-      MaterialEditorPropertiesWindow-->RoughnessTextEdit.setVisible(false);
-      MaterialEditorPropertiesWindow-->RoughnessSlider.setVisible(false);
-      MaterialEditorPropertiesWindow-->MetalnessTextEdit.setVisible(false);
-      MaterialEditorPropertiesWindow-->MetalnessSlider.setVisible(false);
-      
+   %ormMap = (%material).getNormalMap(%layer);
+   %hasOrmMap = (%ormMap !$= "" && %ormMap !$=$MaterialEditor::emptyMaterialImage);
+   %ormMapText = %hasOrmMap ? (%material).getNormalMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText(%ormMapText );      
+   MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( getAssetPreviewImage(%ormMap) );
+
+   //show or hide depending on if we have a map assigned here
+   MaterialEditorPropertiesWindow-->RoughnessTextEdit.setVisible(!%hasOrmMap);
+   MaterialEditorPropertiesWindow-->RoughnessSlider.setVisible(!%hasOrmMap);
+   MaterialEditorPropertiesWindow-->MetalnessTextEdit.setVisible(!%hasOrmMap);
+   MaterialEditorPropertiesWindow-->MetalnessSlider.setVisible(!%hasOrmMap);
+   
+   if(%hasOrmMap)
+   {
       MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]);
       MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setValue((%material).invertRoughness[%layer]);
-      //show used
-      MaterialEditorPropertiesWindow-->isSRGBCheckbox.setVisible(true);
-      MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setVisible(true);
-
    }
-   else
-   {
-      MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
       
-      MaterialEditorPropertiesWindow-->RoughnessTextEdit.setText((%material).Roughness[%layer]);
-      MaterialEditorPropertiesWindow-->RoughnessSlider.setValue((%material).Roughness[%layer]);
-      MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]);
-      MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]);   
-      //show used   
-      MaterialEditorPropertiesWindow-->RoughnessTextEdit.setVisible(true);
-      MaterialEditorPropertiesWindow-->RoughnessSlider.setVisible(true);
-      MaterialEditorPropertiesWindow-->MetalnessTextEdit.setVisible(true);
-      MaterialEditorPropertiesWindow-->MetalnessSlider.setVisible(true);
-      
-      //hide unused
-      MaterialEditorPropertiesWindow-->isSRGBCheckbox.setVisible(false);
-      MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setVisible(false);
-   }
+   MaterialEditorPropertiesWindow-->isSRGBCheckbox.setVisible(%hasOrmMap);
+   MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setVisible(%hasOrmMap);
    
    //AOMap
-   if((%material).getAOMap(%layer) !$= "" && (%material).getAOMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->aoMapNameText.setText( (%material).getAOMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( (%material).getAOMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->aoMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %aoMap = (%material).getAOMap(%layer);
+   %aoMapText = %aoMap !$= "" && %aoMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getAOMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->aoMapNameText.setText( %aoMapText );      
+   MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( getAssetPreviewImage(%aoMap) );
+   
    //RoughMap
-   if((%material).getRoughMap(%layer) !$= "" && (%material).getRoughMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->roughMapNameText.setText( (%material).getRoughMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( (%material).getRoughMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->roughMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %roughMap = (%material).getRoughMap(%layer);
+   %roughMapText = %roughMap !$= "" && %roughMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getRoughMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->roughMapNameText.setText( %roughMapText );      
+   MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( getAssetPreviewImage(%roughMap) );
    
    //MetalMap
-   if((%material).getMetalMap(%layer) !$= "" && (%material).getMetalMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->metalMapNameText.setText( (%material).getMetalMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( (%material).getMetalMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->metalMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %metalMap = (%material).getMetalMap(%layer);
+   %metalMapText = %metalMap !$= "" && %metalMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getMetalMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->metalMapNameText.setText( %metalMapText );      
+   MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( getAssetPreviewImage(%metalMap) );
    
    //GlowMap
-   if((%material).getGlowMap(%layer) !$= "" && (%material).getGlowMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->glowMapNameText.setText( (%material).getGlowMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( (%material).getGlowMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->glowMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %glowMap = (%material).getGlowMap(%layer);
+   %glowMapText = %glowMap !$= "" && %glowMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getGlowMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->glowMapNameText.setText( %glowMapText );      
+   MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( getAssetPreviewImage(%glowMap) );
       
    //Overlay
-   if((%material).getOverlayMap(%layer) !$= "" && (%material).getOverlayMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->overlayMapNameText.setText( (%material).getOverlayMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( (%material).getOverlayMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->overlayMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %overlayMap = (%material).getOverlayMap(%layer);
+   %overlayMapText = %overlayMap !$= "" && %overlayMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getOverlayMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->overlayMapNameText.setText( %overlayMapText );      
+   MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( getAssetPreviewImage(%overlayMap) );
    
    //Detail
-   if((%material).getDetailMap(%layer) !$= "" && (%material).getDetailMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->detailMapNameText.setText( (%material).getDetailMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( (%material).getDetailMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->detailMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %detailMap = (%material).getDetailMap(%layer);
+   %detailMapText = %detailMap !$= "" && %detailMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getDetailMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->detailMapNameText.setText( %detailMapText );      
+   MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( getAssetPreviewImage(%detailMap) );
    
    //Detail Normal
-   if((%material).getDetailNormalMap(%layer) !$= "" && (%material).getDetailNormalMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( (%material).getDetailNormalMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( (%material).getDetailNormalMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %detailNormalMap = (%material).getDetailNormalMap(%layer);
+   %detailNormalMapText = %detailNormalMap !$= "" && %detailNormalMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getDetailNormalMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( %detailNormalMapText );      
+   MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( getAssetPreviewImage(%detailNormalMap) );
    
    //Light
-   if((%material).getLightMap(%layer) !$= "" && (%material).getLightMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->lightMapNameText.setText( (%material).getLightMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( (%material).getLightMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->lightMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %lightMap = (%material).getLightMap(%layer);
+   %lightMapText = %lightMap !$= "" && %lightMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getLightMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->lightMapNameText.setText( %lightMapText );      
+   MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( getAssetPreviewImage(%lightMap) );
    
    //Tone
-   if((%material).getToneMap(%layer) !$= "" && (%material).getToneMap(%layer) !$= $MaterialEditor::emptyMaterialImage) 
-   {
-      MaterialEditorPropertiesWindow-->toneMapNameText.setText( (%material).getToneMapAsset(%layer) );      
-      MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( (%material).getToneMap(%layer) );
-   }
-   else
-   {
-      MaterialEditorPropertiesWindow-->toneMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
-   }
+   %toneMap = (%material).getToneMap(%layer);
+   %toneMapText = %toneMap !$= "" && %toneMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getToneMapAsset(%layer) : "None";
+   MaterialEditorPropertiesWindow-->toneMapNameText.setText( %toneMapText );      
+   MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( getAssetPreviewImage(%toneMap) );
    
    MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]);
    MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]);
@@ -1254,12 +1172,9 @@ function MaterialEditorGui::doUpdateTextureMap( %this, %assetId )
       %bitmapCtrl = MaterialEditorPropertiesWindow.findObjectByInternalName( %type @ "MapDisplayBitmap", true );
       %textCtrl = MaterialEditorPropertiesWindow.findObjectByInternalName( %type @ "MapNameText", true );
    
-      %assetDef = AssetDatabase.acquireAsset(%assetId);
-
-      %texture = %assetDef.getImagePath();
+      %texture = getAssetPreviewImage(%assetId);
    
-      //%texture = MaterialEditorGui.openFile("texture");
-      if( %texture !$= "" )
+      if( %texture !$= "" && %texture !$= $MaterialEditor::emptyMaterialImage)
       {         
          %bitmapCtrl.setBitmap(%texture);
       

+ 8 - 18
Templates/BaseGame/game/tools/particleEditor/particleParticleEditor.ed.tscript

@@ -57,24 +57,11 @@ function PE_ParticleEditor::guiSync( %this )
    %popup.sort();
    %popup.setSelected( %data );
          
-   %bitmap = %data.getTexture();//MaterialEditorGui.searchForTexture( %data.getName(), %data.getTexture() );
-   if( %bitmap !$= "" )
-   {
-      PE_ParticleEditor-->PEP_previewImage.setBitmap( %bitmap );
-      
-      %text = %data.getTextureAsset();
-      if(%text $= "")
-         %text = %bitmap;
-         
-      PE_ParticleEditor-->PEP_previewImageName.setText( %text );
-      PE_ParticleEditor-->PEP_previewImageName.tooltip = %bitmap;
-   }
-   else
-   {
-      PE_ParticleEditor-->PEP_previewImage.setBitmap( "" );
-      PE_ParticleEditor-->PEP_previewImageName.setText( "None" );
-      PE_ParticleEditor-->PEP_previewImageName.tooltip = "None";
-   }
+   %bitmap = %data.getTexture();
+   %bitmapText = %bitmap !$= "" && %bitmap !$= $MaterialEditor::emptyMaterialImage ? %data.getTextureAsset() : "None";
+   PE_ParticleEditor-->PEP_previewImageName.setText( %bitmapText );    
+   PE_ParticleEditor-->PEP_previewImageName.tooltip = %bitmapText;  
+   PE_ParticleEditor-->PEP_previewImage.setBitmap( getAssetPreviewImage(%bitmap) );
    
    PE_ParticleEditor-->PEP_inverseAlpha.setValue( %data.useInvAlpha );
    
@@ -396,6 +383,9 @@ function PE_ParticleEditor::loadNewParticle( %this, %particle )
    else
       %particle = PEP_ParticleSelector.getSelected();
       
+   if( !isObject( %particle ) )
+      return;
+      
    PE_ParticleEditor.currParticle = %particle;
    
    error("PE_ParticleEditor::loadNewParticle() - Loading particle: " @ %particle.getName());

+ 1 - 1
Templates/BaseGame/game/tools/settings.xml

@@ -35,7 +35,7 @@
         <Setting
             name="AssetImporDefaultConfig">DefaultImportConfig</Setting>
         <Setting
-            name="AutoImport">1</Setting>
+            name="AutoImport">0</Setting>
         <Group
             name="Browser">
             <Setting

+ 0 - 2
Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript

@@ -158,8 +158,6 @@ function EditorGui::init(%this)
    {
       exec("tools/gui/EditorSettingsWindow.ed.gui");
       exec("tools/gui/editorSettingsWindow.ed." @ $TorqueScriptFileExtension);
-      %this.add( ESettingsWindow );
-      ESettingsWindow.setVisible(false);
       
       // Start the standard settings tabs pages
       /*exec( "~/worldEditor/gui/GeneralSettingsTab.ed.gui" );

+ 0 - 142
Templates/BaseGame/game/tools/worldEditor/scripts/editorSettingsWindow.ed.tscript

@@ -1,142 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-function ESettingsWindow::startup( %this )
-{
-   ESettingsWindowTabBook.selectPage( 0 );
-   ESettingsWindowList.setSelectedById( 0 );
-}
-
-function ESettingsWindow::onWake( %this )
-{
-}
-
-function ESettingsWindow::hideDialog( %this )
-{
-   %this.setVisible(false);
-}
-
-function ESettingsWindow::ToggleVisibility()
-{
-   if ( ESettingsWindow.visible  )
-   {
-      ESettingsWindow.setVisible(false);
-   }
-   else
-   {
-      ESettingsWindow.setVisible(true);
-      ESettingsWindow.selectWindow();
-      ESettingsWindow.setCollapseGroup(false);
-   }
-}
-
-function ESettingsWindow::addTabPage( %this, %page )
-{
-   ESettingsWindowTabBook.add( %page );
-   ESettingsWindowList.addRow( ESettingsWindowTabBook.getSelectedPage(), %page.text );
-   ESettingsWindowList.sort(0);
-}
-
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowList::onSelect( %this, %id, %text )
-{
-   ESettingsWindowTabBook.selectPage( %id );
-}
-
-//-----------------------------------------------------------------------------
-// Standard settings GUI classes.  Editors may define their own methods of
-// working with settings and are not required to use these.
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowCheckbox::onWake( %this )
-{
-   %this.setStateOn( EditorSettings.value( %this.editorSettingsValue ));
-}
-
-function ESettingsWindowCheckbox::onClick( %this )
-{
-   EditorSettings.setValue( %this.editorSettingsValue, %this.getValue() );
-   eval(%this.editorSettingsRead);
-}
-
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowTextEdit::onWake( %this )
-{
-   %this.setText( EditorSettings.value( %this.editorSettingsValue ));
-}
-
-function ESettingsWindowTextEdit::onValidate( %this )
-{
-   EditorSettings.setValue( %this.editorSettingsValue, %this.getValue() );
-   eval(%this.editorSettingsRead);
-}
-
-function ESettingsWindowTextEdit::onGainFirstResponder( %this )
-{
-   %this.selectAllText();
-}
-
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowColor::apply( %this, %color )
-{
-   EditorSettings.setValue( %this.editorSettingsValue, %color );
-   eval(%this.editorSettingsRead);
-
-   %this.findObjectByInternalName("ColorEdit", true).setText( %color);
-   %this.findObjectByInternalName("ColorButton", true).color = ColorIntToFloat( %color );
-}
-
-function ESettingsWindowColorEdit::onWake( %this )
-{
-   %this.setText( EditorSettings.value( %this.getParent().editorSettingsValue ));
-}
-
-function ESettingsWindowColorEdit::onValidate( %this )
-{
-   %this.getParent().apply( %this.getValue() );
-}
-
-function ESettingsWindowColorEdit::onGainFirstResponder( %this )
-{
-   %this.selectAllText();
-}
-
-function ESettingsWindowColorButton::onWake( %this )
-{
-   %this.color = ColorIntToFloat( EditorSettings.value( %this.getParent().editorSettingsValue ) );
-}
-
-function ESettingsWindowColorButton::onClick( %this )
-{
-   getColorI( ColorFloatToInt( %this.color ), %this.getId() @ ".apply", %this.getRoot() );
-   //EditorSettings.setValue( %this.editorSettingsValue, %this.getValue() );
-   //eval(%this.editorSettingsRead);
-}
-
-function ESettingsWindowColorButton::apply( %this, %color )
-{
-   %this.getParent().apply(%color);
-   echo("ESettingsWindowColorButton::apply(): " @ %color);
-}

+ 2 - 2
Templates/BaseGame/game/tools/worldEditor/scripts/editors/terrainEditor.ed.tscript

@@ -62,7 +62,7 @@ function TerrainEditor::setPaintMaterial( %this, %matIndex, %terrainMat )
    ETerrainMaterialSelected.selectedMatIndex = %matIndex;
    ETerrainMaterialSelected.selectedMat = %terrainMat;
    
-   ETerrainMaterialSelected.setBitmap(%terrainMat.getDiffuseMap());
+   ETerrainMaterialSelected.setBitmap(getAssetPreviewImage(%terrainMat.getDiffuseMap()));
 
    ETerrainMaterialSelectedEdit.Visible = isObject(%terrainMat);
    TerrainTextureText.text = %terrainMat.getInternalName();
@@ -141,7 +141,7 @@ function EPainter::updateLayers( %this, %matIndex )
       };
 
       %ctrl.setText( %matInternalName );
-      %ctrl.setBitmap( %mat.getDiffuseMap() );
+      %ctrl.setBitmap( getAssetPreviewImage(%mat.getDiffuseMap()) );
 
       %tooltip = %matInternalName;
       if(%i < 9)

+ 17 - 81
Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript

@@ -296,7 +296,7 @@ function TerrainMaterialDlg::changeTerrainMatMapAsset(%this)
       %image = $TerrainMaterialEditor::emptyMaterialImage;
    }
 
-   %targetMap.setBitmap( %image );  
+   %targetMap.setBitmap( getAssetPreviewImage(%image) );  
 
    %targetMapName = %targetMap @ "AssetId";
    %targetMapName.setText(%imgAsset);
@@ -420,99 +420,35 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat )
 
       //
       %imgPath = %mat.getDiffuseMap();
-      if(%imgPath $= "")
-         %imgPath = $TerrainMaterialEditor::emptyMaterialImage;
-
-      %this-->texBaseMap.setBitmap( %imgPath );
-      
-      if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage)
-      {
-         %imgAsset = %mat.getDiffuseMapAsset();
-         if(%imgAsset $= "")
-            %imgAsset = %imgPath;
-         %this-->diffuseMapAssetId.setText( %imgAsset );
-      }
-      else
-      {
-         %this-->diffuseMapAssetId.setText( "None" );  
-      }
+      %imgPathText = %imgPath !$= "" && %imgPath !$= $TerrainMaterialEditor::emptyMaterialImage ? %mat.getDiffuseMapAsset() : "None";
+      %this-->diffuseMapAssetId.setText( %imgPathText );
+      %this-->texBaseMap.setBitmap( getAssetPreviewImage(%imgPath) );
 
       //
       %imgPath = %mat.getNormalMap();
-      if(%imgPath $= "")
-         %imgPath = $TerrainMaterialEditor::emptyMaterialImage;
-
-      %this-->texNormalMap.setBitmap( %imgPath );
-      
-      if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage)
-      {
-         %imgAsset = %mat.getNormalMapAsset();
-         if(%imgAsset $= "")
-            %imgAsset = %imgPath;
-         %this-->normalMapAssetId.setText( %imgAsset );
-      }
-      else
-      {
-         %this-->normalMapAssetId.setText( "None" );  
-      }
+      %imgPathText = %imgPath !$= "" && %imgPath !$= $TerrainMaterialEditor::emptyMaterialImage ? %mat.getNormalMapAsset() : "None";
+      %this-->normalMapAssetId.setText( %imgPathText );
+      %this-->texNormalMap.setBitmap( getAssetPreviewImage(%imgPath) );
 
       //
       %imgPath = %mat.getORMConfigMap();
-      if(%imgPath $= "")
-         %imgPath = $TerrainMaterialEditor::emptyMaterialImage;
-
-      %this-->texORMConfigMap.setBitmap( %imgPath );
-      
-      if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage)
-      {
-         %imgAsset = %mat.getORMConfigMapAsset();
-         if(%imgAsset $= "")
-            %imgAsset = %imgPath;
-         %this-->ORMMapAssetId.setText( %imgAsset );
-      }
-      else
-      {
-         %this-->ORMMapAssetId.setText( "None" );  
-      }
+      %imgPathText = %imgPath !$= "" && %imgPath !$= $TerrainMaterialEditor::emptyMaterialImage ? %mat.getORMConfigMapAsset() : "None";
+      %this-->ORMMapAssetId.setText( %imgPathText );
+      %this-->texORMConfigMap.setBitmap( getAssetPreviewImage(%imgPath) );
        
       //
       %imgPath = %mat.getDetailMap();
-      if(%imgPath $= "")
-         %imgPath = $TerrainMaterialEditor::emptyMaterialImage;
-
-      %this-->texDetailMap.setBitmap( %imgPath );
-      
-      if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage)
-      {
-         %imgAsset = %mat.getDetailMapAsset();
-         if(%imgAsset $= "")
-            %imgAsset = %imgPath;
-         %this-->detailMapAssetId.setText( %imgAsset );
-      }
-      else
-      {
-         %this-->detailMapAssetId.setText( "None" );  
-      }
+      %imgPathText = %imgPath !$= "" && %imgPath !$= $TerrainMaterialEditor::emptyMaterialImage ? %mat.getDetailMapAsset() : "None";
+      %this-->detailMapAssetId.setText( %imgPathText );
+      %this-->texDetailMap.setBitmap( getAssetPreviewImage(%imgPath) );
       
       //
       %imgPath = %mat.getMacroMap();
-      if(%imgPath $= "")
-         %imgPath = $TerrainMaterialEditor::emptyMaterialImage;
-
-      %this-->texMacroMap.setBitmap( %imgPath );
-
-      if(%imgPath !$= $TerrainMaterialEditor::emptyMaterialImage)
-      {
-         %imgAsset = %mat.getMacroMapAsset();
-         if(%imgAsset $= "")
-            %imgAsset = %imgPath;
-         %this-->macroMapAssetId.setText( %imgAsset );
-      }
-      else
-      {
-         %this-->macroMapAssetId.setText( "None" );  
-      }      
+      %imgPathText = %imgPath !$= "" && %imgPath !$= $TerrainMaterialEditor::emptyMaterialImage ? %mat.getMacroMapAsset() : "None";
+      %this-->macroMapAssetId.setText( %imgPathText );
+      %this-->texMacroMap.setBitmap( getAssetPreviewImage(%imgPath) );
       
+      //
       %this-->detSizeCtrl.setText( %mat.detailSize );
       %this-->baseSizeCtrl.setText( %mat.diffuseSize );
       %this-->detStrengthCtrl.setText( %mat.detailStrength );