mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
* basic working wgpu @ webgl on websys * fix glow compile error * introduced WebPainter trait, provide wgpu renderstate * WebPainterWgpu destroy implemented * make custom3d demo work on wgpu backend * changelog entry for wgpu support eframe wasm * remove temporary logging hack * stop using pollster for web we're actually not allowed to block - this only worked because wgpu on webgl doesn't actually cause anything blocking. However, when trying webgpu this became an issue * revert cargo update * compile error if neither glow nor wgpu features are enabled * code cleanup * Error handling * Update changelog with link * Make sure --all-features work * Select best framebuffer format from the available ones * update to wasm-bindgen 0.2.83 * Fix typo * Clean up Cargo.toml * Log about using the wgpu painter * fixup wgpu labels * fix custom3d_wgpu_shader ub padding * remove duplicated uniforms struct in wgsl shader for custom3d * Update docs: add async/await to the web 'start' function Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
40 lines
904 B
WebGPU Shading Language
40 lines
904 B
WebGPU Shading Language
struct VertexOut {
|
|
@location(0) color: vec4<f32>,
|
|
@builtin(position) position: vec4<f32>,
|
|
};
|
|
|
|
struct Uniforms {
|
|
@size(16) angle: f32, // pad to 16 bytes
|
|
};
|
|
|
|
@group(0) @binding(0)
|
|
var<uniform> uniforms: Uniforms;
|
|
|
|
var<private> v_positions: array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
vec2<f32>(0.0, 1.0),
|
|
vec2<f32>(1.0, -1.0),
|
|
vec2<f32>(-1.0, -1.0),
|
|
);
|
|
|
|
var<private> v_colors: array<vec4<f32>, 3> = array<vec4<f32>, 3>(
|
|
vec4<f32>(1.0, 0.0, 0.0, 1.0),
|
|
vec4<f32>(0.0, 1.0, 0.0, 1.0),
|
|
vec4<f32>(0.0, 0.0, 1.0, 1.0),
|
|
);
|
|
|
|
@vertex
|
|
fn vs_main(@builtin(vertex_index) v_idx: u32) -> VertexOut {
|
|
var out: VertexOut;
|
|
|
|
out.position = vec4<f32>(v_positions[v_idx], 0.0, 1.0);
|
|
out.position.x = out.position.x * cos(uniforms.angle);
|
|
out.color = v_colors[v_idx];
|
|
|
|
return out;
|
|
}
|
|
|
|
@fragment
|
|
fn fs_main(in: VertexOut) -> @location(0) vec4<f32> {
|
|
return in.color;
|
|
}
|