bumpGLSL.h 3.8 KB

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