lm_common_inc.glsl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. layout(set = 0, binding = 0) uniform BakeParameters {
  2. vec3 world_size;
  3. float bias;
  4. vec3 to_cell_offset;
  5. int grid_size;
  6. vec3 to_cell_size;
  7. uint light_count;
  8. mat3x4 env_transform;
  9. ivec2 atlas_size;
  10. float exposure_normalization;
  11. uint bounces;
  12. float bounce_indirect_energy;
  13. int shadowmask_light_idx;
  14. uint transparency_rays;
  15. float supersampling_factor;
  16. }
  17. bake_params;
  18. struct Vertex {
  19. vec3 position;
  20. float normal_z;
  21. vec2 uv;
  22. vec2 normal_xy;
  23. };
  24. layout(set = 0, binding = 1, std430) restrict readonly buffer Vertices {
  25. Vertex data[];
  26. }
  27. vertices;
  28. #define CULL_DISABLED 0
  29. #define CULL_FRONT 1
  30. #define CULL_BACK 2
  31. struct Triangle {
  32. uvec3 indices;
  33. uint slice;
  34. vec3 min_bounds;
  35. uint cull_mode;
  36. vec3 max_bounds;
  37. uint pad1;
  38. };
  39. struct ClusterAABB {
  40. vec3 min_bounds;
  41. uint pad0;
  42. vec3 max_bounds;
  43. uint pad1;
  44. };
  45. layout(set = 0, binding = 2, std430) restrict readonly buffer Triangles {
  46. Triangle data[];
  47. }
  48. triangles;
  49. layout(set = 0, binding = 3, std430) restrict readonly buffer TriangleIndices {
  50. uint data[];
  51. }
  52. triangle_indices;
  53. #define LIGHT_TYPE_DIRECTIONAL 0
  54. #define LIGHT_TYPE_OMNI 1
  55. #define LIGHT_TYPE_SPOT 2
  56. struct Light {
  57. vec3 position;
  58. uint type;
  59. vec3 direction;
  60. float energy;
  61. vec3 color;
  62. float size;
  63. float range;
  64. float attenuation;
  65. float cos_spot_angle;
  66. float inv_spot_attenuation;
  67. float indirect_energy;
  68. float shadow_blur;
  69. bool static_bake;
  70. uint pad;
  71. };
  72. layout(set = 0, binding = 4, std430) restrict readonly buffer Lights {
  73. Light data[];
  74. }
  75. lights;
  76. struct Seam {
  77. uvec2 a;
  78. uvec2 b;
  79. };
  80. layout(set = 0, binding = 5, std430) restrict readonly buffer Seams {
  81. Seam data[];
  82. }
  83. seams;
  84. layout(set = 0, binding = 6, std430) restrict readonly buffer Probes {
  85. vec4 data[];
  86. }
  87. probe_positions;
  88. layout(set = 0, binding = 7) uniform utexture3D grid;
  89. layout(set = 0, binding = 8) uniform texture2DArray albedo_tex;
  90. layout(set = 0, binding = 9) uniform texture2DArray emission_tex;
  91. layout(set = 0, binding = 10) uniform sampler linear_sampler;
  92. layout(set = 0, binding = 11, std430) restrict readonly buffer ClusterIndices {
  93. uint data[];
  94. }
  95. cluster_indices;
  96. layout(set = 0, binding = 12, std430) restrict readonly buffer ClusterAABBs {
  97. ClusterAABB data[];
  98. }
  99. cluster_aabbs;
  100. // Fragment action constants
  101. const uint FA_NONE = 0;
  102. const uint FA_SMOOTHEN_POSITION = 1;