Skip to content

Commit 20644d7

Browse files
committed
Add padding for color_plane widget for wasm/webgl compat
Added bevy_feathers to webgpu and webgl cargo feature passing.
1 parent f27ac47 commit 20644d7

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

crates/bevy_feathers/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ accesskit = "0.23"
4040
[features]
4141
default = []
4242
custom_cursor = ["bevy_window/custom_cursor"]
43+
webgl = [ ]
44+
webgpu = [ ]
4345

4446
[lints]
4547
workspace = true

crates/bevy_feathers/src/assets/shaders/color_plane.wgsl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@
55
hsl_to_linear_rgb,
66
}
77

8-
@group(1) @binding(0) var<uniform> fixed_channel: f32;
8+
struct ColorPlaneUniform {
9+
fixed_channel : f32,
10+
#ifdef SIXTEEN_BYTE_ALIGNMENT
11+
_webgl2_padding_12b : vec3<f32>,
12+
#endif
13+
}
14+
15+
@group(1) @binding(0) var<uniform> uniform_data : ColorPlaneUniform;
916

1017
@fragment
1118
fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
1219
let uv = in.uv;
1320
#ifdef PLANE_RG
14-
return vec4(srgb_to_linear_rgb(vec3(uv.x, uv.y, fixed_channel)), 1.0);
21+
return vec4(srgb_to_linear_rgb(vec3(uv.x, uv.y, uniform_data.fixed_channel)), 1.0);
1522
#else ifdef PLANE_RB
16-
return vec4(srgb_to_linear_rgb(vec3(uv.x, fixed_channel, uv.y)), 1.0);
23+
return vec4(srgb_to_linear_rgb(vec3(uv.x, uniform_data.fixed_channel, uv.y)), 1.0);
1724
#else ifdef PLANE_GB
18-
return vec4(srgb_to_linear_rgb(vec3(fixed_channel, uv.x, uv.y)), 1.0);
25+
return vec4(srgb_to_linear_rgb(vec3(uniform_data.fixed_channel, uv.x, uv.y)), 1.0);
1926
#else ifdef PLANE_HS
20-
return vec4(hsl_to_linear_rgb(vec3(uv.x, 1.0 - uv.y, fixed_channel)), 1.0);
27+
return vec4(hsl_to_linear_rgb(vec3(uv.x, 1.0 - uv.y, uniform_data.fixed_channel)), 1.0);
2128
#else ifdef PLANE_HL
22-
return vec4(hsl_to_linear_rgb(vec3(uv.x, fixed_channel, 1.0 - uv.y)), 1.0);
29+
return vec4(hsl_to_linear_rgb(vec3(uv.x, uniform_data.fixed_channel, 1.0 - uv.y)), 1.0);
2330
#else
2431
// Error color
2532
return vec4(1.0, 0.0, 1.0, 1.0);

crates/bevy_feathers/src/controls/color_plane.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ struct ColorPlaneMaterial {
8484

8585
#[uniform(0)]
8686
fixed_channel: f32,
87+
88+
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
89+
#[uniform(0)]
90+
_webgl2_padding_12b: Vec3,
8791
}
8892

8993
impl From<&ColorPlaneMaterial> for ColorPlaneMaterialKey {
@@ -207,6 +211,8 @@ fn update_plane_color(
207211
let material = r_materials.add(ColorPlaneMaterial {
208212
plane: *plane,
209213
fixed_channel: plane_value.0.z,
214+
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
215+
_webgl2_padding_12b: Vec3::ZERO,
210216
});
211217
commands.entity(*inner_ent).insert(MaterialNode(material));
212218
}

crates/bevy_internal/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ webgl = [
191191
"bevy_gizmos_render?/webgl",
192192
"bevy_sprite_render?/webgl",
193193
"bevy_dev_tools?/webgl",
194+
"bevy_feathers?/webgl",
194195
]
195196

196197
webgpu = [
@@ -201,6 +202,7 @@ webgpu = [
201202
"bevy_gizmos_render?/webgpu",
202203
"bevy_sprite_render?/webgpu",
203204
"bevy_dev_tools?/webgpu",
205+
"bevy_feathers?/webgpu",
204206
]
205207

206208
# Enable systems that allow for automated testing on CI

0 commit comments

Comments
 (0)