terrFeatureGLSL.h 5.3 KB

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