terrFeatureGLSL.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 _TERRFEATUREGLSL_H_
  23. #define _TERRFEATUREGLSL_H_
  24. #ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
  25. #include "shaderGen/GLSL/shaderFeatureGLSL.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 TerrainFeatGLSL : public ShaderFeatureGLSL
  33. {
  34. protected:
  35. ShaderIncludeDependency mTorqueDep;
  36. public:
  37. TerrainFeatGLSL();
  38. Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList );
  39. Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );
  40. Var* _getDetailMapSampler();
  41. Var* _getMacroMapSampler();
  42. Var* _getNormalMapSampler();
  43. Var* _getOrmMapSampler();
  44. static Var* _getUniformVar( const char *name, const char *type, ConstantSortPosition csp );
  45. Var* _getDetailIdStrengthParallax();
  46. Var* _getMacroIdStrengthParallax();
  47. };
  48. class TerrainBaseMapFeatGLSL : public TerrainFeatGLSL
  49. {
  50. public:
  51. void processVert( Vector<ShaderComponent*> &componentList,
  52. const MaterialFeatureData &fd ) override;
  53. void processPix( Vector<ShaderComponent*> &componentList,
  54. const MaterialFeatureData &fd ) override;
  55. Resources getResources( const MaterialFeatureData &fd ) override;
  56. String getName() override { return "Terrain Base Texture"; }
  57. U32 getOutputTargets( const MaterialFeatureData &fd ) const override;
  58. };
  59. class TerrainDetailMapFeatGLSL : public TerrainFeatGLSL
  60. {
  61. protected:
  62. ShaderIncludeDependency mTorqueDep;
  63. ShaderIncludeDependency mTerrainDep;
  64. public:
  65. TerrainDetailMapFeatGLSL();
  66. void processVert( Vector<ShaderComponent*> &componentList,
  67. const MaterialFeatureData &fd ) override;
  68. void processPix( Vector<ShaderComponent*> &componentList,
  69. const MaterialFeatureData &fd ) override;
  70. Resources getResources( const MaterialFeatureData &fd ) override;
  71. String getName() override { return "Terrain Detail Texture"; }
  72. U32 getOutputTargets( const MaterialFeatureData &fd ) const override;
  73. };
  74. class TerrainMacroMapFeatGLSL : public TerrainFeatGLSL
  75. {
  76. protected:
  77. ShaderIncludeDependency mTorqueDep;
  78. ShaderIncludeDependency mTerrainDep;
  79. public:
  80. TerrainMacroMapFeatGLSL();
  81. void processVert( Vector<ShaderComponent*> &componentList,
  82. const MaterialFeatureData &fd ) override;
  83. void processPix( Vector<ShaderComponent*> &componentList,
  84. const MaterialFeatureData &fd ) override;
  85. Resources getResources( const MaterialFeatureData &fd ) override;
  86. String getName() override { return "Terrain Macro Texture"; }
  87. U32 getOutputTargets( const MaterialFeatureData &fd ) const override;
  88. };
  89. class TerrainNormalMapFeatGLSL : public TerrainFeatGLSL
  90. {
  91. public:
  92. void processVert( Vector<ShaderComponent*> &componentList,
  93. const MaterialFeatureData &fd ) override;
  94. void processPix( Vector<ShaderComponent*> &componentList,
  95. const MaterialFeatureData &fd ) override;
  96. Resources getResources( const MaterialFeatureData &fd ) override;
  97. String getName() override { return "Terrain Normal Texture"; }
  98. };
  99. class TerrainLightMapFeatGLSL : public TerrainFeatGLSL
  100. {
  101. public:
  102. void processPix( Vector<ShaderComponent*> &componentList,
  103. const MaterialFeatureData &fd ) override;
  104. Resources getResources( const MaterialFeatureData &fd ) override;
  105. String getName() override { return "Terrain Lightmap Texture"; }
  106. };
  107. class TerrainORMMapFeatGLSL : public TerrainFeatGLSL
  108. {
  109. public:
  110. void processVert(Vector<ShaderComponent*> &componentList,
  111. const MaterialFeatureData &fd) override;
  112. void processPix(Vector<ShaderComponent*> &componentList,
  113. const MaterialFeatureData &fd) override;
  114. Resources getResources(const MaterialFeatureData &fd) override;
  115. U32 getOutputTargets(const MaterialFeatureData &fd) const override;
  116. String getName() override { return "Composite Matinfo map"; }
  117. };
  118. class TerrainBlankInfoMapFeatGLSL : public ShaderFeatureGLSL
  119. {
  120. public:
  121. void processPix(Vector<ShaderComponent*> &componentList,
  122. const MaterialFeatureData &fd) override;
  123. String getName() override { return "Blank Matinfo map"; }
  124. };
  125. class TerrainHeightMapBlendGLSL : public TerrainFeatGLSL
  126. {
  127. public:
  128. void processVert(Vector<ShaderComponent*>& componentList,
  129. const MaterialFeatureData& fd) override;
  130. void processPix(Vector<ShaderComponent*>& componentList,
  131. const MaterialFeatureData& fd) override;
  132. String getName() override { return "Terrain Heightmap Blend"; }
  133. };
  134. #endif // _TERRFEATUREGLSL_H_