terrFeatureGLSL.h 4.7 KB

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