debugVizFeatureGLSL.cpp 3.8 KB

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