terrFeatureHLSL.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 _TERRFEATUREHLSL_H_
  23. #define _TERRFEATUREHLSL_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. /// A shared base class for terrain features which
  31. /// includes some helper functions.
  32. class TerrainFeatHLSL : public ShaderFeatureHLSL
  33. {
  34. protected:
  35. ShaderIncludeDependency mTorqueDep;
  36. public:
  37. TerrainFeatHLSL();
  38. Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList );
  39. Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );
  40. Var* _getDetailMapSampler();
  41. Var* _getDetailMapArray();
  42. Var* _getNormalMapSampler();
  43. Var* _getNormalMapArray();
  44. Var* _getOrmMapSampler();
  45. Var* _getOrmMapArray();
  46. Var* _getNormalMapTex();
  47. Var* _getORMConfigMapTex();
  48. static Var* _getUniformVar( const char *name, const char *type, ConstantSortPosition csp );
  49. Var* _getDetailIdStrengthParallax();
  50. Var* _getMacroIdStrengthParallax();
  51. };
  52. class TerrainBaseMapFeatHLSL : public TerrainFeatHLSL
  53. {
  54. public:
  55. virtual void processVert( Vector<ShaderComponent*> &componentList,
  56. const MaterialFeatureData &fd );
  57. virtual void processPix( Vector<ShaderComponent*> &componentList,
  58. const MaterialFeatureData &fd );
  59. virtual Resources getResources( const MaterialFeatureData &fd );
  60. virtual String getName() { return "Terrain Base Texture"; }
  61. virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
  62. };
  63. class TerrainDetailMapFeatHLSL : public TerrainFeatHLSL
  64. {
  65. protected:
  66. ShaderIncludeDependency mTorqueDep;
  67. ShaderIncludeDependency mTerrainDep;
  68. public:
  69. TerrainDetailMapFeatHLSL();
  70. virtual void processVert( Vector<ShaderComponent*> &componentList,
  71. const MaterialFeatureData &fd );
  72. virtual void processPix( Vector<ShaderComponent*> &componentList,
  73. const MaterialFeatureData &fd );
  74. virtual Resources getResources( const MaterialFeatureData &fd );
  75. virtual String getName() { return "Terrain Detail Texture"; }
  76. virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
  77. };
  78. class TerrainMacroMapFeatHLSL : public TerrainFeatHLSL
  79. {
  80. protected:
  81. ShaderIncludeDependency mTorqueDep;
  82. ShaderIncludeDependency mTerrainDep;
  83. public:
  84. TerrainMacroMapFeatHLSL();
  85. virtual void processVert( Vector<ShaderComponent*> &componentList,
  86. const MaterialFeatureData &fd );
  87. virtual void processPix( Vector<ShaderComponent*> &componentList,
  88. const MaterialFeatureData &fd );
  89. virtual Resources getResources( const MaterialFeatureData &fd );
  90. virtual String getName() { return "Terrain Macro Texture"; }
  91. virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
  92. };
  93. class TerrainNormalMapFeatHLSL : public TerrainFeatHLSL
  94. {
  95. public:
  96. virtual void processVert( Vector<ShaderComponent*> &componentList,
  97. const MaterialFeatureData &fd );
  98. virtual void processPix( Vector<ShaderComponent*> &componentList,
  99. const MaterialFeatureData &fd );
  100. virtual Resources getResources( const MaterialFeatureData &fd );
  101. virtual String getName() { return "Terrain Normal Texture"; }
  102. };
  103. class TerrainLightMapFeatHLSL : public TerrainFeatHLSL
  104. {
  105. public:
  106. virtual void processPix( Vector<ShaderComponent*> &componentList,
  107. const MaterialFeatureData &fd );
  108. virtual Resources getResources( const MaterialFeatureData &fd );
  109. virtual String getName() { return "Terrain Lightmap Texture"; }
  110. };
  111. class TerrainORMMapFeatHLSL : public TerrainFeatHLSL
  112. {
  113. public:
  114. virtual void processVert(Vector<ShaderComponent*> &componentList,
  115. const MaterialFeatureData &fd);
  116. virtual void processPix(Vector<ShaderComponent*> &componentList,
  117. const MaterialFeatureData &fd);
  118. virtual Resources getResources(const MaterialFeatureData &fd);
  119. virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
  120. virtual String getName() { return "Composite Matinfo map"; }
  121. };
  122. class TerrainBlankInfoMapFeatHLSL : public TerrainFeatHLSL
  123. {
  124. public:
  125. virtual void processPix(Vector<ShaderComponent*> &componentList,
  126. const MaterialFeatureData &fd);
  127. virtual String getName() { return "Blank Matinfo map"; }
  128. };
  129. class TerrainHeightMapBlendHLSL : public TerrainFeatHLSL
  130. {
  131. public:
  132. virtual void processVert(Vector<ShaderComponent*>& componentList,
  133. const MaterialFeatureData& fd);
  134. virtual void processPix(Vector<ShaderComponent*>& componentList,
  135. const MaterialFeatureData& fd);
  136. virtual String getName() { return "Terrain Heightmap Blend"; }
  137. };
  138. #endif // _TERRFEATUREHLSL_H_