terrFeatureGLSL.h 5.8 KB

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