This example is running in WebGL2 and should work in most browsers. You can check the WebGPU examples here.
//! A shader and a material that uses it.
use ;
/// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PATH: &str = "shaders/custom_material_2d.wgsl";
// Setup a simple 2d scene
// This is the struct that will be passed to your shader
/// The Material2d trait is very configurable, but comes with sensible defaults for all methods.
/// You only need to implement functions for features that need non-default behavior. See the Material2d api docs for details!
#import bevy_sprite::mesh2d_vertex_output::VertexOutput
// we can import items from shader modules in the assets folder with a quoted path
#import "shaders/custom_material_import.wgsl"::COLOR_MULTIPLIER
(2) (0) var<uniform> material_color: vec4<f32>;
(2) (1) var base_color_texture: texture_2d<f32>;
(2) (2) var base_color_sampler: sampler;
fn -> (0) vec4<f32> {
return material_color * * COLOR_MULTIPLIER;
}