Common.glsl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // This file contains common code for all shaders. It's optional but it's
  6. // recomended to include it
  7. #ifndef ANKI_SHADERS_COMMON_GLSL
  8. #define ANKI_SHADERS_COMMON_GLSL
  9. // Default precision
  10. #ifndef DEFAULT_FLOAT_PRECISION
  11. #define DEFAULT_FLOAT_PRECISION highp
  12. #endif
  13. #ifndef DEFAULT_INT_PRECISION
  14. #define DEFAULT_INT_PRECISION highp
  15. #endif
  16. precision DEFAULT_FLOAT_PRECISION float;
  17. precision DEFAULT_FLOAT_PRECISION int;
  18. const float EPSILON = 0.000001;
  19. const float PI = 3.14159265358979323846;
  20. // Read from a render target texture
  21. //#define textureRt(tex_, texc_) texture(tex_, texc_)
  22. #define textureRt(tex_, texc_) textureLod(tex_, texc_, 0.0)
  23. // Binding
  24. #define UBO_BINDING(slot_, binding_) binding = slot_ * 1 + binding_
  25. #define SS_BINDING(slot_, binding_) binding = slot_ * 8 + binding_
  26. #define TEX_BINDING(slot_, binding_) binding = slot_ * 8 + binding_
  27. // Common locations
  28. #define POSITION_LOCATION 0
  29. #define TEXTURE_COORDINATE_LOCATION 1
  30. #define NORMAL_LOCATION 2
  31. #define TANGENT_LOCATION 3
  32. #define SCALE_LOCATION 1
  33. #define ALPHA_LOCATION 2
  34. #endif