Ver Fonte

Merge branch 'alph40_pbrConfig_BREAKINGWip' of https://github.com/Azaezel/Torque3D into Preview4_0

Areloch há 5 anos atrás
pai
commit
ac77315e29
36 ficheiros alterados com 1157 adições e 763 exclusões
  1. 3 3
      Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp
  2. 0 1
      Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.h
  3. 182 61
      Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp
  4. 30 11
      Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h
  5. 3 3
      Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp
  6. 0 1
      Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.h
  7. 177 78
      Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp
  8. 23 15
      Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h
  9. 0 2
      Engine/source/lighting/basic/basicLightManager.cpp
  10. 15 9
      Engine/source/materials/materialDefinition.cpp
  11. 7 5
      Engine/source/materials/materialDefinition.h
  12. 10 13
      Engine/source/materials/materialFeatureTypes.cpp
  13. 5 6
      Engine/source/materials/materialFeatureTypes.h
  14. 15 9
      Engine/source/materials/processedMaterial.cpp
  15. 21 21
      Engine/source/materials/processedShaderMaterial.cpp
  16. 2 1
      Engine/source/materials/processedShaderMaterial.h
  17. 13 10
      Engine/source/renderInstance/renderDeferredMgr.cpp
  18. 0 96
      Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp
  19. 0 54
      Engine/source/shaderGen/GLSL/pixSpecularGLSL.h
  20. 7 13
      Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp
  21. 4 6
      Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp
  22. 0 103
      Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp
  23. 0 54
      Engine/source/shaderGen/HLSL/pixSpecularHLSL.h
  24. 6 12
      Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp
  25. 4 7
      Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp
  26. 2 1
      Engine/source/shaderGen/shaderGenVars.cpp
  27. 2 1
      Engine/source/shaderGen/shaderGenVars.h
  28. 2 4
      Engine/source/terrain/glsl/terrFeatureGLSL.cpp
  29. 2 4
      Engine/source/terrain/hlsl/terrFeatureHLSL.cpp
  30. 0 3
      Engine/source/ts/collada/colladaAppMaterial.cpp
  31. 0 1
      Engine/source/ts/collada/colladaAppMaterial.h
  32. 0 1
      Engine/source/ts/collada/colladaShapeLoader.cpp
  33. 2 3
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs
  34. 363 132
      Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui
  35. 81 19
      Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs
  36. 176 0
      Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui

+ 3 - 3
Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp

@@ -390,7 +390,7 @@ void DeferredBumpFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
       Parent::processPix( componentList, fd );
       return;
    }
-   else if (!fd.features[MFT_SpecularMap] )
+   else if (!fd.features[MFT_PBRConfigMap] )
    {
       Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
       if( bumpSample == NULL )
@@ -421,7 +421,7 @@ ShaderFeature::Resources DeferredBumpFeatGLSL::getResources( const MaterialFeatu
       return Parent::getResources( fd );
 
    Resources res; 
-   if(!fd.features[MFT_SpecularMap])
+   if(!fd.features[MFT_PBRConfigMap])
    {
       res.numTex = 1;
       res.numTexReg = 1;
@@ -464,7 +464,7 @@ void DeferredBumpFeatGLSL::setTexData( Material::StageData &stageDat,
          passData.mTexSlot[texIndex++].texObject = stageDat.getTex(MFT_DetailNormalMap);
       }
    }
-   else if (!fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
+   else if (!fd.features[MFT_Parallax] && !fd.features[MFT_PBRConfigMap] &&
          ( fd.features[MFT_DeferredConditioner]) )
    {
       passData.mTexType[ texIndex ] = Material::Bump;

+ 0 - 1
Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.h

@@ -25,7 +25,6 @@
 
 #include "shaderGen/GLSL/shaderFeatureGLSL.h"
 #include "shaderGen/GLSL/bumpGLSL.h"
-#include "shaderGen/GLSL/pixSpecularGLSL.h"
 
 class ConditionerMethodDependency;
 

+ 182 - 61
Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp

@@ -35,55 +35,72 @@
 //****************************************************************************
 // Deferred Shading Features
 //****************************************************************************
+U32 PBRConfigMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
+}
 
-// Specular Map -> Blue of Material Buffer ( greyscaled )
-// Gloss Map (Alpha Channel of Specular Map) -> Alpha ( Spec Power ) of Material Info Buffer.
-void DeferredSpecMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+void PBRConfigMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
 {
    // Get the texture coord.
    Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList );
-
-   // search for color var
-   Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-   MultiLine * meta = new MultiLine;
-   if ( !material )
+   
+   MultiLine* meta = new MultiLine;
+   Var* pbrConfig;
+   if (fd.features[MFT_isDeferred])
    {
-      // create color var
-      material = new Var;
-      material->setType( "vec4" );
-      material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-      material->setStructName("OUT");
+      pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+      if (!pbrConfig)
+      {
+         // create material var
+         pbrConfig = new Var;
+         pbrConfig->setType("vec4");
+         pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+         pbrConfig->setStructName("OUT");
+      }
+   }
+   else
+   {
+      pbrConfig = (Var*)LangElement::find("PBRConfig");
+      if (!pbrConfig)
+      {
+         pbrConfig = new Var("PBRConfig", "vec4");
+         meta->addStatement(new GenOp("   @;\r\n", new DecOp(pbrConfig)));
+      }
    }
 
    // create texture var
-   Var *specularMap = new Var;
-   specularMap->setType( "sampler2D" );
-   specularMap->setName( "specularMap" );
-   specularMap->uniform = true;
-   specularMap->sampler = true;
-   specularMap->constNum = Var::getTexUnitNum();
-   LangElement *texOp = new GenOp( "tex2D(@, @)", specularMap, texCoord );
-
-   Var *pbrConfig = (Var*)LangElement::find("PBRConfig");
-   if (!pbrConfig) pbrConfig = new Var("PBRConfig", "vec4");
+   Var *pbrConfigMap = new Var;
+   pbrConfigMap->setType( "sampler2D" );
+   pbrConfigMap->setName( "pbrConfigMap" );
+   pbrConfigMap->uniform = true;
+   pbrConfigMap->sampler = true;
+   pbrConfigMap->constNum = Var::getTexUnitNum();
+   LangElement *texOp = new GenOp( "tex2D(@, @)", pbrConfigMap, texCoord );
+
    Var *metalness = (Var*)LangElement::find("metalness");
    if (!metalness) metalness = new Var("metalness", "float");
    Var *smoothness = (Var*)LangElement::find("smoothness");
    if (!smoothness) smoothness = new Var("smoothness", "float");
+   Var* ao = (Var*)LangElement::find("ao");
+   if (!ao) ao = new Var("ao", "float");
 
-   meta->addStatement(new GenOp("   @ = @.r;\r\n", new DecOp(smoothness), texOp));
-      meta->addStatement(new GenOp("   @ = @.b;\r\n", new DecOp(metalness), texOp));
 
+   meta->addStatement(new GenOp("   @.bga = @.rgb;\r\n", pbrConfig, texOp));
+
+   meta->addStatement(new GenOp("   @ = @.b;\r\n", new DecOp(smoothness), pbrConfig));
    if (fd.features[MFT_InvertSmoothness])
+   {
+      meta->addStatement(new GenOp("   @.b = [email protected];\r\n", pbrConfig, pbrConfig));
       meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
+   }
+   meta->addStatement(new GenOp("   @ = @.g;\r\n", new DecOp(ao), pbrConfig));
+   meta->addStatement(new GenOp("   @ = @.a;\r\n", new DecOp(metalness), pbrConfig));
 
-   meta->addStatement(new GenOp("   @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp));
-
-   meta->addStatement(new GenOp("   @.bga = vec3(@,@.g,@);\r\n", material, smoothness, pbrConfig, metalness));
    output = meta;
 }
 
-ShaderFeature::Resources DeferredSpecMapGLSL::getResources( const MaterialFeatureData &fd )
+ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureData &fd )
 {
    Resources res; 
    res.numTex = 1;
@@ -92,21 +109,21 @@ ShaderFeature::Resources DeferredSpecMapGLSL::getResources( const MaterialFeatur
    return res;
 }
 
-void DeferredSpecMapGLSL::setTexData(   Material::StageData &stageDat,
+void PBRConfigMapGLSL::setTexData(   Material::StageData &stageDat,
                                        const MaterialFeatureData &fd,
                                        RenderPassData &passData,
                                        U32 &texIndex )
 {
-   GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
+   GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap);
    if ( tex )
    {
       passData.mTexType[ texIndex ] = Material::Standard;
-      passData.mSamplerNames[ texIndex ] = "specularMap";
+      passData.mSamplerNames[ texIndex ] = "pbrConfigMap";
       passData.mTexSlot[ texIndex++ ].texObject = tex;
    }
 }
 
-void DeferredSpecMapGLSL::processVert( Vector<ShaderComponent*> &componentList, 
+void PBRConfigMapGLSL::processVert( Vector<ShaderComponent*> &componentList,
                                        const MaterialFeatureData &fd )
 {
    MultiLine *meta = new MultiLine;
@@ -118,20 +135,37 @@ void DeferredSpecMapGLSL::processVert( Vector<ShaderComponent*> &componentList,
    output = meta;
 }
 
+U32 MatInfoFlagsGLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
+}
+
 // Material Info Flags -> Red ( Flags ) of Material Info Buffer.
-void DeferredMatInfoFlagsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+void MatInfoFlagsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
 {
 	MultiLine *meta = new MultiLine;
 
-   // search for material var
-   Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-   if ( !material )
+   Var* pbrConfig;
+   if (fd.features[MFT_isDeferred])
+   {
+      pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+      if (!pbrConfig)
+      {
+         // create material var
+         pbrConfig = new Var;
+         pbrConfig->setType("vec4");
+         pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+         pbrConfig->setStructName("OUT");
+      }
+   }
+   else
    {
-      // create material var
-      material = new Var;
-      material->setType( "vec4" );
-      material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-      material->setStructName("OUT");
+      pbrConfig = (Var*)LangElement::find("PBRConfig");
+      if (!pbrConfig)
+      {
+         pbrConfig = new Var("PBRConfig", "vec4");
+         meta->addStatement(new GenOp("   @;\r\n", new DecOp(pbrConfig)));
+      }
    }
 
    Var *matInfoFlags = new Var;
@@ -140,39 +174,126 @@ void DeferredMatInfoFlagsGLSL::processPix( Vector<ShaderComponent*> &componentLi
    matInfoFlags->uniform = true;
    matInfoFlags->constSortPos = cspPotentialPrimitive;
 
-   meta->addStatement(output = new GenOp("   @.r = @;\r\n", material, matInfoFlags));
+   meta->addStatement(output = new GenOp("   @.r = @;\r\n", pbrConfig, matInfoFlags));
    output = meta;
 }
 
+U32 PBRConfigVarsGLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
+}
+
 // Spec Strength -> Blue Channel of Material Info Buffer.
 // Spec Power -> Alpha Channel ( of Material Info Buffer.
-void DeferredSpecVarsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+void PBRConfigVarsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
 {
+   MultiLine* meta = new MultiLine;
 
-   // search for material var
-   Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-   if ( !material )
+   Var* pbrConfig;
+   if (fd.features[MFT_isDeferred])
    {
-      // create material var
-      material = new Var;
-      material->setType( "vec4" );
-      material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-      material->setStructName("OUT");
+      pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+      if (!pbrConfig)
+      {
+         // create material var
+         pbrConfig = new Var;
+         pbrConfig->setType("vec4");
+         pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+         pbrConfig->setStructName("OUT");
+      }
    }
-   
-   Var *metalness = new Var("metalness", "float");
+   else
+   {
+      pbrConfig = (Var*)LangElement::find("PBRConfig");
+      if (!pbrConfig)
+      {
+         pbrConfig = new Var("PBRConfig", "vec4");
+         meta->addStatement(new GenOp("   @;\r\n", new DecOp(pbrConfig)));
+      }
+   }
+   Var* metalness = new Var("metalness", "float");
    metalness->uniform = true;
    metalness->constSortPos = cspPotentialPrimitive;
 
-   Var *smoothness = new Var("smoothness", "float");
+   Var* smoothness = new Var("smoothness", "float");
    smoothness->uniform = true;
    smoothness->constSortPos = cspPotentialPrimitive;
 
-	MultiLine *meta = new MultiLine;
-    meta->addStatement(new GenOp("   @.g = 1.0;\r\n", material));
-    meta->addStatement(new GenOp("   @.b = @;\r\n", material, smoothness));
-    if (fd.features[MFT_InvertSmoothness])
-       meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
-    meta->addStatement(new GenOp("   @.a = @;\r\n", material, metalness));
+   //matinfo.g slot reserved for AO later
+   meta->addStatement(new GenOp("   @.g = 1.0;\r\n", pbrConfig));
+   meta->addStatement(new GenOp("   @.b = @;\r\n", pbrConfig, smoothness));
+   if (fd.features[MFT_InvertSmoothness])
+      meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
+   meta->addStatement(new GenOp("   @.a = @;\r\n", pbrConfig, metalness));
    output = meta;
 }
+
+U32 GlowMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
+}
+
+//deferred emissive
+void GlowMapGLSL::processPix(Vector<ShaderComponent*>& componentList, const MaterialFeatureData& fd)
+{
+   Var* texCoord = getInTexCoord("texCoord", "vec2", componentList);
+
+   Var* glowMap = new Var;
+   glowMap->setType("sampler2D");
+   glowMap->setName("glowMap");
+   glowMap->uniform = true;
+   glowMap->sampler = true;
+   glowMap->constNum = Var::getTexUnitNum();
+   LangElement* texOp = new GenOp("tex2D(@, @)", glowMap, texCoord);
+   
+   Var* glowMul = new Var("glowMul", "float");
+   glowMul->uniform = true;
+   glowMul->constSortPos = cspPotentialPrimitive;
+
+   Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
+   if (fd.features[MFT_isDeferred])
+   {
+      targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3));
+      if (!targ)
+      {
+         // create scene color target var
+         targ = new Var;
+         targ->setType("vec4");
+         targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
+         targ->setStructName("OUT");
+         output = new GenOp("@ = vec4(@.rgb*@,0);", targ, texOp, glowMul);
+      }
+      else
+      {
+         output = new GenOp("@ += vec4(@.rgb*@,0);", targ, texOp, glowMul);
+      }
+   }
+   else
+   {
+      output = new GenOp("@ += vec4(@.rgb*@,@.a);", targ, texOp, glowMul, targ);
+   }
+
+}
+
+ShaderFeature::Resources GlowMapGLSL::getResources(const MaterialFeatureData& fd)
+{
+   Resources res;
+   res.numTex = 1;
+   res.numTexReg = 1;
+
+   return res;
+}
+
+void GlowMapGLSL::setTexData(Material::StageData& stageDat,
+   const MaterialFeatureData& fd,
+   RenderPassData& passData,
+   U32& texIndex)
+{
+   GFXTextureObject* tex = stageDat.getTex(MFT_GlowMap);
+   if (tex)
+   {
+      passData.mTexType[texIndex] = Material::Standard;
+      passData.mSamplerNames[texIndex] = "glowMap";
+      passData.mTexSlot[texIndex++].texObject = tex;
+   }
+}

+ 30 - 11
Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h

@@ -25,13 +25,14 @@
 
 #include "shaderGen/GLSL/shaderFeatureGLSL.h"
 #include "shaderGen/GLSL/bumpGLSL.h"
-#include "shaderGen/GLSL/pixSpecularGLSL.h"
 
 // Specular Outputs
-class DeferredSpecMapGLSL : public ShaderFeatureGLSL
+class PBRConfigMapGLSL : public ShaderFeatureGLSL
 {
 public:
-   virtual String getName() { return "Deferred Shading: Specular Map"; }
+   virtual String getName() { return "Deferred Shading: PBR Config Map"; }
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
 
    virtual void processPix( Vector<ShaderComponent*> &componentList, 
       const MaterialFeatureData &fd );
@@ -48,26 +49,44 @@ public:
                              const MaterialFeatureData &fd );
 };
 
-class DeferredMatInfoFlagsGLSL : public ShaderFeatureGLSL
+class MatInfoFlagsGLSL : public ShaderFeatureGLSL
 {
 public:
    virtual String getName() { return "Deferred Shading: Mat Info Flags"; }
 
    virtual void processPix( Vector<ShaderComponent*> &componentList, 
       const MaterialFeatureData &fd );
-   
-   virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
 };
 
-class DeferredSpecVarsGLSL : public ShaderFeatureGLSL
+class PBRConfigVarsGLSL : public ShaderFeatureGLSL
 {
 public:
-   virtual String getName() { return "Deferred Shading: Specular Explicit Numbers"; }
+   virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; }
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
 
    virtual void processPix( Vector<ShaderComponent*> &componentList, 
       const MaterialFeatureData &fd );
-   
-   virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
 };
 
-#endif
+class GlowMapGLSL : public ShaderFeatureGLSL
+{
+public:
+   virtual String getName() { return "Glow Map"; }
+
+   virtual void processPix(Vector<ShaderComponent*>& componentList,
+      const MaterialFeatureData& fd);
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
+
+   virtual Resources getResources(const MaterialFeatureData& fd);
+
+   // Sets textures and texture flags for current pass
+   virtual void setTexData(Material::StageData& stageDat,
+      const MaterialFeatureData& fd,
+      RenderPassData& passData,
+      U32& texIndex);
+};
+#endif

+ 3 - 3
Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp

@@ -421,7 +421,7 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
       Parent::processPix( componentList, fd );
       return;
    }
-   else if (!fd.features[MFT_SpecularMap] )
+   else if (!fd.features[MFT_PBRConfigMap] )
    {
       Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
       if( bumpSample == NULL )
@@ -454,7 +454,7 @@ ShaderFeature::Resources DeferredBumpFeatHLSL::getResources( const MaterialFeatu
       return Parent::getResources( fd );
 
    Resources res; 
-   if(!fd.features[MFT_SpecularMap])
+   if(!fd.features[MFT_PBRConfigMap])
    {
       res.numTex = 1;
       res.numTexReg = 1;
@@ -497,7 +497,7 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat,
          passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_DetailNormalMap );
       }
    }
-   else if (  !fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
+   else if (  !fd.features[MFT_Parallax] && !fd.features[MFT_PBRConfigMap] &&
          ( fd.features[MFT_DeferredConditioner]) )
    {
       passData.mTexType[ texIndex ] = Material::Bump;

+ 0 - 1
Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.h

@@ -25,7 +25,6 @@
 
 #include "shaderGen/HLSL/shaderFeatureHLSL.h"
 #include "shaderGen/HLSL/bumpHLSL.h"
-#include "shaderGen/HLSL/pixSpecularHLSL.h"
 
 class ConditionerMethodDependency;
 

+ 177 - 78
Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp

@@ -35,61 +35,79 @@
 //****************************************************************************
 // Deferred Shading Features
 //****************************************************************************
+U32 PBRConfigMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
+}
 
-// Specular Map -> Blue of Material Buffer ( greyscaled )
-// Gloss Map (Alpha Channel of Specular Map) -> Alpha ( Spec Power ) of Material Info Buffer.
-void DeferredSpecMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+void PBRConfigMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
 {
    // Get the texture coord.
    Var *texCoord = getInTexCoord( "texCoord", "float2", componentList );
 
-   // search for color var
-   Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-   MultiLine * meta = new MultiLine;
-   if ( !material )
+   MultiLine* meta = new MultiLine;
+   Var* pbrConfig;
+   if (fd.features[MFT_isDeferred])
+   {
+      pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+      if (!pbrConfig)
+      {
+         // create material var
+         pbrConfig = new Var;
+         pbrConfig->setType("fragout");
+         pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+         pbrConfig->setStructName("OUT");
+      }
+   }
+   else
    {
-      // create color var
-      material = new Var;
-      material->setType( "fragout" );
-      material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-      material->setStructName( "OUT" );
+      pbrConfig = (Var*)LangElement::find("PBRConfig");
+      if (!pbrConfig)
+      {
+         pbrConfig = new Var("PBRConfig", "float4");
+         meta->addStatement(new GenOp("   @;\r\n", new DecOp(pbrConfig)));
+      }
    }
 
    // create texture var
-   Var *specularMap = new Var;
-   specularMap->setType( "SamplerState" );
-   specularMap->setName( "specularMap" );
-   specularMap->uniform = true;
-   specularMap->sampler = true;
-   specularMap->constNum = Var::getTexUnitNum();
-
-   Var* specularMapTex = new Var;
-   specularMapTex->setName("specularMapTex");
-   specularMapTex->setType("Texture2D");
-   specularMapTex->uniform = true;
-   specularMapTex->texture = true;
-   specularMapTex->constNum = specularMap->constNum;
-   LangElement *texOp = new GenOp("   @.Sample(@, @)", specularMapTex, specularMap, texCoord);
+   Var * pbrConfigMap = new Var;
+   pbrConfigMap->setType( "SamplerState" );
+   pbrConfigMap->setName( "PBRConfigMap" );
+   pbrConfigMap->uniform = true;
+   pbrConfigMap->sampler = true;
+   pbrConfigMap->constNum = Var::getTexUnitNum();
+
+   Var* pbrConfigMapTex = new Var;
+   pbrConfigMapTex->setName("PBRConfigMapTex");
+   pbrConfigMapTex->setType("Texture2D");
+   pbrConfigMapTex->uniform = true;
+   pbrConfigMapTex->texture = true;
+   pbrConfigMapTex->constNum = pbrConfigMap->constNum;
+   LangElement *texOp = new GenOp("@.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord);
    
-   Var * pbrConfig = (Var*)LangElement::find("pbrConfig");
-   if (!pbrConfig) pbrConfig = new Var("pbrConfig", "float4");
    Var *metalness = (Var*)LangElement::find("metalness");
    if (!metalness) metalness = new Var("metalness", "float");
    Var *smoothness = (Var*)LangElement::find("smoothness");
    if (!smoothness) smoothness = new Var("smoothness", "float");
+   Var* ao = (Var*)LangElement::find("ao");
+   if (!ao) ao = new Var("ao", "float");
+
 
-   meta->addStatement(new GenOp("   @ = @.r;\r\n", new DecOp(smoothness), texOp));
-   meta->addStatement(new GenOp("   @ = @.b;\r\n", new DecOp(metalness), texOp));
+   meta->addStatement(new GenOp("   @.bga = @.rgb;\r\n", pbrConfig, texOp));
 
+   meta->addStatement(new GenOp("   @ = @.b;\r\n", new DecOp(smoothness), pbrConfig));
    if (fd.features[MFT_InvertSmoothness])
+   {
+      meta->addStatement(new GenOp("   @.b = [email protected];\r\n", pbrConfig, pbrConfig));
       meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
+   }
+   meta->addStatement(new GenOp("   @ = @.g;\r\n", new DecOp(ao), pbrConfig));
+   meta->addStatement(new GenOp("   @ = @.a;\r\n", new DecOp(metalness), pbrConfig));
 
-   meta->addStatement(new GenOp("   @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp));
-   meta->addStatement(new GenOp("   @.bga = float3(@,@.g,@);\r\n", material, smoothness, pbrConfig, metalness));
    output = meta;
 }
 
-ShaderFeature::Resources DeferredSpecMapHLSL::getResources( const MaterialFeatureData &fd )
+ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureData &fd )
 {
    Resources res; 
    res.numTex = 1;
@@ -98,21 +116,21 @@ ShaderFeature::Resources DeferredSpecMapHLSL::getResources( const MaterialFeatur
    return res;
 }
 
-void DeferredSpecMapHLSL::setTexData(   Material::StageData &stageDat,
+void PBRConfigMapHLSL::setTexData(   Material::StageData &stageDat,
                                        const MaterialFeatureData &fd,
                                        RenderPassData &passData,
                                        U32 &texIndex )
 {
-   GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
+   GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap);
    if ( tex )
    {
       passData.mTexType[ texIndex ] = Material::Standard;
-      passData.mSamplerNames[ texIndex ] = "specularMap";
+      passData.mSamplerNames[ texIndex ] = "PBRConfigMap";
       passData.mTexSlot[ texIndex++ ].texObject = tex;
    }
 }
 
-void DeferredSpecMapHLSL::processVert( Vector<ShaderComponent*> &componentList, 
+void PBRConfigMapHLSL::processVert( Vector<ShaderComponent*> &componentList,
                                        const MaterialFeatureData &fd )
 {
    MultiLine *meta = new MultiLine;
@@ -124,18 +142,32 @@ void DeferredSpecMapHLSL::processVert( Vector<ShaderComponent*> &componentList,
    output = meta;
 }
 
+U32 MatInfoFlagsHLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
+}
+
 // Material Info Flags -> Red ( Flags ) of Material Info Buffer.
-void DeferredMatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+void MatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
 {
    // search for material var
-   Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-   if ( !material )
+   Var* pbrConfig;
+   if (fd.features[MFT_isDeferred])
    {
-      // create material var
-      material = new Var;
-      material->setType( "fragout" );
-      material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-      material->setStructName( "OUT" );
+      pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+      if (!pbrConfig)
+      {
+         // create material var
+         pbrConfig = new Var;
+         pbrConfig->setType("fragout");
+         pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+         pbrConfig->setStructName("OUT");
+      }
+   }
+   else
+   {
+      pbrConfig = (Var*)LangElement::find("PBRConfig");
+      if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4");
    }
 
    Var *matInfoFlags = new Var;
@@ -144,24 +176,36 @@ void DeferredMatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentLi
    matInfoFlags->uniform = true;
    matInfoFlags->constSortPos = cspPotentialPrimitive;
 
-   output = new GenOp( "   @.r = @;\r\n", material, matInfoFlags );
+   output = new GenOp( "   @.r = @;\r\n", pbrConfig, matInfoFlags );
 }
 
-// Spec Strength -> Blue Channel of Material Info Buffer.
-// Spec Power -> Alpha Channel ( of Material Info Buffer.
-void DeferredSpecVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+U32 PBRConfigVarsHLSL::getOutputTargets(const MaterialFeatureData& fd) const
 {
-   // search for material var
-   Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-   if ( !material )
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
+}
+
+void PBRConfigVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
+{
+   MultiLine* meta = new MultiLine;
+   Var* pbrConfig;
+   if (fd.features[MFT_isDeferred])
    {
-      // create material var
-      material = new Var;
-      material->setType( "fragout" );
-      material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
-      material->setStructName( "OUT" );
+      pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+      if (!pbrConfig)
+      {
+         // create material var
+         pbrConfig = new Var;
+         pbrConfig->setType("fragout");
+         pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
+         pbrConfig->setStructName("OUT");
+      }
+   }
+   else
+   {
+      pbrConfig = (Var*)LangElement::find("PBRConfig");
+      if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4");
+      meta->addStatement(new GenOp("   @;\r\n", new DecOp(pbrConfig)));
    }
-
    Var *metalness = new Var("metalness", "float");
    metalness->uniform = true;
    metalness->constSortPos = cspPotentialPrimitive;
@@ -170,34 +214,89 @@ void DeferredSpecVarsHLSL::processPix( Vector<ShaderComponent*> &componentList,
    smoothness->uniform = true;
    smoothness->constSortPos = cspPotentialPrimitive;
 
-   MultiLine * meta = new MultiLine;
    //matinfo.g slot reserved for AO later
-   meta->addStatement(new GenOp("   @.g = 1.0;\r\n", material));
-   meta->addStatement(new GenOp("   @.b = @;\r\n", material, smoothness));
+   meta->addStatement(new GenOp("   @.g = 1.0;\r\n", pbrConfig));
+   meta->addStatement(new GenOp("   @.b = @;\r\n", pbrConfig, smoothness));
    if (fd.features[MFT_InvertSmoothness])
       meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
-   meta->addStatement(new GenOp("   @.a = @;\r\n", material, metalness));
+   meta->addStatement(new GenOp("   @.a = @;\r\n", pbrConfig, metalness));
    output = meta;
 }
 
+U32 GlowMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const
+{
+   return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
+}
+
 //deferred emissive
-void DeferredEmissiveHLSL::processPix(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
+void GlowMapHLSL::processPix(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
 {
-   //for now emission just uses the diffuse color, we could plug in a separate texture for emission at some stage
-   Var *diffuseTargetVar = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
-   if (!diffuseTargetVar)
-      return; //oh dear something is not right, maybe we should just write 0's instead
-
-   // search for scene color target var
-   Var *sceneColorVar = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3));
-   if (!sceneColorVar)
+   Var* texCoord = getInTexCoord("texCoord", "float2", componentList);
+
+   // create texture var
+   Var* glowMap = new Var;
+   glowMap->setType("SamplerState");
+   glowMap->setName("glowMap");
+   glowMap->uniform = true;
+   glowMap->sampler = true;
+   glowMap->constNum = Var::getTexUnitNum();
+
+   Var* glowMapTex = new Var;
+   glowMapTex->setName("glowMapTex");
+   glowMapTex->setType("Texture2D");
+   glowMapTex->uniform = true;
+   glowMapTex->texture = true;
+   glowMapTex->constNum = glowMap->constNum;
+   LangElement* texOp = new GenOp("@.Sample(@, @)", glowMapTex, glowMap, texCoord);
+
+   Var* glowMul = new Var("glowMul", "float");
+   glowMul->uniform = true;
+   glowMul->constSortPos = cspPotentialPrimitive;
+
+   Var *targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
+   if (fd.features[MFT_isDeferred])
    {
-      // create scene color target var
-      sceneColorVar = new Var;
-      sceneColorVar->setType("fragout");
-      sceneColorVar->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
-      sceneColorVar->setStructName("OUT");
+      targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3));
+      if (!targ)
+      {
+         // create scene color target var
+         targ = new Var;
+         targ->setType("fragout");
+         targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
+         targ->setStructName("OUT");
+         output = new GenOp("@ = float4(@.rgb*@,0);", targ, texOp, glowMul);
+      }
+      else
+      {
+         output = new GenOp("@ += float4(@.rgb*@,0);", targ, texOp, glowMul);
+      }
+   }
+   else
+   {
+      output = new GenOp("@ += float4(@.rgb*@,@.a);", targ, texOp, glowMul, targ);
    }
 
-   output = new GenOp("@ = float4(@.rgb,0);", sceneColorVar, diffuseTargetVar);
-}
+}
+
+ShaderFeature::Resources GlowMapHLSL::getResources(const MaterialFeatureData& fd)
+{
+   Resources res;
+   res.numTex = 1;
+   res.numTexReg = 1;
+
+   return res;
+}
+
+void GlowMapHLSL::setTexData(Material::StageData& stageDat,
+   const MaterialFeatureData& fd,
+   RenderPassData& passData,
+   U32& texIndex)
+{
+   GFXTextureObject* tex = stageDat.getTex(MFT_GlowMap);
+   if (tex)
+   {
+      passData.mTexType[texIndex] = Material::Standard;
+      passData.mSamplerNames[texIndex] = "glowMap";
+      passData.mTexSlot[texIndex++].texObject = tex;
+   }
+}

+ 23 - 15
Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h

@@ -25,13 +25,13 @@
 
 #include "shaderGen/HLSL/shaderFeatureHLSL.h"
 #include "shaderGen/HLSL/bumpHLSL.h"
-#include "shaderGen/HLSL/pixSpecularHLSL.h"
 
-// Specular Outputs
-class DeferredSpecMapHLSL : public ShaderFeatureHLSL
+class PBRConfigMapHLSL : public ShaderFeatureHLSL
 {
 public:
-   virtual String getName() { return "Deferred Shading: Specular Map"; }
+   virtual String getName() { return "Deferred Shading: PBR Config Map"; }
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
 
    virtual void processPix( Vector<ShaderComponent*> &componentList, 
       const MaterialFeatureData &fd );
@@ -48,37 +48,45 @@ public:
                              const MaterialFeatureData &fd );
 };
 
-class DeferredMatInfoFlagsHLSL : public ShaderFeatureHLSL
+class MatInfoFlagsHLSL : public ShaderFeatureHLSL
 {
 public:
    virtual String getName() { return "Deferred Shading: Mat Info Flags"; }
 
    virtual void processPix( Vector<ShaderComponent*> &componentList, 
       const MaterialFeatureData &fd );
-   
-   virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
 };
 
-class DeferredSpecVarsHLSL : public ShaderFeatureHLSL
+class PBRConfigVarsHLSL : public ShaderFeatureHLSL
 {
 public:
-   virtual String getName() { return "Deferred Shading: Specular Explicit Numbers"; }
+   virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; }
+
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
 
    virtual void processPix( Vector<ShaderComponent*> &componentList, 
       const MaterialFeatureData &fd );
-   
-   virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
 };
 
-class DeferredEmissiveHLSL : public ShaderFeatureHLSL
+class GlowMapHLSL : public ShaderFeatureHLSL
 {
 public:
-   virtual String getName() { return "Deferred Shading: Emissive"; }
+   virtual String getName() { return "Glow Map"; }
 
    virtual void processPix(Vector<ShaderComponent*> &componentList,
       const MaterialFeatureData &fd);
 
-   virtual U32 getOutputTargets(const MaterialFeatureData &fd) const { return ShaderFeature::RenderTarget3; }
+   virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
+
+   virtual Resources getResources(const MaterialFeatureData& fd);
+
+   // Sets textures and texture flags for current pass
+   virtual void setTexData(Material::StageData& stageDat,
+      const MaterialFeatureData& fd,
+      RenderPassData& passData,
+      U32& texIndex);
 };
 
-#endif
+#endif

+ 0 - 2
Engine/source/lighting/basic/basicLightManager.cpp

@@ -43,14 +43,12 @@
 #include "shaderGen/featureMgr.h"
 #include "shaderGen/HLSL/shaderFeatureHLSL.h"
 #include "shaderGen/HLSL/bumpHLSL.h"
-#include "shaderGen/HLSL/pixSpecularHLSL.h"
 #include "lighting/basic/blTerrainSystem.h"
 #include "lighting/common/projectedShadow.h"
 
 #if defined( TORQUE_OPENGL )
 #include "shaderGen/GLSL/shaderFeatureGLSL.h"
 #include "shaderGen/GLSL/bumpGLSL.h"
-#include "shaderGen/GLSL/pixSpecularGLSL.h"
 #endif
 
 

+ 15 - 9
Engine/source/materials/materialDefinition.cpp

@@ -179,6 +179,9 @@ Material::Material()
       mAOMapFilename[i].clear();
       mMetalMapFilename[i].clear();
       mMetalMapAsset[i] = StringTable->EmptyString();
+      mGlowMapFilename[i].clear();
+      mGlowMapAsset[i] = StringTable->EmptyString();
+      mGlowMul[i] = 0.0f;
    }
 
    dMemset(mCellIndex, 0, sizeof(mCellIndex));
@@ -187,9 +190,6 @@ Material::Material()
    dMemset(mNormalMapAtlas, 0, sizeof(mNormalMapAtlas));
    dMemset(mUseAnisotropic, 1, sizeof(mUseAnisotropic));
 
-   // Deferred Shading : Metalness
-   dMemset(mUseMetalness, 0, sizeof(mUseMetalness));
-
    mImposterLimits = Point4F::Zero;
 
    mDoubleSided = false;
@@ -273,10 +273,13 @@ void Material::initPersistFields()
          "Used to scale the strength of the detail normal map when blended with the base normal map." );
       
       addField("smoothness", TypeF32, Offset(mSmoothness, Material), MAX_STAGES,
-         "The degree of smoothness when not using a specularMap." );
+         "The degree of smoothness when not using a PBRConfigMap." );
 
 		addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
-         "The degree of Metalness when not using a specularMap." );
+         "The degree of Metalness when not using a PBRConfigMap." );
+
+      addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
+         "glow mask multiplier");
 
       addProtectedField( "accuEnabled", TYPEID< bool >(), Offset( mAccuEnabled, Material ),
             &_setAccuEnabled, &defaultProtectedGetFn, MAX_STAGES, "Accumulation texture." );
@@ -302,7 +305,7 @@ void Material::initPersistFields()
       addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES,
          "Treat Smoothness as Roughness");
 
-      addField( "specularMap", TypeImageFilename, Offset(mSpecularMapFilename, Material), MAX_STAGES,
+      addField( "PBRConfigMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES,
          "Prepacked specular map texture. The RGB channels of this texture provide per-pixel reference values for: "
          "smoothness (R), Ambient Occlusion (G), and metalness(B)");
 
@@ -321,6 +324,12 @@ void Material::initPersistFields()
       addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES,
          "The input channel metalness maps use.");
 
+      addField("glowMap", TypeImageFilename, Offset(mGlowMapFilename, Material), MAX_STAGES,
+         "Metalness map. will be packed into the B channel of a packed 'specular' map");
+      addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
+         "The input channel metalness maps use.");
+      addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES,
+         "Enables rendering as glowing.");
 
       addField( "parallaxScale", TypeF32, Offset(mParallaxScale, Material), MAX_STAGES,
          "Enables parallax mapping and defines the scale factor for the parallax effect.  Typically "
@@ -347,9 +356,6 @@ void Material::initPersistFields()
       addField("subSurfaceRolloff", TypeF32, Offset(mSubSurfaceRolloff, Material), MAX_STAGES,
          "The 0 to 1 rolloff factor used in the subsurface scattering approximation." );
 
-      addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES,
-         "Enables rendering this material to the glow buffer." );
-
       addField("emissive", TypeBool, Offset(mEmissive, Material), MAX_STAGES,
          "Enables emissive lighting for the material." );
 

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

@@ -238,9 +238,9 @@ public:
 
    bool     mIsSRGb[MAX_STAGES];
    bool     mInvertSmoothness[MAX_STAGES];
-   FileName mSpecularMapFilename[MAX_STAGES];
-   StringTableEntry mSpecularMapAssetId[MAX_STAGES];
-   AssetPtr<ImageAsset> mSpecularMapAsset[MAX_STAGES];
+   FileName mPBRConfigMapFilename[MAX_STAGES];
+   StringTableEntry mPBRConfigMapAssetId[MAX_STAGES];
+   AssetPtr<ImageAsset> mPBRConfigMapAsset[MAX_STAGES];
    FileName mRoughMapFilename[MAX_STAGES];
    StringTableEntry mRoughMapAssetId[MAX_STAGES];
    AssetPtr<ImageAsset> mRoughMapAsset[MAX_STAGES];
@@ -254,6 +254,10 @@ public:
    AssetPtr<ImageAsset> mMetalMapAsset[MAX_STAGES];
    F32      mMetalChan[MAX_STAGES];
 
+   FileName mGlowMapFilename[MAX_STAGES];
+   StringTableEntry mGlowMapAssetId[MAX_STAGES];
+   AssetPtr<ImageAsset> mGlowMapAsset[MAX_STAGES];
+   F32      mGlowMul[MAX_STAGES];
    /// A second normal map which repeats at the detail map
    /// scale and blended with the base normal map.
    FileName mDetailNormalMapFilename[MAX_STAGES];
@@ -324,8 +328,6 @@ public:
    /// If the stage should use anisotropic filtering.
    bool mUseAnisotropic[MAX_STAGES];
 
-   // Deferred Shading: Metalness
-   bool mUseMetalness[MAX_STAGES];
 
    bool mDoubleSided;
 

+ 10 - 13
Engine/source/materials/materialFeatureTypes.cpp

@@ -43,19 +43,22 @@ ImplementFeatureType( MFT_DetailMap, MFG_Texture, 4.0f, true );
 ImplementFeatureType( MFT_DiffuseColor, MFG_Texture, 5.0f, true );
 ImplementFeatureType( MFT_DiffuseVertColor, MFG_Texture, 6.0f, true );
 ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
-ImplementFeatureType(MFT_InvertSmoothness, U32(-1), -1, true);
-ImplementFeatureType( MFT_SpecularMap, MFG_Texture, 8.0f, true );
-ImplementFeatureType( MFT_NormalMap, MFG_Texture, 9.0f, true );
-ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 10.0f, true );
+ImplementFeatureType( MFT_InvertSmoothness, U32(-1), -1, true);
+ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.0f, true);
+ImplementFeatureType( MFT_PBRConfigVars, MFG_Texture, 8.0f, true);
+ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, true);
+ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true );
+ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true );
 ImplementFeatureType( MFT_Imposter, U32(-1), -1, true );
 
 ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true );
 
 ImplementFeatureType(MFT_ReflectionProbes, MFG_Lighting, 1.0f, true);
 ImplementFeatureType( MFT_RTLighting, MFG_Lighting, 2.0f, true );
-ImplementFeatureType( MFT_LightMap, MFG_Lighting, 3.0f, true );
-ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 4.0f, true );
-ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 5.0f, false );
+ImplementFeatureType( MFT_GlowMap, MFG_Lighting, 3.0f, true );
+ImplementFeatureType( MFT_LightMap, MFG_Lighting, 4.0f, true );
+ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true );
+ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 6.0f, false );
 ImplementFeatureType( MFT_StaticCubemap, U32(-1), -1.0, true );
 ImplementFeatureType( MFT_CubeMap, MFG_Lighting, 7.0f, true );
 ImplementFeatureType( MFT_SubSurface, MFG_Lighting, 8.0f, true );
@@ -76,7 +79,6 @@ ImplementFeatureType( MFT_IsBC5nm, U32(-1), -1, true);
 ImplementFeatureType( MFT_IsTranslucent, U32(-1), -1, true );
 ImplementFeatureType( MFT_IsTranslucentZWrite, U32(-1), -1, true );
 ImplementFeatureType( MFT_IsEmissive, U32(-1), -1, true );
-ImplementFeatureType( MFT_GlossMap, U32(-1), -1, true );
 ImplementFeatureType( MFT_DiffuseMapAtlas, U32(-1), -1, true );
 ImplementFeatureType( MFT_NormalMapAtlas, U32(-1), -1, true );
 ImplementFeatureType( MFT_InterlacedDeferred, U32(-1), -1, true );
@@ -104,10 +106,5 @@ ImplementFeatureType( MFT_ImposterVert, MFG_PreTransform, 1.0, false );
 // Deferred Shading
 ImplementFeatureType( MFT_isDeferred, U32(-1), -1, true );
 ImplementFeatureType( MFT_SkyBox, MFG_Transform, 1.0f, false );
-ImplementFeatureType( MFT_DeferredSpecMap, MFG_Texture, 8.2f, false );
-ImplementFeatureType( MFT_DeferredSpecVars, MFG_Texture, 8.5f, false );
-ImplementFeatureType( MFT_DeferredMatInfoFlags, MFG_Texture, 8.7f, false );
-ImplementFeatureType( MFT_DeferredEmissive, MFG_Texture, 8.9f, false);
-
 ImplementFeatureType( MFT_HardwareSkinning, MFG_Transform,-2.0, false );
 

+ 5 - 6
Engine/source/materials/materialFeatureTypes.h

@@ -125,8 +125,10 @@ DeclareFeatureType( MFT_VertLitTone );
 DeclareFeatureType( MFT_StaticCubemap );
 DeclareFeatureType( MFT_CubeMap );
 DeclareFeatureType( MFT_InvertSmoothness );
-DeclareFeatureType( MFT_SpecularMap );
-DeclareFeatureType( MFT_GlossMap );
+DeclareFeatureType( MFT_PBRConfigMap );
+DeclareFeatureType( MFT_PBRConfigVars );
+
+DeclareFeatureType( MFT_GlowMap );
 
 DeclareFeatureType( MFT_ReflectionProbes );
 
@@ -191,8 +193,5 @@ DeclareFeatureType( MFT_HardwareSkinning );
 // Deferred Shading
 DeclareFeatureType( MFT_isDeferred );
 DeclareFeatureType( MFT_SkyBox );
-DeclareFeatureType( MFT_DeferredSpecMap );
-DeclareFeatureType( MFT_DeferredSpecVars );
-DeclareFeatureType( MFT_DeferredMatInfoFlags );
-DeclareFeatureType( MFT_DeferredEmissive );
+DeclareFeatureType( MFT_MatInfoFlags );
 #endif // _MATERIALFEATURETYPES_H_

+ 15 - 9
Engine/source/materials/processedMaterial.cpp

@@ -486,12 +486,12 @@ void ProcessedMaterial::_setStageData()
       if (mMaterial->mIsSRGb[i])
          profile = &GFXStaticTextureSRGBProfile;
 
-      // SpecularMap
-      if (mMaterial->mSpecularMapFilename[i].isNotEmpty())
+      // PBRConfig
+      if (mMaterial->mPBRConfigMapFilename[i].isNotEmpty())
       {
-         mStages[i].setTex(MFT_SpecularMap, _createTexture(mMaterial->mSpecularMapFilename[i], profile));
-         if (!mStages[i].getTex(MFT_SpecularMap))
-            mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i);
+         mStages[i].setTex(MFT_PBRConfigMap, _createTexture(mMaterial->mPBRConfigMapFilename[i], profile));
+         if (!mStages[i].getTex(MFT_PBRConfigMap))
+            mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
       }
       else
       {
@@ -501,14 +501,20 @@ void ProcessedMaterial::_setStageData()
             inputKey[0] = mMaterial->mSmoothnessChan[i];
             inputKey[1] = mMaterial->mAOChan[i];
             inputKey[2] = mMaterial->mMetalChan[i];
-            inputKey[3] = NULL;
-            mStages[i].setTex(MFT_SpecularMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
+            inputKey[3] = 0;
+            mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
                mMaterial->mMetalMapFilename[i], "",
                inputKey, profile));
-            if (!mStages[i].getTex(MFT_SpecularMap))
-               mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i);
+            if (!mStages[i].getTex(MFT_PBRConfigMap))
+               mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
          }
       }
+      if (mMaterial->mGlowMapFilename[i].isNotEmpty())
+      {
+         mStages[i].setTex(MFT_GlowMap, _createTexture(mMaterial->mGlowMapFilename[i], &GFXStaticTextureProfile));
+         if (!mStages[i].getTex(MFT_GlowMap))
+            mMaterial->logError("Failed to load glow map %s for stage %i", _getTexturePath(mMaterial->mGlowMapFilename[i]).c_str(), i);
+      }
    }
 
    mMaterial->mCubemapData = dynamic_cast<CubemapData*>(Sim::findObject(mMaterial->mCubemapName));

+ 21 - 21
Engine/source/materials/processedShaderMaterial.cpp

@@ -59,9 +59,10 @@ void ShaderConstHandles::init( GFXShader *shader, Vector<CustomShaderFeatureData
    mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
    mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
    mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap);
-   mSpecularColorSC = shader->getShaderConstHandle(ShaderGenVars::specularColor);
+   mPBRConfigSC = shader->getShaderConstHandle(ShaderGenVars::pbrConfig);
    mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness);
    mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness);
+   mGlowMulSC = shader->getShaderConstHandle(ShaderGenVars::glowMul);
    mAccuScaleSC = shader->getShaderConstHandle("$accuScale");
    mAccuDirectionSC = shader->getShaderConstHandle("$accuDirection");
    mAccuStrengthSC = shader->getShaderConstHandle("$accuStrength");
@@ -385,14 +386,6 @@ void ProcessedShaderMaterial::_determineFeatures(  U32 stageNum,
        fd.features.addFeature( MFT_CubeMap );
    }
 
-   if (features.hasFeature(MFT_SkyBox))
-   {
-      fd.features.addFeature(MFT_StaticCubemap);
-      fd.features.addFeature(MFT_CubeMap);
-      fd.features.addFeature(MFT_SkyBox);
-
-      fd.features.removeFeature(MFT_ReflectionProbes);
-   }
    fd.features.addFeature( MFT_Visibility );
 
    if (  lastStage && 
@@ -445,20 +438,26 @@ void ProcessedShaderMaterial::_determineFeatures(  U32 stageNum,
          fd.features.addFeature( MFT_Parallax );
    }
 
-   // Without realtime lighting and on lower end 
-   // shader models disable the specular map.
-   if (  !fd.features[ MFT_RTLighting ] || shaderVersion == 2.0 )
-      fd.features.removeFeature( MFT_SpecularMap );
+   // Deferred Shading : PBR Config
+   if (mStages[stageNum].getTex(MFT_PBRConfigMap))
+   {
+      fd.features.addFeature(MFT_PBRConfigMap);
+   }
+   else
+      fd.features.addFeature(MFT_PBRConfigVars);
+
+   // Deferred Shading : Material Info Flags
+   fd.features.addFeature(MFT_MatInfoFlags);
 
-   // If we have a specular map then make sure we
-   // have per-pixel specular enabled.
-   if( fd.features[ MFT_SpecularMap ] )
+   if (features.hasFeature(MFT_SkyBox))
    {
-      // Check for an alpha channel on the specular map. If it has one (and it
-      // has values less than 255) than the artist has put the gloss map into
-      // the alpha channel.
-      if( mStages[stageNum].getTex( MFT_SpecularMap )->mHasTransparency )
-         fd.features.addFeature( MFT_GlossMap );
+      fd.features.addFeature(MFT_StaticCubemap);
+      fd.features.addFeature(MFT_CubeMap);
+      fd.features.addFeature(MFT_SkyBox);
+
+      fd.features.removeFeature(MFT_ReflectionProbes);
+      fd.features.removeFeature(MFT_PBRConfigVars);
+      fd.features.removeFeature(MFT_MatInfoFlags);
    }
 
    if ( mMaterial->mAccuEnabled[stageNum] )
@@ -1118,6 +1117,7 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
 
    shaderConsts->setSafe(handles->mSmoothnessSC, mMaterial->mSmoothness[stageNum]);
    shaderConsts->setSafe(handles->mMetalnessSC, mMaterial->mMetalness[stageNum]);
+   shaderConsts->setSafe(handles->mGlowMulSC, mMaterial->mGlowMul[stageNum]);
 
    shaderConsts->setSafe(handles->mParallaxInfoSC, mMaterial->mParallaxScale[stageNum]);   
    shaderConsts->setSafe(handles->mMinnaertConstantSC, mMaterial->mMinnaertConstant[stageNum]);

+ 2 - 1
Engine/source/materials/processedShaderMaterial.h

@@ -46,9 +46,10 @@ public:
    GFXShaderConstHandle* mDiffuseColorSC;
    GFXShaderConstHandle* mToneMapTexSC;
    GFXShaderConstHandle* mTexMatSC;
-   GFXShaderConstHandle* mSpecularColorSC;
+   GFXShaderConstHandle* mPBRConfigSC;
    GFXShaderConstHandle* mSmoothnessSC;
    GFXShaderConstHandle* mMetalnessSC;
+   GFXShaderConstHandle* mGlowMulSC;
    GFXShaderConstHandle* mParallaxInfoSC;
    GFXShaderConstHandle* mAccuScaleSC;
    GFXShaderConstHandle* mAccuDirectionSC;

+ 13 - 10
Engine/source/renderInstance/renderDeferredMgr.cpp

@@ -634,16 +634,23 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
    if (mMaterial->mInvertSmoothness[stageNum])
       newFeatures.addFeature(MFT_InvertSmoothness);
 
-   // Deferred Shading : Specular
-   if( mStages[stageNum].getTex( MFT_SpecularMap ) )
+   // Deferred Shading : PBR Config
+   if( mStages[stageNum].getTex( MFT_PBRConfigMap ) )
    {
-       newFeatures.addFeature( MFT_DeferredSpecMap );
+       newFeatures.addFeature( MFT_PBRConfigMap );
+       if( mStages[stageNum].getTex( MFT_PBRConfigMap )->mHasTransparency )
+          newFeatures.addFeature( MFT_GlowMap );
    }
    else
-       newFeatures.addFeature( MFT_DeferredSpecVars );
+       newFeatures.addFeature( MFT_PBRConfigVars );
+
+   if (mStages[stageNum].getTex(MFT_GlowMap))
+   {
+      newFeatures.addFeature(MFT_GlowMap);
+   }
 
    // Deferred Shading : Material Info Flags
-   newFeatures.addFeature( MFT_DeferredMatInfoFlags );
+   newFeatures.addFeature( MFT_MatInfoFlags );
 
    for ( U32 i=0; i < fd.features.getCount(); i++ )
    {
@@ -738,12 +745,8 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
          newFeatures.addFeature( MFT_VertLit );
          newFeatures.addFeature( MFT_LightbufferMRT );
       }
-      else
+      else if (!fd.features.hasFeature(MFT_GlowMap))
       {
-         // If this object isn't lightmapped or emissive, add a zero-output feature for render target 3
-         if (fd.features.hasFeature(MFT_IsEmissive))
-            newFeatures.addFeature(MFT_DeferredEmissive);
-         else
             newFeatures.addFeature( MFT_RenderTarget3_Zero );
       }
    }

+ 0 - 96
Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp

@@ -1,96 +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.
-//-----------------------------------------------------------------------------
-
-#include "platform/platform.h"
-#include "shaderGen/GLSL/pixSpecularGLSL.h"
-#include "materials/processedMaterial.h"
-#include "materials/materialFeatureTypes.h"
-#include "shaderGen/shaderOp.h"
-#include "shaderGen/shaderGenVars.h"
-#include "gfx/gfxStructs.h"
-#include "shaderGen/shaderGen.h"
-
-void SpecularMapGLSL::processVert(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
-{
-   MultiLine *meta = new MultiLine;
-
-   // Add the texture coords.
-   getOutTexCoord("texCoord",
-     "vec2",
-      fd.features[MFT_TexAnim],
-      meta,
-      componentList);
-
-   output = meta;
-}
-
-void SpecularMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
-{
-   // Get the texture coord.
-   Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList );
-
-   // create texture var
-   Var *specularMap = new Var;
-   specularMap->setType( "sampler2D" );
-   specularMap->setName( "specularMap" );
-   specularMap->uniform = true;
-   specularMap->sampler = true;
-   specularMap->constNum = Var::getTexUnitNum();
-   LangElement *texOp = new GenOp( "texture(@, @)", specularMap, texCoord );
-
-   Var * pbrConfig = new Var( "PBRConfig", "vec4" );
-   Var *metalness = (Var*)LangElement::find("metalness");
-   if (!metalness) metalness = new Var("metalness", "float");
-   Var *smoothness = (Var*)LangElement::find("smoothness");
-   if (!smoothness) smoothness = new Var("smoothness", "float");
-   MultiLine * meta = new MultiLine;
-
-   meta->addStatement(new GenOp("   @ = @.r;\r\n", new DecOp(smoothness), texOp));
-   meta->addStatement(new GenOp("   @ = @.b;\r\n", new DecOp(metalness), texOp));
-
-   if (fd.features[MFT_InvertSmoothness])
-      meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
-
-   meta->addStatement(new GenOp("   @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp));
-   output = meta;
-}
-
-ShaderFeature::Resources SpecularMapGLSL::getResources( const MaterialFeatureData &fd )
-{
-   Resources res;
-   res.numTex = 1;
-   return res;
-}
-
-void SpecularMapGLSL::setTexData( Material::StageData &stageDat,
-                                 const MaterialFeatureData &fd,
-                                 RenderPassData &passData,
-                                 U32 &texIndex )
-{
-   GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
-   if ( tex )
-   {
-      passData.mTexType[ texIndex ] = Material::Standard;
-      passData.mSamplerNames[ texIndex ] = "specularMap";
-      passData.mTexSlot[ texIndex++ ].texObject = tex;
-   }
-}

+ 0 - 54
Engine/source/shaderGen/GLSL/pixSpecularGLSL.h

@@ -1,54 +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.
-//-----------------------------------------------------------------------------
-
-#ifndef _PIXSPECULAR_GLSL_H_
-#define _PIXSPECULAR_GLSL_H_
-
-#ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
-#include "shaderGen/GLSL/shaderFeatureGLSL.h"
-#endif
-
-/// A texture source for the PixSpecular feature
-class SpecularMapGLSL : public ShaderFeatureGLSL
-{
-
-public:
-   virtual void processVert( Vector<ShaderComponent*> &componentList,
-                             const MaterialFeatureData &fd );
-
-   virtual void processPix( Vector<ShaderComponent*> &componentList, 
-      const MaterialFeatureData &fd );
-
-   virtual Resources getResources( const MaterialFeatureData &fd );
-
-   virtual void setTexData( Material::StageData &stageDat,
-      const MaterialFeatureData &fd,
-      RenderPassData &passData,
-      U32 &texIndex );
-
-   virtual String getName()
-   {
-      return "Specular Map";
-   }
-};
-
-#endif // _PIXSPECULAR_HLSL_H_

+ 7 - 13
Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp

@@ -837,8 +837,8 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
 
    Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
 
-   Var* matinfo = (Var*)LangElement::find("PBRConfig");
-   if (!matinfo)
+   Var* pbrConfig = (Var*)LangElement::find("PBRConfig");
+   if (!pbrConfig)
    {
       Var* metalness = (Var*)LangElement::find("metalness");
       if (!metalness)
@@ -856,9 +856,9 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
          smoothness->constSortPos = cspPotentialPrimitive;
       }
 
-      matinfo = new Var("PBRConfig", "vec4");
-      LangElement* colorDecl = new DecOp(matinfo);
-      meta->addStatement(new GenOp("   @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
+      pbrConfig = new Var("PBRConfig", "vec4");
+      LangElement* colorDecl = new DecOp(pbrConfig);
+      meta->addStatement(new GenOp("   @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct pbrConfig, no ao darkening
    }
 
    Var* wsNormal = (Var*)LangElement::find("wsNormal");
@@ -895,7 +895,7 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
    if (!surface)
    {
       surface = new Var("surface", "Surface");
-      meta->addStatement(new GenOp("  @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo,
+      meta->addStatement(new GenOp("  @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig,
          wsPosition, wsEyePos, wsView));
    }
 
@@ -3046,13 +3046,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
    }
 
    Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
-
-   Var *matinfo = (Var*)LangElement::find("PBRConfig");
-   Var* metalness = (Var*)LangElement::find("metalness");
-   Var* smoothness = (Var*)LangElement::find("smoothness");
-   
-   Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
-
+      
    //Reflection vec
    String computeForwardProbes = String("   @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
    computeForwardProbes += String("@,@,\r\n\t\t");

+ 4 - 6
Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp

@@ -27,7 +27,6 @@
 #include "shaderGen/GLSL/shaderFeatureGLSL.h"
 #include "shaderGen/featureMgr.h"
 #include "shaderGen/GLSL/bumpGLSL.h"
-#include "shaderGen/GLSL/pixSpecularGLSL.h"
 #include "shaderGen/GLSL/depthGLSL.h"
 #include "shaderGen/GLSL/paraboloidGLSL.h"
 #include "materials/materialFeatureTypes.h"
@@ -66,9 +65,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
 	FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) );
    FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL );
    FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0"));
-   FEATUREMGR->registerFeature( MFT_SpecularMap, new SpecularMapGLSL );
    FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
-   FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) );
    FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
    FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
    FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatGLSL );
@@ -102,9 +99,10 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
 
    // Deferred Shading
    FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
-   FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapGLSL );
-   FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsGLSL );
-   FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsGLSL );
+   FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL );
+   FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL );
+   FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL );
+   FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapGLSL);
    FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureGLSL( "skybox" ) );
    FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureGLSL );
 }

+ 0 - 103
Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp

@@ -1,103 +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.
-//-----------------------------------------------------------------------------
-
-#include "platform/platform.h"
-#include "shaderGen/HLSL/pixSpecularHLSL.h"
-#include "materials/processedMaterial.h"
-#include "materials/materialFeatureTypes.h"
-#include "shaderGen/shaderOp.h"
-#include "shaderGen/shaderGenVars.h"
-#include "gfx/gfxStructs.h"
-#include "shaderGen/shaderGen.h"
-
-void SpecularMapHLSL::processVert(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
-{
-   MultiLine *meta = new MultiLine;
-
-   // Add the texture coords.
-   getOutTexCoord("texCoord",
-     "float2",
-      fd.features[MFT_TexAnim],
-      meta,
-      componentList);
-
-   output = meta;
-}
-
-void SpecularMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
-{
-   // Get the texture coord.
-   Var *texCoord = getInTexCoord("texCoord", "float2", componentList);
-
-   // create texture var
-   Var *specularMap = new Var;
-   specularMap->setType( "SamplerState" );
-   specularMap->setName( "specularMap" );
-   specularMap->uniform = true;
-   specularMap->sampler = true;
-   specularMap->constNum = Var::getTexUnitNum();
-
-   Var *specularMapTex = new Var;
-   specularMapTex->setName("specularMapTex");
-   specularMapTex->setType("Texture2D");
-   specularMapTex->uniform = true;
-   specularMapTex->texture = true;
-   specularMapTex->constNum = specularMap->constNum;
-   LangElement *texOp = new GenOp("@.Sample(@, @)", specularMapTex, specularMap, texCoord);
-
-
-   Var * pbrConfig = new Var( "PBRConfig", "float4" );
-   Var *metalness = (Var*)LangElement::find("metalness");
-   if (!metalness) metalness = new Var("metalness", "float");
-   Var *smoothness = (Var*)LangElement::find("smoothness");
-   if (!smoothness) smoothness = new Var("smoothness", "float");
-   MultiLine * meta = new MultiLine;
-
-   meta->addStatement(new GenOp("   @ = @.r;\r\n", new DecOp(smoothness), texOp));
-   meta->addStatement(new GenOp("   @ = @.b;\r\n", new DecOp(metalness), texOp));
-
-   if (fd.features[MFT_InvertSmoothness])
-      meta->addStatement(new GenOp("   @ = 1.0-@;\r\n", smoothness, smoothness));
-   meta->addStatement(new GenOp("   @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp));
-   output = meta;
-}
-
-ShaderFeature::Resources SpecularMapHLSL::getResources( const MaterialFeatureData &fd )
-{
-   Resources res;
-   res.numTex = 1;
-   return res;
-}
-
-void SpecularMapHLSL::setTexData( Material::StageData &stageDat,
-                                 const MaterialFeatureData &fd,
-                                 RenderPassData &passData,
-                                 U32 &texIndex )
-{
-   GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
-   if ( tex )
-   {
-      passData.mTexType[ texIndex ] = Material::Standard;
-      passData.mSamplerNames[ texIndex ] = "specularMap";
-      passData.mTexSlot[ texIndex++ ].texObject = tex;
-   }
-}

+ 0 - 54
Engine/source/shaderGen/HLSL/pixSpecularHLSL.h

@@ -1,54 +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.
-//-----------------------------------------------------------------------------
-
-#ifndef _PIXSPECULAR_HLSL_H_
-#define _PIXSPECULAR_HLSL_H_
-
-#ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
-#include "shaderGen/HLSL/shaderFeatureHLSL.h"
-#endif
-
-/// A texture source for the PixSpecular feature
-class SpecularMapHLSL : public ShaderFeatureHLSL
-{
-
-public:
-   virtual void processVert( Vector<ShaderComponent*> &componentList,
-                             const MaterialFeatureData &fd );
-
-   virtual void processPix( Vector<ShaderComponent*> &componentList, 
-      const MaterialFeatureData &fd );
-
-   virtual Resources getResources( const MaterialFeatureData &fd );
-
-   virtual void setTexData( Material::StageData &stageDat,
-      const MaterialFeatureData &fd,
-      RenderPassData &passData,
-      U32 &texIndex );
-
-   virtual String getName()
-   {
-      return "Specular Map";
-   }
-};
-
-#endif // _PIXSPECULAR_HLSL_H_

+ 6 - 12
Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

@@ -849,8 +849,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
 
    Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
 
-   Var* matinfo = (Var*)LangElement::find("PBRConfig");
-   if (!matinfo)
+   Var* pbrConfig = (Var*)LangElement::find("PBRConfig");
+   if (!pbrConfig)
    {
       Var* metalness = (Var*)LangElement::find("metalness");
       if (!metalness)
@@ -868,8 +868,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
          smoothness->constSortPos = cspPotentialPrimitive;
       }
 
-      matinfo = new Var("PBRConfig", "float4");
-      LangElement* colorDecl = new DecOp(matinfo);
+      pbrConfig = new Var("PBRConfig", "float4");
+      LangElement* colorDecl = new DecOp(pbrConfig);
       meta->addStatement(new GenOp("   @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
    }
 
@@ -903,7 +903,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
    if (!surface)
    {
       surface = new Var("surface", "Surface");
-      meta->addStatement(new GenOp("  @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo,
+      meta->addStatement(new GenOp("  @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig,
          wsPosition, wsEyePos, wsView));
    }
 
@@ -1328,7 +1328,7 @@ void LightmapFeatHLSL::processPix(  Vector<ShaderComponent*> &componentList,
    lightMapTex->texture = true;
    lightMapTex->constNum = lightMap->constNum;
    
-   // argh, pixel specular should prob use this too
+   // argh, PBRConfigMap should prob use this too
    if( fd.features[MFT_NormalMap] )
    {
       Var *lmColor = new Var;
@@ -3135,12 +3135,6 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
 
    Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
 
-   Var *matinfo = (Var*)LangElement::find("PBRConfig");
-   Var* metalness = (Var*)LangElement::find("metalness");
-   Var* smoothness = (Var*)LangElement::find("smoothness");
-   
-   Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
-
    //Reflection vec
    Var* ibl = (Var*)LangElement::find("ibl");
    if (!ibl)

+ 4 - 7
Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp

@@ -27,7 +27,6 @@
 #include "shaderGen/HLSL/shaderFeatureHLSL.h"
 #include "shaderGen/featureMgr.h"
 #include "shaderGen/HLSL/bumpHLSL.h"
-#include "shaderGen/HLSL/pixSpecularHLSL.h"
 #include "shaderGen/HLSL/depthHLSL.h"
 #include "shaderGen/HLSL/debugVizFeatureHLSL.h"
 #include "shaderGen/HLSL/paraboloidHLSL.h"
@@ -71,9 +70,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
    FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) );
    FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL );
    FEATUREMGR->registerFeature( MFT_Fog, new FogFeatHLSL );
-   FEATUREMGR->registerFeature( MFT_SpecularMap, new SpecularMapHLSL );
    FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatHLSL );
-   FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) );
    FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) );
    FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget1 ) );
    FEATUREMGR->registerFeature( MFT_RenderTarget2_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget2 ) );
@@ -107,10 +104,10 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
    FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );
 
    FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
-   FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapHLSL );
-   FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsHLSL );
-   FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsHLSL );
-   FEATUREMGR->registerFeature( MFT_DeferredEmissive, new DeferredEmissiveHLSL);
+   FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL);
+   FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL);
+   FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL );
+   FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapHLSL);
    FEATUREMGR->registerFeature( MFT_SkyBox,  new NamedFeatureHLSL( "skybox" ) );
    FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureHLSL );
 }

+ 2 - 1
Engine/source/shaderGen/shaderGenVars.cpp

@@ -73,9 +73,10 @@ const String ShaderGenVars::vectorLightDirection("$vectorLightDirection");
 const String ShaderGenVars::vectorLightColor("$vectorLightColor");
 const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness");
 
-const String ShaderGenVars::specularColor("$specularColor");
+const String ShaderGenVars::pbrConfig("$PBRConfig");
 const String ShaderGenVars::smoothness("$smoothness");
 const String ShaderGenVars::metalness("$metalness");
+const String ShaderGenVars::glowMul("$glowMul");
 
 //Reflection Probes
 const String ShaderGenVars::probePosition("$inProbePosArray");

+ 2 - 1
Engine/source/shaderGen/shaderGenVars.h

@@ -85,9 +85,10 @@ struct ShaderGenVars
    const static String vectorLightColor;
    const static String vectorLightBrightness;
 
-   const static String specularColor;
+   const static String pbrConfig;
    const static String smoothness;
    const static String metalness;
+   const static String glowMul;
 
    //Reflection Probes
    const static String probePosition;

+ 2 - 4
Engine/source/terrain/glsl/terrFeatureGLSL.cpp

@@ -1298,14 +1298,12 @@ ShaderFeature::Resources TerrainCompositeMapFeatGLSL::getResources(const Materia
 }
 
 
-//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled.
-//we'll most likely revisit that later. possibly several ways...
-
 U32 TerrainBlankInfoMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
 {
    return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
 }
 
+// reminder, the matinfo buffer is flags, smooth, ao, metal
 void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
    const MaterialFeatureData &fd)
 {
@@ -1328,7 +1326,7 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
       material->setStructName("OUT");
    }
 
-   meta->addStatement(new GenOp("   @ = vec4(0.0,1.0,0.0,0.0001);\r\n", material));
+   meta->addStatement(new GenOp("   @ = vec4(0.0,0.0,1.0,0);\r\n", material));
 
    output = meta;
 }

+ 2 - 4
Engine/source/terrain/hlsl/terrFeatureHLSL.cpp

@@ -1315,9 +1315,7 @@ ShaderFeature::Resources TerrainCompositeMapFeatHLSL::getResources(const Materia
    return res;
 }
 
-//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled.
-//we'll most likely revisit that later. possibly several ways...
-
+// reminder, the matinfo buffer is flags, smooth, ao, metal
 U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
 {
    return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
@@ -1345,7 +1343,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
       material->setStructName("OUT");
    }
 
-   meta->addStatement(new GenOp("   @ = float4(0.0,1.0,0.0,0.0001);\r\n", material));
+   meta->addStatement(new GenOp("   @ = float4(0.0,0.0,1.0,0);\r\n", material));
 
    output = meta;
 }

+ 0 - 3
Engine/source/ts/collada/colladaAppMaterial.cpp

@@ -86,7 +86,6 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
    // Get the <profile_COMMON>, <diffuse> and <specular> elements
    const domProfile_COMMON* commonProfile = ColladaUtils::findEffectCommonProfile(effect);
    const domCommon_color_or_texture_type_complexType* domDiffuse = findEffectDiffuse(effect);
-   const domCommon_color_or_texture_type_complexType* domSpecular = findEffectSpecular(effect);
 
    // Wrap flags
    if (effectExt->wrapU)
@@ -158,7 +157,6 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
    // Get the paths for the various textures => Collada indirection at its finest!
    // <texture>.<newparam>.<sampler2D>.<source>.<newparam>.<surface>.<init_from>.<image>.<init_from>
    diffuseMap = getSamplerImagePath(effect, getTextureSampler(effect, domDiffuse));
-   specularMap = getSamplerImagePath(effect, getTextureSampler(effect, domSpecular));
    normalMap = getSamplerImagePath(effect, effectExt->bumpSampler);
 
    // Set the material name
@@ -218,7 +216,6 @@ Material *ColladaAppMaterial::createMaterial(const Torque::Path& path) const
 
    newMat->mDiffuseMapFilename[0] = diffuseMap;
    newMat->mNormalMapFilename[0] = normalMap;
-   newMat->mSpecularMapFilename[0] = specularMap;
 
    newMat->mDiffuse[0] = diffuseColor;
    newMat->mSmoothness[0] = smoothness;

+ 0 - 1
Engine/source/ts/collada/colladaAppMaterial.h

@@ -43,7 +43,6 @@ public:
    // Settings extracted from the Collada file, and optionally saved to materials.cs
    String                     diffuseMap;
    String                     normalMap;
-   String                     specularMap;
 
    LinearColorF               diffuseColor;
    LinearColorF               specularColor;

+ 0 - 1
Engine/source/ts/collada/colladaShapeLoader.cpp

@@ -499,7 +499,6 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
 
          copySketchupTexture(path, mat->mDiffuseMapFilename[0]);
          copySketchupTexture(path, mat->mNormalMapFilename[0]);
-         copySketchupTexture(path, mat->mSpecularMapFilename[0]);
       }
    }
 

+ 2 - 3
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs

@@ -393,10 +393,9 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem)
          %file.writeline("   AOMap[0] = \"" @ %AOAssetPath @"\";");
          %file.writeline("   AOMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.AOImageAsset.assetName @"\";");
       }
-      if(%assetItem.compositeImageAsset)
+      if(%assetItem.PBRConfigMapImageAsset)
       {
-         %compAssetPath = %assetPath @ fileName(%assetItem.compositeImageAsset.filePath);
-         %file.writeline("   PBRConfigMap[0] = \"" @ %compAssetPath @"\";");
+         %file.writeline("   PBRConfigMap[0] = \"" @ %assetItem.compositeImageAsset.filePath @"\";");
          %file.writeline("   PBRConfigMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.compositeImageAsset.assetName @"\";");
       }
       %file.writeline("};");

+ 363 - 132
Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui

@@ -566,6 +566,132 @@
                      Visible = "1";
                      tooltipprofile = "ToolsGuiToolTipProfile";
                      hovertime = "1000";
+                     
+                     new GuiContainer(){
+                        profile = "ToolsGuiTransparentProfile";
+                        isContainer = "1";
+                        position = "0 0";
+                        Extent = "185 50";
+                        HorizSizing = "width";
+						
+                        new GuiTextCtrl() {
+                           HorizSizing = "right";
+                           VertSizing = "bottom";
+                           position = "9 4";
+                           Extent = "72 16";
+                           text = "Smoothness";
+                           Profile = "ToolsGuiTextProfile";
+                        };                        
+                        
+                        new GuiTextCtrl() {
+                           HorizSizing = "right";
+                           VertSizing = "bottom";
+                           position = "9 26";
+                           Extent = "72 16";
+                           text = "Metalness";
+                           Profile = "ToolsGuiTextProfile";
+                        };
+                        
+                        new GuiControl() {
+                           class = "AggregateControl";
+                           position = "91 4";
+                           Extent = "96 20";
+                           
+                           new GuiSliderCtrl() {
+                              canSaveDynamicFields = "0";
+                              internalName = "SmoothnessSlider";
+                              Enabled = "1";
+                              isContainer = "0";
+                              Profile = "ToolsGuiSliderProfile";
+                              HorizSizing = "right";
+                              VertSizing = "bottom";
+                              position = "0 1";
+                              Extent = "61 14";
+                              MinExtent = "8 2";
+                              canSave = "1";
+                              Visible = "1";
+                              Command = "MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);";
+                              AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);";
+                              tooltipprofile = "ToolsGuiDefaultProfile";
+                              ToolTip = "Sets Smoothness.";
+                              hovertime = "1000";
+                              range = "0 1";
+                              ticks = "0";
+                              value = "0";
+                           };
+                           new GuiTextEditCtrl() {
+                              canSaveDynamicFields = "0";
+                              internalName = "SmoothnessTextEdit";
+                              Enabled = "1";
+                              isContainer = "0";
+                              Profile = "ToolsGuiTextEditProfile";
+                              HorizSizing = "right";
+                              VertSizing = "bottom";
+                              position = "64 0";
+                              Extent = "29 18";
+                              MinExtent = "8 2";
+                              canSave = "1";
+                              Visible = "1";
+                              Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
+                              hovertime = "1000";
+                              AnchorTop = "1";
+                              AnchorBottom = "0";
+                              AnchorLeft = "1";
+                              AnchorRight = "0";
+                              text = "0";
+                           };
+                        };
+
+                        new GuiControl() {
+                           class = "AggregateControl";
+                           position = "91 26";
+                           Extent = "96 20";
+
+                           new GuiSliderCtrl() {
+                              canSaveDynamicFields = "0";
+                              internalName = "MetalnessSlider";
+                              Enabled = "1";
+                              isContainer = "0";
+                              Profile = "ToolsGuiSliderProfile";
+                              HorizSizing = "right";
+                              VertSizing = "bottom";
+                              position = "0 1";
+                              Extent = "61 14";
+                              MinExtent = "8 2";
+                              canSave = "1";
+                              Visible = "1";
+                              Command = "MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);";
+                              AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);";
+                              tooltipprofile = "ToolsGuiDefaultProfile";
+                              ToolTip = "Sets Metalness.";
+                              hovertime = "1000";
+                              range = "0 1";
+                              ticks = "0";
+                              value = "0";
+                           };
+                           new GuiTextEditCtrl() {
+                              canSaveDynamicFields = "0";
+                              internalName = "MetalnessTextEdit";
+                              Enabled = "1";
+                              isContainer = "0";
+                              Profile = "ToolsGuiTextEditProfile";
+                              HorizSizing = "right";
+                              VertSizing = "bottom";
+                              position = "64 0";
+                              Extent = "29 18";
+                              MinExtent = "8 2";
+                              canSave = "1";
+                              Visible = "1";
+                              Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
+                              hovertime = "1000";
+                              AnchorTop = "1";
+                              AnchorBottom = "0";
+                              AnchorLeft = "1";
+                              AnchorRight = "0";
+                              text = "0";
+                           };
+                        };
+                     };
 					 
                      new GuiContainer(){ // spec Map options
                         profile="ToolsGuiDefaultProfile";
@@ -605,7 +731,7 @@
                            HorizSizing = "right";
                            VertSizing = "bottom";
                            position = "70 2";
-                           Extent = "57 16";
+                           Extent = "107 16";
                            MinExtent = "8 2";
                            canSave = "1";
                            Visible = "1";
@@ -646,7 +772,7 @@
                         
                         new GuiBitmapCtrl() {
                            canSaveDynamicFields = "0";
-                           internalName = "specMapDisplayBitmap";
+                           internalName = "PBRConfigMapDisplayBitmap";
                            Enabled = "1";
                            isContainer = "0";
                            Profile = "ToolsGuiDefaultProfile";
@@ -680,7 +806,7 @@
                            AnchorBottom = "0";
                            AnchorLeft = "1";
                            AnchorRight = "0";
-                           text = "Composite Map";
+                           text = "PBR Config Map";
                            maxLength = "1024";
                         };
                         new GuiBitmapButtonCtrl() {
@@ -695,7 +821,7 @@
                            MinExtent = "8 2";
                            canSave = "1";
                            Visible = "1";
-                           Command = "MaterialEditorGui.updateSpecMap(1);";
+                           Command = "MaterialEditorGui.updatePBRConfigMap(1);";
                            tooltipprofile = "ToolsGuiDefaultProfile";
                            ToolTip = "Change the packed spec map for this layer. \n Smoothness (R), Ambient Occlusion (G), and Metalness(B))";
                            hovertime = "1000";
@@ -706,7 +832,7 @@
                         };
                         new GuiTextCtrl() {
                            canSaveDynamicFields = "0";
-                           internalName = "specMapNameText";
+                           internalName = "PBRConfigMapNameText";
                            Enabled = "1";
                            isContainer = "0";
                            Profile = "ToolsGuiTextProfile";
@@ -735,7 +861,7 @@
                            position = "134 34";
                            Extent = "40 16";
                            buttonType = "PushButton";
-                           command="MaterialEditorGui.updateSpecMap(1);";
+                           command="MaterialEditorGui.updatePBRConfigMap(1);";
                         };
                         new GuiBitmapButtonCtrl() {
                            canSaveDynamicFields = "0";
@@ -749,7 +875,7 @@
                            MinExtent = "8 2";
                            canSave = "1";
                            Visible = "1";
-                           Command = "MaterialEditorGui.updateSpecMap(0);";
+                           Command = "MaterialEditorGui.updatePBRConfigMap(0);";
                            hovertime = "1000";
                            groupNum = "-1";
                            buttonType = "PushButton";
@@ -1552,6 +1678,236 @@
 						 canSaveDynamicFields = "0";
 					  };
 				    };
+				   new GuiBitmapCtrl() {
+					  bitmap = "tools/gui/images/separator-v";
+					  wrap = "0";
+					  position = "6 75";
+					  extent = "175 2";
+					  minExtent = "8 2";
+					  horizSizing = "width";
+					  vertSizing = "bottom";
+					  profile = "ToolsGuiButtonProfile";
+					  visible = "1";
+					  active = "1";
+					  tooltipProfile = "GuiToolTipProfile";
+					  hovertime = "1000";
+					  isContainer = "0";
+					  canSave = "1";
+					  canSaveDynamicFields = "0";
+				   };
+				   new GuiContainer() {
+					  margin = "0 0 0 0";
+					  padding = "0 0 0 0";
+					  anchorTop = "1";
+					  anchorBottom = "0";
+					  anchorLeft = "1";
+					  anchorRight = "0";
+					  position = "6 364";
+					  extent = "185 67";
+					  minExtent = "8 2";
+					  horizSizing = "width";
+					  vertSizing = "bottom";
+					  profile = "GuiDefaultProfile";
+					  visible = "1";
+					  active = "1";
+					  tooltipProfile = "GuiToolTipProfile";
+					  hovertime = "1000";
+					  isContainer = "1";
+					  canSave = "1";
+					  canSaveDynamicFields = "0";
+					  new GuiBitmapCtrl() {
+						 bitmap = "tools/materialeditor/gui/unknownImage";
+						 wrap = "0";
+						 position = "1 1";
+						 extent = "48 48";
+						 minExtent = "8 2";
+						 horizSizing = "right";
+						 vertSizing = "bottom";
+						 profile = "ToolsGuiButtonProfile";
+						 visible = "1";
+						 active = "1";
+						 tooltipProfile = "GuiToolTipProfile";
+						 hovertime = "1000";
+						 isContainer = "0";
+						 internalName = "glowMapDisplayBitmap";
+						 canSave = "1";
+						 canSaveDynamicFields = "0";
+					  };
+					  new GuiTextCtrl() {
+						 text = "glow";
+						 maxLength = "1024";
+						 margin = "0 0 0 0";
+						 padding = "0 0 0 0";
+						 anchorTop = "1";
+						 anchorBottom = "0";
+						 anchorLeft = "1";
+						 anchorRight = "0";
+						 position = "56 5";
+						 extent = "35 8";
+						 minExtent = "8 2";
+						 horizSizing = "right";
+						 vertSizing = "bottom";
+						 profile = "ToolsGuiTextProfile";
+						 visible = "1";
+						 active = "1";
+						 tooltipProfile = "GuiToolTipProfile";
+						 hovertime = "1000";
+						 isContainer = "0";
+						 canSave = "1";
+						 canSaveDynamicFields = "0";
+					  };
+					  new GuiBitmapButtonCtrl() {
+						 bitmap = "tools/materialEditor/gui/cubemapBtnBorder";
+						 bitmapMode = "Stretched";
+						 autoFitExtents = "0";
+						 useModifiers = "0";
+						 useStates = "1";
+						 groupNum = "-1";
+						 buttonType = "PushButton";
+						 useMouseEvents = "0";
+						 position = "1 1";
+						 extent = "48 48";
+						 minExtent = "8 2";
+						 horizSizing = "right";
+						 vertSizing = "bottom";
+						 profile = "ToolsGuiButtonProfile";
+						 visible = "1";
+						 active = "1";
+						 command = "MaterialEditorGui.updateglowMap(1);";
+						 tooltipProfile = "GuiToolTipProfile";
+						 tooltip = "Change the glowness Map for this layer.";
+						 hovertime = "1000";
+						 isContainer = "0";
+						 canSave = "1";
+						 canSaveDynamicFields = "0";
+					  };
+					  new GuiTextCtrl() {
+						 text = "None";
+						 maxLength = "1024";
+						 margin = "0 0 0 0";
+						 padding = "0 0 0 0";
+						 anchorTop = "1";
+						 anchorBottom = "0";
+						 anchorLeft = "1";
+						 anchorRight = "0";
+						 position = "56 17";
+						 extent = "143 17";
+						 minExtent = "8 2";
+						 horizSizing = "width";
+						 vertSizing = "bottom";
+						 profile = "ToolsGuiTextProfile";
+						 visible = "1";
+						 active = "1";
+						 tooltipProfile = "GuiToolTipProfile";
+						 hovertime = "1000";
+						 isContainer = "0";
+						 internalName = "glowMapNameText";
+						 canSave = "1";
+						 canSaveDynamicFields = "0";
+					  };
+					  new GuiButtonCtrl() {
+						 text = "Edit";
+						 groupNum = "-1";
+						 buttonType = "PushButton";
+						 useMouseEvents = "0";
+						 position = "134 34";
+						 extent = "40 16";
+						 minExtent = "8 2";
+						 horizSizing = "left";
+						 vertSizing = "bottom";
+						 profile = "ToolsGuiButtonProfile";
+						 visible = "1";
+						 active = "1";
+						 command = "MaterialEditorGui.updateglowMap(1);";
+						 tooltipProfile = "GuiToolTipProfile";
+						 hovertime = "1000";
+						 isContainer = "0";
+						 canSave = "1";
+						 canSaveDynamicFields = "0";
+					  };
+					  new GuiBitmapButtonCtrl() {
+						 bitmap = "tools/gui/images/delete";
+						 bitmapMode = "Stretched";
+						 autoFitExtents = "0";
+						 useModifiers = "0";
+						 useStates = "1";
+						 groupNum = "-1";
+						 buttonType = "PushButton";
+						 useMouseEvents = "0";
+						 position = "177 34";
+						 extent = "16 16";
+						 minExtent = "8 2";
+						 horizSizing = "left";
+						 vertSizing = "bottom";
+						 profile = "ToolsGuiButtonProfile";
+						 visible = "1";
+						 active = "1";
+						 command = "MaterialEditorGui.updateglowMap(0);";
+						 tooltipProfile = "GuiToolTipProfile";
+						 hovertime = "1000";
+						 isContainer = "0";
+						 canSave = "1";
+						 canSaveDynamicFields = "0";
+					  };
+                        new GuiTextCtrl() {
+                           HorizSizing = "right";
+                           VertSizing = "bottom";
+                           position = "9 48";
+                           Extent = "72 16";
+                           text = "GlowMul";
+                           Profile = "ToolsGuiTextProfile";
+                        };
+                        
+                        new GuiControl() {
+                           class = "AggregateControl";
+                           position = "91 48";
+                           Extent = "96 20";
+                           
+                           new GuiSliderCtrl() {
+                              canSaveDynamicFields = "0";
+                              internalName = "GlowMulSlider";
+                              Enabled = "1";
+                              isContainer = "0";
+                              Profile = "ToolsGuiSliderProfile";
+                              HorizSizing = "right";
+                              VertSizing = "bottom";
+                              position = "0 1";
+                              Extent = "61 14";
+                              MinExtent = "8 2";
+                              canSave = "1";
+                              Visible = "1";
+                              Command = "MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);";
+                              AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);";
+                              tooltipprofile = "ToolsGuiDefaultProfile";
+                              ToolTip = "Sets GlowMul.";
+                              hovertime = "1000";
+                              range = "0 20";
+                              ticks = "0";
+                              value = "0";
+                           };
+                           new GuiTextEditCtrl() {
+                              canSaveDynamicFields = "0";
+                              internalName = "GlowMulTextEdit";
+                              Enabled = "1";
+                              isContainer = "0";
+                              Profile = "ToolsGuiTextEditProfile";
+                              HorizSizing = "right";
+                              VertSizing = "bottom";
+                              position = "64 0";
+                              Extent = "29 18";
+                              MinExtent = "8 2";
+                              canSave = "1";
+                              Visible = "1";
+                              Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
+                              hovertime = "1000";
+                              AnchorTop = "1";
+                              AnchorBottom = "0";
+                              AnchorLeft = "1";
+                              AnchorRight = "0";
+                              text = "0";
+                           };
+                        };
+				    };
 				  };
                };
                new GuiRolloutCtrl(advancedTextureMapsRollout) {
@@ -2767,131 +3123,6 @@
                      tooltipprofile = "ToolsGuiToolTipProfile";
                      hovertime = "1000";
                   
-                     new GuiContainer(){ // specular
-                        profile = "ToolsGuiTransparentProfile";
-                        isContainer = "1";
-                        position = "0 0";
-                        Extent = "185 44";
-                        HorizSizing = "width";
-						
-                        new GuiTextCtrl() {
-                           profile = "ToolsGuiTextProfile";
-                           HorizSizing = "right";
-                           VertSizing = "bottom";
-                           position = "9 4";
-                           Extent = "72 16";
-                           text = "Smoothness";
-                        };                        
-                        
-                        new GuiTextCtrl() {
-                           profile = "ToolsGuiTextProfile";
-                           HorizSizing = "right";
-                           VertSizing = "bottom";
-                           position = "9 26";
-                           Extent = "72 16";
-                           text = "Metalness";
-                        };
-
-                        new GuiControl() {
-                           class = "AggregateControl";
-                           position = "91 4";
-                           Extent = "96 20";
-                           
-                           new GuiSliderCtrl() {
-                              canSaveDynamicFields = "0";
-                              internalName = "SmoothnessSlider";
-                              Enabled = "1";
-                              isContainer = "0";
-                              Profile = "ToolsGuiSliderProfile";
-                              HorizSizing = "right";
-                              VertSizing = "bottom";
-                              position = "0 1";
-                              Extent = "61 14";
-                              MinExtent = "8 2";
-                              canSave = "1";
-                              Visible = "1";
-                              Command = "MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);";
-                              AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);";
-                              tooltipprofile = "ToolsGuiDefaultProfile";
-                              ToolTip = "Sets Smoothness.";
-                              hovertime = "1000";
-                              range = "0 1";
-                              ticks = "0";
-                              value = "0";
-                           };
-                           new GuiTextEditCtrl() {
-                              canSaveDynamicFields = "0";
-                              internalName = "SmoothnessTextEdit";
-                              Enabled = "1";
-                              isContainer = "0";
-                              Profile = "ToolsGuiTextEditProfile";
-                              HorizSizing = "right";
-                              VertSizing = "bottom";
-                              position = "64 0";
-                              Extent = "29 18";
-                              MinExtent = "8 2";
-                              canSave = "1";
-                              Visible = "1";
-                              Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
-                              hovertime = "1000";
-                              AnchorTop = "1";
-                              AnchorBottom = "0";
-                              AnchorLeft = "1";
-                              AnchorRight = "0";
-                              text = "0";
-                           };
-                        };
-
-                        new GuiControl() {
-                           class = "AggregateControl";
-                           position = "91 26";
-                           Extent = "96 20";
-
-                           new GuiSliderCtrl() {
-                              canSaveDynamicFields = "0";
-                              internalName = "MetalnessSlider";
-                              Enabled = "1";
-                              isContainer = "0";
-                              Profile = "ToolsGuiSliderProfile";
-                              HorizSizing = "right";
-                              VertSizing = "bottom";
-                              position = "0 1";
-                              Extent = "61 14";
-                              MinExtent = "8 2";
-                              canSave = "1";
-                              Visible = "1";
-                              Command = "MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);";
-                              AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);";
-                              tooltipprofile = "ToolsGuiDefaultProfile";
-                              ToolTip = "Sets Metalness.";
-                              hovertime = "1000";
-                              range = "0 1";
-                              ticks = "0";
-                              value = "0";
-                           };
-                           new GuiTextEditCtrl() {
-                              canSaveDynamicFields = "0";
-                              internalName = "MetalnessTextEdit";
-                              Enabled = "1";
-                              isContainer = "0";
-                              Profile = "ToolsGuiTextEditProfile";
-                              HorizSizing = "right";
-                              VertSizing = "bottom";
-                              position = "64 0";
-                              Extent = "29 18";
-                              MinExtent = "8 2";
-                              canSave = "1";
-                              Visible = "1";
-                              Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
-                              hovertime = "1000";
-                              AnchorTop = "1";
-                              AnchorBottom = "0";
-                              AnchorLeft = "1";
-                              AnchorRight = "0";
-                              text = "0";
-                           };
-                        };
-                     };
                      new GuiContainer(){ // glow emissive
                         profile = "ToolsGuiTransparentProfile";
                         isContainer = "1";

+ 81 - 19
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs

@@ -590,9 +590,9 @@ function MaterialEditorGui::convertTextureFields(%this)
    
    for(%specI = 0; %specI < 4; %specI++)
    {
-      %specMap = MaterialEditorGui.currentMaterial.specularMap[%specI];      
-      %specMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %specMap);
-      MaterialEditorGui.currentMaterial.specularMap[%specI] = %specMap;
+      %PBRConfigMap = MaterialEditorGui.currentMaterial.PBRConfigMap[%specI];      
+      %PBRConfigMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %PBRConfigMap);
+      MaterialEditorGui.currentMaterial.PBRConfigMap[%specI] = %PBRConfigMap;
    }
    
    for(%roughI = 0; %roughI < 4; %roughI++)
@@ -615,6 +615,13 @@ function MaterialEditorGui::convertTextureFields(%this)
       %metalMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %metalMap);
       MaterialEditorGui.currentMaterial.metalMap[%metalI] = %metalMap;
    }
+   
+   for(%glowI = 0; %glowI < 4; %glowI++)
+   {
+      %glowMap = MaterialEditorGui.currentMaterial.glowMap[%glowI];      
+      %glowMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %glowMap);
+      MaterialEditorGui.currentMaterial.glowMap[%glowI] = %glowMap;
+   }
 }
 
 // still needs to be optimized further
@@ -901,15 +908,15 @@ function MaterialEditorGui::guiSync( %this, %material )
    MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]);
    MaterialEditorPropertiesWindow-->invertSmoothnessCheckbox.setValue((%material).invertSmoothness[%layer]);
       
-   if((%material).specularMap[%layer] $= "") 
+   if((%material).PBRConfigMap[%layer] $= "") 
    {
-      MaterialEditorPropertiesWindow-->specMapNameText.setText( "None" );
-      MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
+      MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText( "None" );
+      MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
    }
    else
    {
-      MaterialEditorPropertiesWindow-->specMapNameText.setText( (%material).specularMap[%layer] );
-      MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap( (%material).specularMap[%layer] );
+      MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText( (%material).PBRConfigMap[%layer] );
+      MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap( (%material).PBRConfigMap[%layer] );
    }
    
    if((%material).roughMap[%layer] $= "") 
@@ -945,6 +952,17 @@ function MaterialEditorGui::guiSync( %this, %material )
       MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( (%material).metalMap[%layer] );
    }
    
+   if((%material).glowMap[%layer] $= "") 
+   {
+      MaterialEditorPropertiesWindow-->glowMapNameText.setText( "None" );
+      MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( "tools/materialeditor/gui/unknownImage" );
+   }
+   else
+   {
+      MaterialEditorPropertiesWindow-->glowMapNameText.setText( (%material).glowMap[%layer] );
+      MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( (%material).glowMap[%layer] );
+   }
+   
    MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]);
    MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]);
    MaterialEditorPropertiesWindow-->accuDirectionTextEdit.setText((%material).accuDirection[%layer]);
@@ -966,6 +984,8 @@ function MaterialEditorGui::guiSync( %this, %material )
    MaterialEditorPropertiesWindow-->SmoothnessSlider.setValue((%material).Smoothness[%layer]);
    MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]);
    MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]);
+   MaterialEditorPropertiesWindow-->glowMulTextEdit.setText((%material).glowMul[%layer]);
+   MaterialEditorPropertiesWindow-->glowMulSlider.setValue((%material).glowMul[%layer]);
    MaterialEditorPropertiesWindow-->glowCheckbox.setValue((%material).glow[%layer]);
    MaterialEditorPropertiesWindow-->emissiveCheckbox.setValue((%material).emissive[%layer]);
    MaterialEditorPropertiesWindow-->parallaxTextEdit.setText((%material).parallaxScale[%layer]);
@@ -1040,6 +1060,7 @@ function MaterialEditorGui::guiSync( %this, %material )
    %this.getRoughChan((%material).SmoothnessChan[%layer]);
    %this.getAOChan((%material).AOChan[%layer]);
    %this.getMetalChan((%material).metalChan[%layer]);
+   %this.getGlowChan((%material).glowChan[%layer]);
    %this.preventUndo = false;
 }
 
@@ -1061,6 +1082,11 @@ function MaterialEditorGui::getMetalChan(%this, %channel)
 	%guiElement = metalChanBtn @ %channel;
 	%guiElement.setStateOn(true);
 }
+function MaterialEditorGui::getGlowChan(%this, %channel)
+{
+	%guiElement = glowChanBtn @ %channel;
+	%guiElement.setStateOn(true);
+}
 //=======================================
 // Material Update Functionality
 
@@ -1242,7 +1268,7 @@ function MaterialEditorGui::updateDetailNormalStrength(%this,%newStrength)
    MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength);
 }
 
-function MaterialEditorGui::updateSpecMap(%this,%action)
+function MaterialEditorGui::updatePBRConfigMap(%this,%action)
 {
    %layer = MaterialEditorGui.currentLayer;
    
@@ -1253,20 +1279,20 @@ function MaterialEditorGui::updateSpecMap(%this,%action)
       {
          MaterialEditorGui.updateActiveMaterial("pixelSpecular[" @ MaterialEditorGui.currentLayer @ "]", 0);
          
-         MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap(%texture);
+         MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap(%texture);
       
-         %bitmap = MaterialEditorPropertiesWindow-->specMapDisplayBitmap.bitmap;
+         %bitmap = MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.bitmap;
          %bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
-         MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap(%bitmap);
-         MaterialEditorPropertiesWindow-->specMapNameText.setText(%bitmap);
-         MaterialEditorGui.updateActiveMaterial("specularMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
+         MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap(%bitmap);
+         MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText(%bitmap);
+         MaterialEditorGui.updateActiveMaterial("PBRConfigMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
       }
    }
    else
    {
-      MaterialEditorPropertiesWindow-->specMapNameText.setText("None");
-      MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage");
-      MaterialEditorGui.updateActiveMaterial("specularMap[" @ %layer @ "]","");
+      MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText("None");
+      MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage");
+      MaterialEditorGui.updateActiveMaterial("PBRConfigMap[" @ %layer @ "]","");
    }
    
    MaterialEditorGui.guiSync( materialEd_previewMaterial );
@@ -1356,6 +1382,34 @@ function MaterialEditorGui::updatemetalMap(%this,%action)
    MaterialEditorGui.guiSync( materialEd_previewMaterial );
 }
 
+function MaterialEditorGui::updateGlowMap(%this,%action)
+{
+   %layer = MaterialEditorGui.currentLayer;
+   
+   if( %action )
+   {
+      %texture = MaterialEditorGui.openFile("texture");
+      if( %texture !$= "" )
+      {         
+         MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap(%texture);
+      
+         %bitmap = MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.bitmap;
+         %bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
+         MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap(%bitmap);
+         MaterialEditorPropertiesWindow-->GlowMapNameText.setText(%bitmap);
+         MaterialEditorGui.updateActiveMaterial("glowMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
+      }
+   }
+   else
+   {
+      MaterialEditorPropertiesWindow-->GlowMapNameText.setText("None");
+      MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap("tools/materialeditor/gui/unknownImage");
+      MaterialEditorGui.updateActiveMaterial("glowMap[" @ %layer @ "]","");
+   }
+   
+   MaterialEditorGui.guiSync( materialEd_previewMaterial );
+}
+
 function MaterialEditorGui::updateRotationOffset(%this, %isSlider, %onMouseUp)
 {
    %layer = MaterialEditorGui.currentLayer;
@@ -2478,6 +2532,12 @@ function MaterialEditorGui::setMetalChan(%this, %value)
    MaterialEditorGui.guiSync( materialEd_previewMaterial );
 }
 
+function MaterialEditorGui::setGlowChan(%this, %value)
+{
+   MaterialEditorGui.updateActiveMaterial("glowChan[" @ MaterialEditorGui.currentLayer @ "]", %value);   
+   MaterialEditorGui.guiSync( materialEd_previewMaterial );
+}
+
 function MaterialEditorGui::saveCompositeMap(%this)
 {
     %saveAs = "";
@@ -2503,13 +2563,15 @@ function MaterialEditorGui::saveCompositeMap(%this)
     %roughMap = %material.roughMap[%layer];
     %aoMap = %material.aoMap[%layer];
     %metalMap = %material.metalMap[%layer];
+    %glowMap = %material.glowMap[%layer];
     
     %smooth = %material.SmoothnessChan[%layer];
     %ao = %material.AOChan[%layer];
     %metal = %material.metalChan[%layer];
+    %glow = %material.glowChan[%layer];
     
-    %channelKey = %smooth SPC %ao SPC %metal SPC 3;
+    %channelKey = %smooth SPC %ao SPC %metal SPC %glow;
     error("Storing: \"" @ %roughMap @"\" \""@  %aoMap @"\" \""@ %metalMap @"\" \""@ %channelKey @"\" \""@ %saveAs @"\"");
-    saveCompositeTexture(%roughMap,%aoMap,%metalMap,"",%channelKey, %saveAs);
+    saveCompositeTexture(%roughMap,%aoMap,%metalMap,%glowMap,%channelKey, %saveAs);
     %dlg.delete();
 }

+ 176 - 0
Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui

@@ -1257,6 +1257,182 @@
                canSave = "1";
                canSaveDynamicFields = "0";
             };
+            new GuiContainer() {
+               margin = "0 0 0 0";
+               padding = "0 0 0 0";
+               anchorTop = "1";
+               anchorBottom = "0";
+               anchorLeft = "1";
+               anchorRight = "0";
+               position = "6 216";
+               extent = "174 53";
+               minExtent = "8 2";
+               horizSizing = "width";
+               vertSizing = "bottom";
+               profile = "ToolsGuiDefaultProfile";
+               visible = "1";
+               active = "1";
+               tooltipProfile = "ToolsGuiToolTipProfile";
+               hovertime = "1000";
+               isContainer = "1";
+               canSave = "1";
+               canSaveDynamicFields = "0";
+
+               new GuiBitmapCtrl() {
+                  bitmap = "tools/materialEditor/gui/unknownImage";
+                  color = "255 255 255 255";
+                  wrap = "0";
+                  position = "1 1";
+                  extent = "47 47";
+                  minExtent = "8 2";
+                  horizSizing = "right";
+                  vertSizing = "bottom";
+                  profile = "ToolsGuiDefaultProfile";
+                  visible = "1";
+                  active = "1";
+                  tooltipProfile = "ToolsGuiToolTipProfile";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  internalName = "compositeTexCtrl";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+               new GuiBitmapButtonCtrl() {
+                  bitmap = "tools/materialEditor/gui/cubemapBtnBorder";
+                  bitmapMode = "Stretched";
+                  autoFitExtents = "0";
+                  useModifiers = "0";
+                  useStates = "1";
+                  masked = "0";
+                  groupNum = "-1";
+                  buttonType = "PushButton";
+                  useMouseEvents = "0";
+                  position = "1 1";
+                  extent = "48 48";
+                  minExtent = "8 2";
+                  horizSizing = "right";
+                  vertSizing = "bottom";
+                  profile = "ToolsGuiDefaultProfile";
+                  visible = "1";
+                  active = "1";
+                  command = "TerrainMaterialDlg.changecomposite();";
+                  tooltipProfile = "ToolsGuiDefaultProfile";
+                  tooltip = "Change the active composite Map for this layer.";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+               new GuiTextCtrl() {
+                  text = "Composite";
+                  maxLength = "1024";
+                  margin = "0 0 0 0";
+                  padding = "0 0 0 0";
+                  anchorTop = "1";
+                  anchorBottom = "0";
+                  anchorLeft = "1";
+                  anchorRight = "0";
+                  position = "56 -3";
+                  extent = "61 18";
+                  minExtent = "8 2";
+                  horizSizing = "right";
+                  vertSizing = "bottom";
+                  profile = "EditorTextProfile";
+                  visible = "1";
+                  active = "1";
+                  tooltipProfile = "ToolsGuiToolTipProfile";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+               new GuiTextCtrl() {
+                  text = "None";
+                  maxLength = "1024";
+                  margin = "0 0 0 0";
+                  padding = "0 0 0 0";
+                  anchorTop = "1";
+                  anchorBottom = "0";
+                  anchorLeft = "1";
+                  anchorRight = "0";
+                  position = "56 17";
+                  extent = "79 17";
+                  minExtent = "8 2";
+                  horizSizing = "width";
+                  vertSizing = "bottom";
+                  profile = "ToolsGuiTextProfile";
+                  visible = "1";
+                  active = "1";
+                  tooltipProfile = "ToolsGuiToolTipProfile";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+               new GuiButtonCtrl() {
+                  text = "Edit";
+                  groupNum = "-1";
+                  buttonType = "PushButton";
+                  useMouseEvents = "0";
+                  position = "111 0";
+                  extent = "40 16";
+                  minExtent = "8 2";
+                  horizSizing = "left";
+                  vertSizing = "bottom";
+                  profile = "ToolsGuiButtonProfile";
+                  visible = "1";
+                  active = "1";
+                  command = "TerrainMaterialDlg.changecomposite();";
+                  tooltipProfile = "ToolsGuiToolTipProfile";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+               new GuiBitmapButtonCtrl() {
+                  bitmap = "tools/gui/images/delete";
+                  bitmapMode = "Stretched";
+                  autoFitExtents = "0";
+                  useModifiers = "0";
+                  useStates = "1";
+                  masked = "0";
+                  groupNum = "-1";
+                  buttonType = "PushButton";
+                  useMouseEvents = "0";
+                  position = "154 0";
+                  extent = "16 16";
+                  minExtent = "8 2";
+                  horizSizing = "left";
+                  vertSizing = "bottom";
+                  profile = "ToolsGuiDefaultProfile";
+                  visible = "1";
+                  active = "1";
+                  command = "TerrainMaterialDlg-->compositeTexCtrl.setBitmap(\"tools/materialEditor/gui/unknownImage\");";
+                  tooltipProfile = "ToolsGuiToolTipProfile";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+               new GuiBitmapCtrl() {
+                  bitmap = "tools/gui/images/separator-v";
+                  color = "255 255 255 255";
+                  wrap = "0";
+                  position = "4 51";
+                  extent = "148 2";
+                  minExtent = "8 2";
+                  horizSizing = "width";
+                  vertSizing = "bottom";
+                  profile = "ToolsGuiDefaultProfile";
+                  visible = "1";
+                  active = "1";
+                  tooltipProfile = "ToolsGuiToolTipProfile";
+                  hovertime = "1000";
+                  isContainer = "0";
+                  canSave = "1";
+                  canSaveDynamicFields = "0";
+               };
+            };
          };
          new GuiBitmapCtrl() {
             bitmap = "tools/gui/images/separator-v";