Torque3D Documentation / _generateds / debugVizFeatureGLSL.cpp

debugVizFeatureGLSL.cpp

Engine/source/shaderGen/GLSL/debugVizFeatureGLSL.cpp

More...

Detailed Description

  1
  2#include "shaderGen/GLSL/debugVizFeatureGLSL.h"
  3#include "shaderGen/shaderGen.h"
  4#include "shaderGen/langElement.h"
  5#include "shaderGen/shaderOp.h"
  6#include "shaderGen/shaderGenVars.h"
  7#include "gfx/gfxDevice.h"
  8#include "materials/matInstance.h"
  9#include "materials/processedMaterial.h"
 10#include "materials/materialFeatureTypes.h"
 11#include "core/util/autoPtr.h"
 12
 13//****************************************************************************
 14// HDR Output
 15//****************************************************************************
 16
 17DebugVizGLSL::DebugVizGLSL()
 18   : mTorqueDep(ShaderGen::smCommonShaderPath + String("/gl/torque.glsl"))
 19{
 20   addDependency(&mTorqueDep);
 21}
 22
 23void DebugVizGLSL::processPix(Vector<ShaderComponent*>& componentList,
 24   const MaterialFeatureData& fd)
 25{
 26   MultiLine* meta = new MultiLine;
 27   Var* surface = (Var*)LangElement::find("surface");
 28
 29   //0 == display both forward and deferred viz, 1 = display forward only viz, 2 = display deferred only viz
 30   S32 vizDisplayMode = Con::getIntVariable("$Viz_DisplayMode", 0);
 31
 32   if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
 33   {
 34      Var* color = (Var*)LangElement::find("col");
 35      if (color)
 36      {
 37         Var* specularColor = (Var*)LangElement::find("specularColor");
 38
 39         S32 surfaceVizMode = Con::getIntVariable("$Viz_SurfacePropertiesModeVar", -1);
 40
 41         switch (surfaceVizMode)
 42         {
 43         case 0:
 44            meta->addStatement(new GenOp("   @.rgb = @.baseColor.rgb;\r\n", color, surface));
 45            break;
 46         case 1:
 47            meta->addStatement(new GenOp("   @.rgb = @.N.rgb;\r\n", color, surface));
 48            break;
 49         case 2:
 50            meta->addStatement(new GenOp("   @.rgb = @.ao.rrr;\r\n", color, surface));
 51            break;
 52         case 3:
 53            meta->addStatement(new GenOp("   @.rgb = @.roughness.rrr;\r\n", color, surface));
 54            break;
 55         case 4:
 56            meta->addStatement(new GenOp("   @.rgb = @.metalness.rrr;\r\n", color, surface));
 57            break;
 58         case 5:
 59            meta->addStatement(new GenOp("   @.rgb = @.depth.rrr;\r\n", color, surface));
 60            break;
 61         case 6:
 62            meta->addStatement(new GenOp("   @.rgb = @.albedo.rgb;\r\n", color, surface));
 63            break;
 64         case 7:
 65            if (!specularColor)
 66            {
 67               specularColor = new Var("specularColor", "float3");
 68               specularColor->uniform = false;
 69            }
 70
 71            meta->addStatement(new GenOp("   @ = @.baseColor.rgb * @.ao;\r\n", specularColor, surface, surface));
 72            meta->addStatement(new GenOp("   @.rgb = @.rgb;\r\n", color, specularColor));
 73            break;
 74         case 8:
 75            meta->addStatement(new GenOp("   @.rgb = @.matFlag.rrr;\r\n", color, surface));
 76            break;
 77         case 9:
 78            meta->addStatement(new GenOp("   @.rgb = @.P.xyz;\r\n", color, surface));
 79            break;
 80         case 10:
 81            meta->addStatement(new GenOp("   @.rgb = @.R.xyz;\r\n", color, surface));
 82            break;
 83         case 11:
 84            meta->addStatement(new GenOp("   @.rgb = @.F.rgb;\r\n", color, surface));
 85            break;
 86         case 12: //TODO
 87            /*Var * ssaoMaskTex = (Var*)LangElement::find("ssaoMaskTex");
 88            if (!ssaoMaskTex)
 89            {
 90               break;
 91            }
 92
 93            meta->addStatement(new GenOp("   @.rgb = @.N;\r\n", color, surface));*/
 94            meta->addStatement(new GenOp("   @.rgb = vec3(0,0,0);\r\n", color));
 95            break;
 96         case 13: //TODO
 97            meta->addStatement(new GenOp("   @.rgb = vec3(0,0,0);\r\n", color));
 98            break;
 99         case 14: //TODO
100            meta->addStatement(new GenOp("   @.rgb = vec3(0,0,0);\r\n", color));
101            break;
102         };
103      }
104   }
105
106   output = meta;
107}
108