2022-12-24 23:41:59 +00:00
|
|
|
/// This code is prepended to gradient/common.wgsl and is specialised for uniform buffers
|
2021-10-20 21:44:06 +00:00
|
|
|
|
|
|
|
struct Gradient {
|
2022-12-24 21:50:41 +00:00
|
|
|
colors: array<vec4<f32>, 16>,
|
2022-12-24 22:21:58 +00:00
|
|
|
ratios: array<vec4<f32>, 4u>, // secretly array<f32; 16> but this let's us squeeze it into alignment
|
2022-07-02 12:18:30 +00:00
|
|
|
gradient_type: i32,
|
|
|
|
num_colors: u32,
|
|
|
|
interpolation: i32,
|
|
|
|
focal_point: f32,
|
2021-10-20 21:44:06 +00:00
|
|
|
};
|
|
|
|
|
2022-12-27 22:18:03 +00:00
|
|
|
@group(3) @binding(1) var<uniform> gradient: Gradient;
|
2021-10-20 21:44:06 +00:00
|
|
|
|
2022-12-24 22:21:58 +00:00
|
|
|
fn ratio(i: u32) -> f32 {
|
|
|
|
return gradient.ratios[i / 4u][i % 4u];
|
|
|
|
}
|