Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1// This shader draws the color plane in various color spaces.
2#import bevy_ui::ui_vertex_output::UiVertexOutput
3#import bevy_render::color_operations::{
4 srgb_to_linear_rgb,
5 hsl_to_linear_rgb,
6}
8struct ColorPlaneUniform {
9 fixed_channel : f32,
10#ifdef SIXTEEN_BYTE_ALIGNMENT
11 _webgl2_padding_12b : vec3<f32>,
12#endif
15@group(1) @binding(0) var<uniform> uniform_data : ColorPlaneUniform;
17@fragment
18fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
19 let uv = in.uv;
20#ifdef PLANE_RG
21 return vec4(srgb_to_linear_rgb(vec3(uv.x, uv.y, uniform_data.fixed_channel)), 1.0);
22#else ifdef PLANE_RB
23 return vec4(srgb_to_linear_rgb(vec3(uv.x, uniform_data.fixed_channel, uv.y)), 1.0);
24#else ifdef PLANE_GB
25 return vec4(srgb_to_linear_rgb(vec3(uniform_data.fixed_channel, uv.x, uv.y)), 1.0);
26#else ifdef PLANE_HS
27 return vec4(hsl_to_linear_rgb(vec3(uv.x, 1.0 - uv.y, uniform_data.fixed_channel)), 1.0);
28#else ifdef PLANE_HL
29 return vec4(hsl_to_linear_rgb(vec3(uv.x, uniform_data.fixed_channel, 1.0 - uv.y)), 1.0);
30#else
31 // Error color
32 return vec4(1.0, 0.0, 1.0, 1.0);
33#endif
Contents