Common.glsl 867 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (C) 2009-2021, 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. #pragma once
  7. #include <AnKi/Shaders/Include/Common.h>
  8. #include <AnKi/Shaders/TextureFunctions.glsl>
  9. // Constants
  10. const F32 EPSILON = 0.000001;
  11. const F32 FLT_MAX = 3.402823e+38;
  12. const U32 MAX_U32 = 0xFFFFFFFFu;
  13. const F32 PI = 3.14159265358979323846;
  14. const U32 MAX_UBO_SIZE = 16384u;
  15. const U32 MAX_SHARED_MEMORY = 32u * 1024u;
  16. // Macros
  17. #define UV_TO_NDC(x_) ((x_)*2.0 - 1.0)
  18. #define NDC_TO_UV(x_) ((x_)*0.5 + 0.5)
  19. #define saturate(x_) clamp((x_), 0.0, 1.0)
  20. #define mad(a_, b_, c_) fma((a_), (b_), (c_))
  21. // Passes
  22. #define PASS_GB 0
  23. #define PASS_FS 1
  24. #define PASS_SM 2
  25. #define PASS_EZ 3