canvas_uniforms_inc.glsl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #define MAX_LIGHTS_PER_ITEM uint(16)
  2. #define M_PI 3.14159265359
  3. #define SDF_MAX_LENGTH 16384.0
  4. //1 means enabled, 2+ means trails in use
  5. #define FLAGS_INSTANCING_MASK uint(0x7F)
  6. #define FLAGS_INSTANCING_HAS_COLORS uint(1 << 7)
  7. #define FLAGS_INSTANCING_HAS_CUSTOM_DATA uint(1 << 8)
  8. #define FLAGS_CLIP_RECT_UV uint(1 << 9)
  9. #define FLAGS_TRANSPOSE_RECT uint(1 << 10)
  10. #define FLAGS_USING_LIGHT_MASK uint(1 << 11)
  11. #define FLAGS_NINEPACH_DRAW_CENTER uint(1 << 12)
  12. #define FLAGS_USING_PARTICLES uint(1 << 13)
  13. #define FLAGS_NINEPATCH_H_MODE_SHIFT 16
  14. #define FLAGS_NINEPATCH_V_MODE_SHIFT 18
  15. #define FLAGS_LIGHT_COUNT_SHIFT 20
  16. #define FLAGS_DEFAULT_NORMAL_MAP_USED uint(1 << 26)
  17. #define FLAGS_DEFAULT_SPECULAR_MAP_USED uint(1 << 27)
  18. #define FLAGS_USE_MSDF uint(1 << 28)
  19. #define FLAGS_USE_LCD uint(1 << 29)
  20. #define FLAGS_FLIP_H uint(1 << 30)
  21. #define FLAGS_FLIP_V uint(1 << 31)
  22. layout(std140) uniform GlobalShaderUniformData { //ubo:1
  23. vec4 global_shader_uniforms[MAX_GLOBAL_SHADER_UNIFORMS];
  24. };
  25. layout(std140) uniform CanvasData { //ubo:0
  26. mat4 canvas_transform;
  27. mat4 screen_transform;
  28. mat4 canvas_normal_transform;
  29. vec4 canvas_modulation;
  30. vec2 screen_pixel_size;
  31. float time;
  32. bool use_pixel_snap;
  33. vec4 sdf_to_tex;
  34. vec2 screen_to_sdf;
  35. vec2 sdf_to_screen;
  36. uint directional_light_count;
  37. float tex_to_sdf;
  38. uint pad1;
  39. uint pad2;
  40. };
  41. #ifndef DISABLE_LIGHTING
  42. #define LIGHT_FLAGS_BLEND_MASK uint(3 << 16)
  43. #define LIGHT_FLAGS_BLEND_MODE_ADD uint(0 << 16)
  44. #define LIGHT_FLAGS_BLEND_MODE_SUB uint(1 << 16)
  45. #define LIGHT_FLAGS_BLEND_MODE_MIX uint(2 << 16)
  46. #define LIGHT_FLAGS_BLEND_MODE_MASK uint(3 << 16)
  47. #define LIGHT_FLAGS_HAS_SHADOW uint(1 << 20)
  48. #define LIGHT_FLAGS_FILTER_SHIFT 22
  49. #define LIGHT_FLAGS_FILTER_MASK uint(3 << 22)
  50. #define LIGHT_FLAGS_SHADOW_NEAREST uint(0 << 22)
  51. #define LIGHT_FLAGS_SHADOW_PCF5 uint(1 << 22)
  52. #define LIGHT_FLAGS_SHADOW_PCF13 uint(2 << 22)
  53. struct Light {
  54. mat2x4 texture_matrix; //light to texture coordinate matrix (transposed)
  55. mat2x4 shadow_matrix; //light to shadow coordinate matrix (transposed)
  56. vec4 color;
  57. uint shadow_color; // packed
  58. uint flags; //index to light texture
  59. float shadow_pixel_size;
  60. float height;
  61. vec2 position;
  62. float shadow_zfar_inv;
  63. float shadow_y_ofs;
  64. vec4 atlas_rect;
  65. };
  66. layout(std140) uniform LightData { //ubo:2
  67. Light light_array[MAX_LIGHTS];
  68. };
  69. #endif // DISABLE_LIGHTING