customFeatureHLSL.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
  2. #include "shaderGen/HLSL/shaderFeatureHLSL.h"
  3. #endif
  4. #ifndef _LANG_ELEMENT_H_
  5. #include "shaderGen/langElement.h"
  6. #endif
  7. #ifndef _GFXDEVICE_H_
  8. #include "gfx/gfxDevice.h"
  9. #endif
  10. #ifndef _FEATUREMGR_H_
  11. #include "shaderGen/featureMgr.h"
  12. #endif
  13. #ifndef _MATERIALFEATURETYPES_H_
  14. #include "materials/materialFeatureTypes.h"
  15. #endif
  16. #ifndef _MATERIALFEATUREDATA_H_
  17. #include "materials/materialFeatureData.h"
  18. #endif
  19. #ifndef CUSTOMSHADERFEATURE_H
  20. #include "shaderGen/customShaderFeature.h"
  21. #endif
  22. class CustomShaderFeatureData;
  23. class CustomFeatureHLSL : public ShaderFeatureHLSL
  24. {
  25. friend class CustomShaderFeatureData;
  26. struct VarHolder
  27. {
  28. String varName;
  29. String type;
  30. String defaultValue;
  31. S32 elementId;
  32. bool uniform;
  33. bool sampler;
  34. bool texture;
  35. bool texCoord;
  36. U32 constNum;
  37. U32 arraySize;
  38. String structName;
  39. ConstantSortPosition constSortPos;
  40. VarHolder() :
  41. varName(""),
  42. type(""),
  43. defaultValue(""),
  44. elementId(-1),
  45. uniform(false),
  46. sampler(false),
  47. texture(false),
  48. texCoord(false),
  49. constNum(0),
  50. arraySize(0),
  51. structName(""),
  52. constSortPos(cspUninit)
  53. {
  54. }
  55. VarHolder(String _varName, String _type, String _defaultValue) :
  56. elementId(-1), uniform(false), sampler(false), texture(false), texCoord(false), constNum(0), arraySize(0), structName(""), constSortPos(cspUninit)
  57. {
  58. varName = _varName;
  59. type = _type;
  60. defaultValue = _defaultValue;
  61. }
  62. };
  63. Vector<VarHolder> mVars;
  64. Vector<VarHolder> mConnectorVars;
  65. enum outputState
  66. {
  67. NoOutput,
  68. VertexOutput,
  69. PixelOutput
  70. };
  71. outputState mOutputState;
  72. public:
  73. CustomShaderFeatureData* mOwner;
  74. Vector<ShaderComponent*> mComponentList;
  75. MaterialFeatureData mFeatureData;
  76. protected:
  77. MultiLine* meta;
  78. public:
  79. //****************************************************************************
  80. // Accu Texture
  81. //****************************************************************************
  82. virtual void processVert(Vector<ShaderComponent*>& componentList,
  83. const MaterialFeatureData& fd);
  84. virtual void processPix(Vector<ShaderComponent*>& componentList,
  85. const MaterialFeatureData& fd);
  86. virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; }
  87. virtual Resources getResources(const MaterialFeatureData& fd)
  88. {
  89. Resources res;
  90. res.numTex = 1;
  91. res.numTexReg = 1;
  92. return res;
  93. }
  94. virtual void setTexData(Material::StageData& stageDat,
  95. const MaterialFeatureData& fd,
  96. RenderPassData& passData,
  97. U32& texIndex);
  98. virtual String getName()
  99. {
  100. return mOwner->getName();
  101. }
  102. bool hasFeature(String name);
  103. void addUniform(String name, String type, String defaultValue, U32 arraySize = 0);
  104. void addVariable(String name, String type, String defaultValue);
  105. void addSampler(String name, String type, U32 arraySize = 0);
  106. void addTexture(String name, String type, String samplerState, U32 arraySize);
  107. void addConnector(String name, String type, String elementName);
  108. void addVertTexCoord(String name);
  109. void writeLine(String format, S32 argc, ConsoleValue* argv);
  110. };