accuFeatureHLSL.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _ACCUFEATUREHLSL_H_
  23. #define _ACCUFEATUREHLSL_H_
  24. #ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
  25. #include "shaderGen/HLSL/shaderFeatureHLSL.h"
  26. #endif
  27. #ifndef _LANG_ELEMENT_H_
  28. #include "shaderGen/langElement.h"
  29. #endif
  30. #ifndef _GFXDEVICE_H_
  31. #include "gfx/gfxDevice.h"
  32. #endif
  33. #ifndef _FEATUREMGR_H_
  34. #include "shaderGen/featureMgr.h"
  35. #endif
  36. #ifndef _MATERIALFEATURETYPES_H_
  37. #include "materials/materialFeatureTypes.h"
  38. #endif
  39. #ifndef _MATERIALFEATUREDATA_H_
  40. #include "materials/materialFeatureData.h"
  41. #endif
  42. /// Accu texture
  43. class AccuTexFeatHLSL : public ShaderFeatureHLSL
  44. {
  45. public:
  46. //****************************************************************************
  47. // Accu Texture
  48. //****************************************************************************
  49. virtual void processVert( Vector<ShaderComponent*> &componentList,
  50. const MaterialFeatureData &fd );
  51. virtual void processPix( Vector<ShaderComponent*> &componentList,
  52. const MaterialFeatureData &fd );
  53. void getAccuVec( MultiLine *meta, LangElement *accuVec );
  54. Var* addOutAccuVec( Vector<ShaderComponent*> &componentList, MultiLine *meta );
  55. virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
  56. virtual Resources getResources( const MaterialFeatureData &fd )
  57. {
  58. Resources res;
  59. res.numTex = 1;
  60. res.numTexReg = 1;
  61. return res;
  62. }
  63. virtual void setTexData( Material::StageData &stageDat,
  64. const MaterialFeatureData &fd,
  65. RenderPassData &passData,
  66. U32 &texIndex );
  67. virtual String getName()
  68. {
  69. return "Accu Texture";
  70. }
  71. };
  72. class AccuScaleFeature : public ShaderFeatureHLSL
  73. {
  74. public:
  75. virtual void processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
  76. {
  77. // Find the constant value
  78. Var *accuScale = (Var *)( LangElement::find("accuScale") );
  79. if( accuScale == NULL )
  80. {
  81. accuScale = new Var;
  82. accuScale->setType( "float" );
  83. accuScale->setName( "accuScale" );
  84. accuScale->constSortPos = cspPotentialPrimitive;
  85. accuScale->uniform = true;
  86. }
  87. }
  88. virtual String getName() { return "Accu Scale"; }
  89. };
  90. class AccuDirectionFeature : public ShaderFeatureHLSL
  91. {
  92. public:
  93. virtual void processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
  94. {
  95. // Find the constant value
  96. Var *accuDirection = (Var *)( LangElement::find("accuDirection") );
  97. if( accuDirection == NULL )
  98. {
  99. accuDirection = new Var;
  100. accuDirection->setType( "float" );
  101. accuDirection->setName( "accuDirection" );
  102. accuDirection->constSortPos = cspPotentialPrimitive;
  103. accuDirection->uniform = true;
  104. }
  105. }
  106. virtual String getName() { return "Accu Direction"; }
  107. };
  108. class AccuStrengthFeature : public ShaderFeatureHLSL
  109. {
  110. public:
  111. virtual void processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
  112. {
  113. // Find the constant value
  114. Var *accuStrength = (Var *)( LangElement::find("accuStrength") );
  115. if( accuStrength == NULL )
  116. {
  117. accuStrength = new Var;
  118. accuStrength->setType( "float" );
  119. accuStrength->setName( "accuStrength" );
  120. accuStrength->constSortPos = cspPotentialPrimitive;
  121. accuStrength->uniform = true;
  122. }
  123. }
  124. virtual String getName() { return "Accu Strength"; }
  125. };
  126. class AccuCoverageFeature : public ShaderFeatureHLSL
  127. {
  128. public:
  129. virtual void processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
  130. {
  131. // Find the constant value
  132. Var *accuCoverage = (Var *)( LangElement::find("accuCoverage") );
  133. if( accuCoverage == NULL )
  134. {
  135. accuCoverage = new Var;
  136. accuCoverage->setType( "float" );
  137. accuCoverage->setName( "accuCoverage" );
  138. accuCoverage->constSortPos = cspPotentialPrimitive;
  139. accuCoverage->uniform = true;
  140. }
  141. }
  142. virtual String getName() { return "Accu Coverage"; }
  143. };
  144. class AccuSpecularFeature : public ShaderFeatureHLSL
  145. {
  146. public:
  147. virtual void processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
  148. {
  149. // Find the constant value
  150. Var *accuSpecular = (Var *)( LangElement::find("accuSpecular") );
  151. if( accuSpecular == NULL )
  152. {
  153. accuSpecular = new Var;
  154. accuSpecular->setType( "float" );
  155. accuSpecular->setName( "accuSpecular" );
  156. accuSpecular->constSortPos = cspPotentialPrimitive;
  157. accuSpecular->uniform = true;
  158. }
  159. }
  160. virtual String getName() { return "Accu Specular"; }
  161. };
  162. #endif