Common.glsl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (C) 2009-2017, Panagiotis Christopoulos Charitos and contributors.
  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 recomended to include it
  6. #ifndef ANKI_SHADERS_COMMON_GLSL
  7. #define ANKI_SHADERS_COMMON_GLSL
  8. // WORKAROUND
  9. #if defined(ANKI_VENDOR_NVIDIA)
  10. #define NVIDIA_LINK_ERROR_WORKAROUND 1
  11. #else
  12. #define NVIDIA_LINK_ERROR_WORKAROUND 0
  13. #endif
  14. // Default precision
  15. #ifndef DEFAULT_FLOAT_PRECISION
  16. #define DEFAULT_FLOAT_PRECISION highp
  17. #endif
  18. #ifndef DEFAULT_INT_PRECISION
  19. #define DEFAULT_INT_PRECISION highp
  20. #endif
  21. precision DEFAULT_FLOAT_PRECISION float;
  22. precision DEFAULT_INT_PRECISION int;
  23. const float EPSILON = 0.000001;
  24. const float PI = 3.14159265358979323846;
  25. const uint UBO_MAX_SIZE = 16384u;
  26. const uint MAX_U32 = 0xFFFFFFFFu;
  27. #define UV_TO_NDC(x_) ((x_)*2.0 - 1.0)
  28. #define NDC_TO_UV(x_) ((x_)*0.5 + 0.5)
  29. // Common locations
  30. #define POSITION_LOCATION 0
  31. #define TEXTURE_COORDINATE_LOCATION 1
  32. #define NORMAL_LOCATION 2
  33. #define TANGENT_LOCATION 3
  34. #define SCALE_LOCATION 1
  35. #define ALPHA_LOCATION 2
  36. #if !defined(ANKI_ARB_SHADER_BALLOT)
  37. #define readFirstInvocationARB(x_) (x_)
  38. #endif
  39. #endif