terrFeatureHLSL.h 6.1 KB

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