2
0

Common.glsl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2009-2022, 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 F16 EPSILON_F16 = 0.0001hf; // Divisions by this should be OK according to http://weitz.de/ieee/
  12. const ANKI_RP F32 EPSILON_RP = F32(EPSILON_F16);
  13. const U32 MAX_U32 = 0xFFFFFFFFu;
  14. const F32 MAX_F32 = 3.402823e+38;
  15. const F16 MAX_F16 = 65504.0hf;
  16. const F16 MIN_F16 = 0.00006104hf;
  17. const F32 PI = 3.14159265358979323846;
  18. const U32 MAX_UBO_SIZE = 16384u;
  19. const U32 MAX_SHARED_MEMORY = 32u * 1024u;
  20. // Macros
  21. #define UV_TO_NDC(x_) ((x_)*2.0 - 1.0)
  22. #define NDC_TO_UV(x_) ((x_)*0.5 + 0.5)
  23. #define saturate(x_) clamp((x_), 0.0, 1.0)
  24. #define saturateRp(x) min(x, F32(MAX_F16))
  25. #define mad(a_, b_, c_) fma((a_), (b_), (c_))
  26. // Techniques
  27. #define RENDERING_TECHNIQUE_GBUFFER 0
  28. #define RENDERING_TECHNIQUE_GBUFFER_EZ 1
  29. #define RENDERING_TECHNIQUE_SHADOWS 2
  30. #define RENDERING_TECHNIQUE_FORWARD 3