bumpGLSL.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 _BUMP_GLSL_H_
  23. #define _BUMP_GLSL_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. struct RenderPassData;
  31. class MultiLine;
  32. /// The Bumpmap feature will read the normal map and
  33. /// transform it by the inverse of the worldToTanget
  34. /// matrix. This normal is then used by subsequent
  35. /// shader features.
  36. class BumpFeatGLSL : public ShaderFeatureGLSL
  37. {
  38. public:
  39. // ShaderFeatureGLSL
  40. virtual void processVert( Vector<ShaderComponent*> &componentList,
  41. const MaterialFeatureData &fd );
  42. virtual void processPix( Vector<ShaderComponent*> &componentList,
  43. const MaterialFeatureData &fd );
  44. virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
  45. virtual Resources getResources( const MaterialFeatureData &fd );
  46. virtual void setTexData( Material::StageData &stageDat,
  47. const MaterialFeatureData &fd,
  48. RenderPassData &passData,
  49. U32 &texIndex );
  50. virtual String getName() { return "Bumpmap"; }
  51. };
  52. /// This feature either generates the cheap yet effective offset
  53. /// mapping style parallax or the much more expensive occlusion
  54. /// mapping technique based on the enabled feature flags.
  55. class ParallaxFeatGLSL : public ShaderFeatureGLSL
  56. {
  57. protected:
  58. static Var* _getUniformVar( const char *name,
  59. const char *type,
  60. ConstantSortPosition csp );
  61. ShaderIncludeDependency mIncludeDep;
  62. public:
  63. ParallaxFeatGLSL();
  64. // ShaderFeatureGLSL
  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 void setTexData( Material::StageData &stageDat,
  71. const MaterialFeatureData &fd,
  72. RenderPassData &passData,
  73. U32 &texIndex );
  74. virtual String getName() { return "Parallax"; }
  75. };
  76. /// This feature is used to render normals to the
  77. /// diffuse target for imposter rendering.
  78. class NormalsOutFeatGLSL : public ShaderFeatureGLSL
  79. {
  80. public:
  81. // ShaderFeatureGLSL
  82. virtual void processVert( Vector<ShaderComponent*> &componentList,
  83. const MaterialFeatureData &fd );
  84. virtual void processPix( Vector<ShaderComponent*> &componentList,
  85. const MaterialFeatureData &fd );
  86. virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
  87. virtual String getName() { return "NormalsOut"; }
  88. };
  89. #endif // _BUMP_GLSL_H_