فهرست منبع

Added Forward Material debug viz for HLSL(so far) and integrated it back into editor flagging.
Re-added logic to track existing probe shader consts instead of constantly recreating it
Added logic for pre multiplied translucency mode

Areloch 5 سال پیش
والد
کامیت
72ceede272

+ 2 - 1
Engine/source/materials/materialDefinition.cpp

@@ -85,7 +85,8 @@ ImplementEnumType( MaterialBlendOp,
    { Material::Add,          "Add", "Adds the color of the material to the frame buffer with full alpha for each pixel." },
    { Material::AddAlpha,     "AddAlpha", "The color is modulated by the alpha channel before being added to the frame buffer." },
    { Material::Sub,          "Sub", "Subtractive Blending. Reverses the color model, causing dark colors to have a stronger visual effect." },
-   { Material::LerpAlpha,    "LerpAlpha", "Linearly interpolates between Material color and frame buffer color based on alpha." }
+   { Material::LerpAlpha,    "LerpAlpha", "Linearly interpolates between Material color and frame buffer color based on alpha." },
+   { Material::PreMult, "PreMult", "" }
 EndImplementEnumType;
 
 ImplementEnumType( MaterialWaveType,

+ 1 - 0
Engine/source/materials/materialDefinition.h

@@ -111,6 +111,7 @@ public:
       Sub,
       LerpAlpha,     // linear interpolation modulated with alpha channel
       ToneMap,
+      PreMult,
       NumBlendTypes
    };
 

+ 2 - 0
Engine/source/materials/materialFeatureTypes.cpp

@@ -67,6 +67,8 @@ ImplementFeatureType( MFT_GlowMask, MFG_PostLighting, 1.0f, true );
 ImplementFeatureType( MFT_Visibility, MFG_PostLighting, 2.0f, true );
 ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true );
 
+ImplementFeatureType(MFT_DebugViz, MFG_PostProcess, 998.0f, true);
+
 ImplementFeatureType( MFT_HDROut, MFG_PostProcess, 999.0f, true );
 
 ImplementFeatureType( MFT_IsBC3nm, U32(-1), -1, true );

+ 2 - 0
Engine/source/materials/materialFeatureTypes.h

@@ -153,6 +153,8 @@ DeclareFeatureType( MFT_Fog );
 /// dynamic range color into the correct HDR encoded format.
 DeclareFeatureType( MFT_HDROut );
 
+DeclareFeatureType( MFT_DebugViz );
+
 ///
 DeclareFeatureType( MFT_DeferredConditioner );
 DeclareFeatureType( MFT_InterlacedDeferred );

+ 7 - 0
Engine/source/materials/processedMaterial.cpp

@@ -142,6 +142,13 @@ void ProcessedMaterial::_setBlendState(Material::BlendOp blendOp, GFXStateBlockD
          break;
       }
 
+   case Material::PreMult:
+   {
+      desc.blendSrc = GFXBlendOne;
+      desc.blendDest = GFXBlendInvSrcAlpha;
+      break;
+   }
+
    default:
       {
          // default to LerpAlpha

+ 7 - 0
Engine/source/materials/processedShaderMaterial.cpp

@@ -415,6 +415,11 @@ void ProcessedShaderMaterial::_determineFeatures(  U32 stageNum,
          fd.features.addFeature( MFT_NormalMapAtlas );
    }
 
+   if (!fd.features.hasFeature(MFT_ForwardShading))
+   {
+      fd.features.removeFeature(MFT_DebugViz);
+   }
+
    // Grab other features like normal maps, base texture, etc.
    FeatureSet mergeFeatures;
    mStages[stageNum].getFeatureSet( &mergeFeatures );
@@ -513,6 +518,8 @@ void ProcessedShaderMaterial::_determineFeatures(  U32 stageNum,
    //
    fd.features.addFeature( MFT_HDROut );
 
+   fd.features.addFeature(MFT_DebugViz);
+
    // If vertex color is enabled on the material's stage and
    // color is present in vertex format, add diffuse vertex
    // color feature.

+ 8 - 5
Engine/source/renderInstance/renderProbeMgr.cpp

@@ -521,7 +521,7 @@ ProbeShaderConstants* RenderProbeMgr::getProbeShaderConstants(GFXShaderConstBuff
 
    // Check to see if this is the same shader, we'll get hit repeatedly by
    // the same one due to the render bin loops.
-   /*if (mLastShader.getPointer() != shader)
+   if (mLastShader.getPointer() != shader)
    {
       ProbeConstantMap::Iterator iter = mConstantLookup.find(shader);
       if (iter != mConstantLookup.end())
@@ -538,12 +538,15 @@ ProbeShaderConstants* RenderProbeMgr::getProbeShaderConstants(GFXShaderConstBuff
 
       // Set our new shader
       mLastShader = shader;
-   }*/
+   }
 
-   ProbeShaderConstants* psc = new ProbeShaderConstants();
-   mConstantLookup[shader] = psc;
+   /*if (mLastConstants == nullptr)
+   {
+      ProbeShaderConstants* psc = new ProbeShaderConstants();
+      mConstantLookup[shader] = psc;
 
-   mLastConstants = psc;
+      mLastConstants = psc;
+   }*/
 
    // Make sure that our current lighting constants are initialized
    if (mLastConstants && !mLastConstants->mInit)

+ 106 - 0
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp

@@ -0,0 +1,106 @@
+#include "shaderGen/GLSL/debugVizFeatureGLSL.h"
+#include "shaderGen/shaderGen.h"
+#include "shaderGen/langElement.h"
+#include "shaderGen/shaderOp.h"
+#include "shaderGen/shaderGenVars.h"
+#include "gfx/gfxDevice.h"
+#include "materials/matInstance.h"
+#include "materials/processedMaterial.h"
+#include "materials/materialFeatureTypes.h"
+#include "core/util/autoPtr.h"
+
+//****************************************************************************
+// HDR Output
+//****************************************************************************
+
+DebugVizGLSL::DebugVizGLSL()
+   : mTorqueDep(ShaderGen::smCommonShaderPath + String("/gl/torque.glsl"))
+{
+   addDependency(&mTorqueDep);
+}
+
+void DebugVizGLSL::processPix(Vector<ShaderComponent*>& componentList,
+   const MaterialFeatureData& fd)
+{
+   MultiLine* meta = new MultiLine;
+   Var* surface = (Var*)LangElement::find("surface");
+
+   //0 == display both forward and deferred viz, 1 = display forward only viz, 2 = display deferred only viz
+   S32 vizDisplayMode = Con::getIntVariable("$Viz_DisplayMode", 0);
+
+   if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
+   {
+      Var* color = (Var*)LangElement::find("col");
+      if (color)
+      {
+         Var* specularColor = (Var*)LangElement::find("specularColor");
+
+         S32 surfaceVizMode = Con::getIntVariable("$Viz_SurfacePropertiesModeVar", -1);
+
+         switch (surfaceVizMode)
+         {
+         case 0:
+            meta->addStatement(new GenOp("   @.rgb = @.baseColor.rgb;\r\n", color, surface));
+            break;
+         case 1:
+            meta->addStatement(new GenOp("   @.rgb = @.N.rgb;\r\n", color, surface));
+            break;
+         case 2:
+            meta->addStatement(new GenOp("   @.rgb = @.ao.rrr;\r\n", color, surface));
+            break;
+         case 3:
+            meta->addStatement(new GenOp("   @.rgb = @.roughness.rrr;\r\n", color, surface));
+            break;
+         case 4:
+            meta->addStatement(new GenOp("   @.rgb = @.metalness.rrr;\r\n", color, surface));
+            break;
+         case 5:
+            meta->addStatement(new GenOp("   @.rgb = @.depth.rrr;\r\n", color, surface));
+            break;
+         case 6:
+            meta->addStatement(new GenOp("   @.rgb = @.albedo.rgb;\r\n", color, surface));
+            break;
+         case 7:
+            if (!specularColor)
+            {
+               specularColor = new Var("specularColor", "float3");
+               specularColor->uniform = false;
+            }
+
+            meta->addStatement(new GenOp("   @ = @.baseColor.rgb * @.ao;\r\n", specularColor, surface, surface));
+            meta->addStatement(new GenOp("   @.rgb = @.rgb;\r\n", color, specularColor));
+            break;
+         case 8:
+            meta->addStatement(new GenOp("   @.rgb = @.matFlag.rrr;\r\n", color, surface));
+            break;
+         case 9:
+            meta->addStatement(new GenOp("   @.rgb = @.P.xyz;\r\n", color, surface));
+            break;
+         case 10:
+            meta->addStatement(new GenOp("   @.rgb = @.R.xyz;\r\n", color, surface));
+            break;
+         case 11:
+            meta->addStatement(new GenOp("   @.rgb = @.F.rgb;\r\n", color, surface));
+            break;
+         case 12: //TODO
+            /*Var * ssaoMaskTex = (Var*)LangElement::find("ssaoMaskTex");
+            if (!ssaoMaskTex)
+            {
+               break;
+            }
+
+            meta->addStatement(new GenOp("   @.rgb = @.N;\r\n", color, surface));*/
+            meta->addStatement(new GenOp("   @.rgb = vec3(0,0,0);\r\n", color));
+            break;
+         case 13: //TODO
+            meta->addStatement(new GenOp("   @.rgb = vec3(0,0,0);\r\n", color));
+            break;
+         case 14: //TODO
+            meta->addStatement(new GenOp("   @.rgb = vec3(0,0,0);\r\n", color));
+            break;
+         };
+      }
+   }
+
+   output = meta;
+}

+ 41 - 0
Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.h

@@ -0,0 +1,41 @@
+#pragma once
+
+#ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
+#include "shaderGen/GLSL/shaderFeatureGLSL.h"
+#endif
+#ifndef _LANG_ELEMENT_H_
+#include "shaderGen/langElement.h"
+#endif
+#ifndef _GFXDEVICE_H_
+#include "gfx/gfxDevice.h"
+#endif
+#ifndef _FEATUREMGR_H_
+#include "shaderGen/featureMgr.h"
+#endif
+#ifndef _MATERIALFEATURETYPES_H_
+#include "materials/materialFeatureTypes.h"
+#endif
+#ifndef _MATERIALFEATUREDATA_H_
+#include "materials/materialFeatureData.h"
+#endif
+
+/// This should be the final feature on most pixel shaders which
+/// encodes the color for the current HDR target format.
+/// @see HDRPostFx
+/// @see LightManager
+/// @see torque.hlsl
+class DebugVizGLSL : public ShaderFeatureGLSL
+{
+protected:
+
+   ShaderIncludeDependency mTorqueDep;
+
+public:
+
+   DebugVizGLSL();
+
+   virtual void processPix(Vector<ShaderComponent*>& componentList,
+      const MaterialFeatureData& fd);
+
+   virtual String getName() { return "Debug Viz"; }
+};

+ 106 - 0
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.cpp

@@ -0,0 +1,106 @@
+#include "shaderGen/HLSL/debugVizFeatureHLSL.h"
+#include "shaderGen/shaderGen.h"
+#include "shaderGen/langElement.h"
+#include "shaderGen/shaderOp.h"
+#include "shaderGen/shaderGenVars.h"
+#include "gfx/gfxDevice.h"
+#include "materials/matInstance.h"
+#include "materials/processedMaterial.h"
+#include "materials/materialFeatureTypes.h"
+#include "core/util/autoPtr.h"
+
+//****************************************************************************
+// HDR Output
+//****************************************************************************
+
+DebugVizHLSL::DebugVizHLSL()
+   : mTorqueDep(ShaderGen::smCommonShaderPath + String("/torque.hlsl"))
+{
+   addDependency(&mTorqueDep);
+}
+
+void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
+   const MaterialFeatureData& fd)
+{
+   MultiLine* meta = new MultiLine;
+   Var* surface = (Var*)LangElement::find("surface");
+
+   //0 == display both forward and deferred viz, 1 = display forward only viz, 2 = display deferred only viz
+   S32 vizDisplayMode = Con::getIntVariable("$Viz_DisplayMode", 0);
+
+   if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
+   {
+      Var* color = (Var*)LangElement::find("col");
+      if (color)
+      {
+         Var* specularColor = (Var*)LangElement::find("specularColor");
+
+         S32 surfaceVizMode = Con::getIntVariable("$Viz_SurfacePropertiesModeVar", -1);
+
+         switch (surfaceVizMode)
+         {
+         case 0:
+            meta->addStatement(new GenOp("   @.rgb = @.baseColor.rgb;\r\n", color, surface));
+            break;
+         case 1:
+            meta->addStatement(new GenOp("   @.rgb = @.N.rgb;\r\n", color, surface));
+            break;
+         case 2:
+            meta->addStatement(new GenOp("   @.rgb = @.ao.rrr;\r\n", color, surface));
+            break;
+         case 3:
+            meta->addStatement(new GenOp("   @.rgb = @.roughness.rrr;\r\n", color, surface));
+            break;
+         case 4:
+            meta->addStatement(new GenOp("   @.rgb = @.metalness.rrr;\r\n", color, surface));
+            break;
+         case 5:
+            meta->addStatement(new GenOp("   @.rgb = @.depth.rrr;\r\n", color, surface));
+            break;
+         case 6:
+            meta->addStatement(new GenOp("   @.rgb = @.albedo.rgb;\r\n", color, surface));
+            break;
+         case 7:
+            if (!specularColor)
+            {
+               specularColor = new Var("specularColor", "float3");
+               specularColor->uniform = false;
+            }
+
+            meta->addStatement(new GenOp("   @ = @.baseColor.rgb * @.ao;\r\n", specularColor, surface, surface));
+            meta->addStatement(new GenOp("   @.rgb = @.rgb;\r\n", color, specularColor));
+            break;
+         case 8:
+            meta->addStatement(new GenOp("   @.rgb = @.matFlag.rrr;\r\n", color, surface));
+            break;
+         case 9:
+            meta->addStatement(new GenOp("   @.rgb = @.P.xyz;\r\n", color, surface));
+            break;
+         case 10:
+            meta->addStatement(new GenOp("   @.rgb = @.R.xyz;\r\n", color, surface));
+            break;
+         case 11:
+            meta->addStatement(new GenOp("   @.rgb = @.F.rgb;\r\n", color, surface));
+            break;
+         case 12: //TODO
+            /*Var * ssaoMaskTex = (Var*)LangElement::find("ssaoMaskTex");
+            if (!ssaoMaskTex)
+            {
+               break;
+            }
+
+            meta->addStatement(new GenOp("   @.rgb = @.N;\r\n", color, surface));*/
+            meta->addStatement(new GenOp("   @.rgb = float3(0,0,0);\r\n", color));
+            break;
+         case 13: //TODO
+            meta->addStatement(new GenOp("   @.rgb = float3(0,0,0);\r\n", color));
+            break;
+         case 14: //TODO
+            meta->addStatement(new GenOp("   @.rgb = float3(0,0,0);\r\n", color));
+            break;
+         };
+      }
+   }
+
+   output = meta;
+}

+ 41 - 0
Engine/source/shaderGen/HLSL/debugVizFeatureHLSL.h

@@ -0,0 +1,41 @@
+#pragma once
+
+#ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
+#include "shaderGen/HLSL/shaderFeatureHLSL.h"
+#endif
+#ifndef _LANG_ELEMENT_H_
+#include "shaderGen/langElement.h"
+#endif
+#ifndef _GFXDEVICE_H_
+#include "gfx/gfxDevice.h"
+#endif
+#ifndef _FEATUREMGR_H_
+#include "shaderGen/featureMgr.h"
+#endif
+#ifndef _MATERIALFEATURETYPES_H_
+#include "materials/materialFeatureTypes.h"
+#endif
+#ifndef _MATERIALFEATUREDATA_H_
+#include "materials/materialFeatureData.h"
+#endif
+
+/// This should be the final feature on most pixel shaders which
+/// encodes the color for the current HDR target format.
+/// @see HDRPostFx
+/// @see LightManager
+/// @see torque.hlsl
+class DebugVizHLSL : public ShaderFeatureHLSL
+{
+protected:
+
+   ShaderIncludeDependency mTorqueDep;
+
+public:
+
+   DebugVizHLSL();
+
+   virtual void processPix(Vector<ShaderComponent*>& componentList,
+      const MaterialFeatureData& fd);
+
+   virtual String getName() { return "Debug Viz"; }
+};

+ 10 - 1
Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

@@ -111,6 +111,10 @@ LangElement* ShaderFeatureHLSL::assignColor( LangElement *elem,
          assign = new GenOp( "@ -= @", color, elem );
          break;
 
+      case Material::PreMult:
+         assign = new GenOp("@ *= @", color, elem);
+         break;
+
       case Material::Mul:
          assign = new GenOp( "@ *= @", color, elem );
          break;
@@ -2223,7 +2227,10 @@ void RTLightingFeatHLSL::processPix(   Vector<ShaderComponent*> &componentList,
    MultiLine *meta = new MultiLine;
 
    // Now the wsPosition and wsView.
+   Var* worldToTangent = getInWorldToTangent(componentList);
+   Var* wsNormal = getInWorldNormal(componentList);
    Var *wsPosition = getInWsPosition( componentList );
+   
    Var *wsView = getWsView( wsPosition, meta );
    
    // Look for a light mask generated from a previous
@@ -3037,7 +3044,9 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
    MultiLine *meta = new MultiLine;
    
    // Now the wsPosition and wsView.
-   Var *wsPosition = getInWsPosition(componentList);
+   Var* worldToTangent = getInWorldToTangent(componentList);
+   Var *wsNormal = getInWorldNormal(componentList);
+   Var* wsPosition = getInWsPosition(componentList);
    Var *wsView = getWsView(wsPosition, meta);
    
    //Reflection Probe WIP

+ 3 - 0
Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp

@@ -29,6 +29,7 @@
 #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"
 #include "materials/materialFeatureTypes.h"
 #include "core/module.h"
@@ -89,6 +90,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
 
    FEATUREMGR->registerFeature( MFT_HDROut, new HDROutHLSL );
 
+   FEATUREMGR->registerFeature( MFT_DebugViz, new DebugVizHLSL);
+
    FEATUREMGR->registerFeature( MFT_ParaboloidVertTransform, new ParaboloidVertTransformHLSL );
    FEATUREMGR->registerFeature( MFT_IsSinglePassParaboloid, new NamedFeatureHLSL( "Single Pass Paraboloid" ) );
    FEATUREMGR->registerFeature( MFT_UseInstancing, new NamedFeatureHLSL( "Hardware Instancing" ) );

+ 2 - 0
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs

@@ -79,6 +79,7 @@ function MaterialEditorGui::open(%this)
    MaterialEditorPropertiesWindow-->blendingTypePopUp.add(AddAlpha,3);
    MaterialEditorPropertiesWindow-->blendingTypePopUp.add(Sub,4);
    MaterialEditorPropertiesWindow-->blendingTypePopUp.add(LerpAlpha,5);
+   MaterialEditorPropertiesWindow-->blendingTypePopUp.add(PreMult,6);
    MaterialEditorPropertiesWindow-->blendingTypePopUp.setSelected( 0, false );
 
    //Reflection Types
@@ -786,6 +787,7 @@ function MaterialEditorGui::guiSync( %this, %material )
        case "AddAlpha": %selectedNum = 3;
             case "Sub": %selectedNum = 4;
       case "LerpAlpha": %selectedNum = 5;
+      case "PreMult": %selectedNum = 6;
    }
    MaterialEditorPropertiesWindow-->blendingTypePopUp.setSelected(%selectedNum);
    

+ 56 - 7
Templates/BaseGame/game/tools/worldEditor/scripts/visibility/miscViz.cs

@@ -110,8 +110,47 @@ singleton PostEffect( Viz_SurfacePropertiesPFX )
    
    target = "$backBuffer";
    renderPriority = 9999;
+   
+   renderTime = "PFXBeforeBin";
+   renderBin = "ObjTranslucentBin"; 
 };
 
+function toggleDebugVizMode( %mode )
+{
+   switch$ ( %mode )
+   {
+      case "All Materials":
+         $Viz_DisplayMode = "0";
+      case "Forward Materials Only":
+         $Viz_DisplayMode = "1";
+      case "Deferred Materials Only":
+         $Viz_DisplayMode = "2"; 
+      default:
+         $Viz_DisplayMode = "0";
+   }
+   
+   if($Viz_DisplayMode == 1)
+   {
+      Viz_SurfacePropertiesPFX.disable(); 
+   }
+   else
+   {
+      if($Viz_SurfacePropertiesModeVar != "" && $Viz_SurfacePropertiesModeVar != -1)
+         Viz_SurfacePropertiesPFX.enable(); 
+   }
+   
+   for(%i=0; %i < 3; %i++)
+   {
+      if(%i == $Viz_DisplayMode)
+         EBufferVizModeOptions.checkItem(%i, true);
+      else
+         EBufferVizModeOptions.checkItem(%i, false);
+   }
+   
+   //forces the forward materials to get dis viz properly
+   reInitMaterials();
+}
+
 /// Toggles the visualization of the AL lighting specular power buffer.
 function toggleSurfacePropertiesViz( %mode )
 {   
@@ -153,17 +192,24 @@ function toggleSurfacePropertiesViz( %mode )
          $Viz_SurfacePropertiesModeVar = "-1";
    }
    
-   //If the visualizer isn't enabled, we just flip it on
-   if(!Viz_SurfacePropertiesPFX.isEnabled())
+   if($Viz_DisplayMode == 1)
    {
-      Viz_SurfacePropertiesPFX.enable();  
+      Viz_SurfacePropertiesPFX.disable(); 
    }
-   else //if it's currently enabled, check if we clicked the same mode again. If so, disable. If not, just swap modes to the new one
+   else
    {
-      if(%previousMode == $Viz_SurfacePropertiesModeVar)
+      //If the visualizer isn't enabled, we just flip it on
+      if(!Viz_SurfacePropertiesPFX.isEnabled())
       {
-         $Viz_SurfacePropertiesModeVar = -1;
-         Viz_SurfacePropertiesPFX.disable(); 
+         Viz_SurfacePropertiesPFX.enable();  
+      }
+      else //if it's currently enabled, check if we clicked the same mode again. If so, disable. If not, just swap modes to the new one
+      {
+         if(%previousMode == $Viz_SurfacePropertiesModeVar)
+         {
+            $Viz_SurfacePropertiesModeVar = -1;
+            Viz_SurfacePropertiesPFX.disable(); 
+         }
       }
    }
    
@@ -174,6 +220,9 @@ function toggleSurfacePropertiesViz( %mode )
       else
          EVisibilityBufferVizOptions.checkItem(%i, false);
    }
+   
+   //forces the forward materials to get dis viz properly
+   reInitMaterials();
 }
 
 function Viz_SurfacePropertiesPFX::setShaderConsts(%this)

+ 29 - 15
Templates/BaseGame/game/tools/worldEditor/scripts/visibility/visibilityLayer.ed.cs

@@ -155,6 +155,18 @@ function setupEditorVisibilityMenu()
    
    %probespopup.enableItem(4, false);
    
+   %bufferVizpopup = new PopupMenu(EBufferVizModeOptions)
+   {
+      superClass = "MenuBuilder";
+      class = "EditorWorldMenu";
+      
+      item[ 0 ] = "All Materials" TAB "" TAB "toggleDebugVizMode(\"All Materials\");";
+      item[ 1 ] = "Forward Materials Only" TAB "" TAB "toggleDebugVizMode(\"Forward Materials Only\");";
+      item[ 2 ] = "Deferred Materials Only" TAB "" TAB "toggleDebugVizMode(\"Deferred Materials Only\");";
+   };
+   
+   toggleDebugVizMode("All Materials");
+   
    //
    //Buffer Viz
    %bufferVizpopup = new PopupMenu(EVisibilityBufferVizOptions)
@@ -162,26 +174,28 @@ function setupEditorVisibilityMenu()
       superClass = "MenuBuilder";
       class = "EditorWorldMenu";
       
-      item[ 0 ] = "Base Color" TAB "" TAB "toggleSurfacePropertiesViz(\"BaseColor\");";
-      item[ 1 ] = "Normals" TAB "" TAB "toggleSurfacePropertiesViz(\"Normal\");";
-      item[ 2 ] = "Material Ambient Occlusion" TAB "" TAB "toggleSurfacePropertiesViz(\"AO\");";
-      item[ 3 ] = "Roughness" TAB "" TAB "toggleSurfacePropertiesViz(\"Roughness\");";
-      item[ 4 ] = "Metalness" TAB "" TAB "toggleSurfacePropertiesViz(\"Metalness\");";
-      item[ 5 ] = "Depth" TAB "" TAB "toggleSurfacePropertiesViz(\"Depth\");";
+      item[ 0 ] = "Display Mode" TAB EBufferVizModeOptions;
+      
+      item[ 1 ] = "Base Color" TAB "" TAB "toggleSurfacePropertiesViz(\"BaseColor\");";
+      item[ 2 ] = "Normals" TAB "" TAB "toggleSurfacePropertiesViz(\"Normal\");";
+      item[ 3 ] = "Material Ambient Occlusion" TAB "" TAB "toggleSurfacePropertiesViz(\"AO\");";
+      item[ 4 ] = "Roughness" TAB "" TAB "toggleSurfacePropertiesViz(\"Roughness\");";
+      item[ 5 ] = "Metalness" TAB "" TAB "toggleSurfacePropertiesViz(\"Metalness\");";
+      item[ 6 ] = "Depth" TAB "" TAB "toggleSurfacePropertiesViz(\"Depth\");";
       
-      item[ 6 ] = "Diffuse Color" TAB "" TAB "toggleSurfacePropertiesViz(\"DiffuseColor\");";
-      item[ 7 ] = "Specular Color" TAB "" TAB "toggleSurfacePropertiesViz(\"SpecularColor\");";
-      item[ 8 ] = "Material Flags" TAB "" TAB "toggleSurfacePropertiesViz(\"MatFlag\");";
+      item[ 7 ] = "Diffuse Color" TAB "" TAB "toggleSurfacePropertiesViz(\"DiffuseColor\");";
+      item[ 8 ] = "Specular Color" TAB "" TAB "toggleSurfacePropertiesViz(\"SpecularColor\");";
+      item[ 9 ] = "Material Flags" TAB "" TAB "toggleSurfacePropertiesViz(\"MatFlag\");";
       
-      item[ 9 ] = "World Position" TAB "" TAB "toggleSurfacePropertiesViz(\"WorldPos\");";
-      item[ 10 ] = "Reflection Vector" TAB "" TAB "toggleSurfacePropertiesViz(\"ReflectionVector\");";
+      item[ 10 ] = "World Position" TAB "" TAB "toggleSurfacePropertiesViz(\"WorldPos\");";
+      item[ 11 ] = "Reflection Vector" TAB "" TAB "toggleSurfacePropertiesViz(\"ReflectionVector\");";
       
-      item[ 11 ] = "Fresnel" TAB "" TAB "toggleSurfacePropertiesViz(\"Fresnel\");";
+      item[ 12 ] = "Fresnel" TAB "" TAB "toggleSurfacePropertiesViz(\"Fresnel\");";
       
-      item[ 12 ] = "Ambient Occlusion" TAB "" TAB "toggleSurfacePropertiesViz(\"SSAO\");";
+      item[ 13 ] = "Ambient Occlusion" TAB "" TAB "toggleSurfacePropertiesViz(\"SSAO\");";
       
-      item[ 13 ] = "Backbuffer" TAB "" TAB "toggleSurfacePropertiesViz(\"Backbuffer\");";
-      item[ 14 ] = "Glow" TAB "" TAB "toggleSurfacePropertiesViz(\"Glow\");";
+      item[ 14 ] = "Backbuffer" TAB "" TAB "toggleSurfacePropertiesViz(\"Backbuffer\");";
+      item[ 15 ] = "Glow" TAB "" TAB "toggleSurfacePropertiesViz(\"Glow\");";
    };
    
    //