This example is running in WebGL2 and should work in most browsers. You can check the WebGPU examples here.
shader_material_2d.rs:
//! A shader and a material that uses it.
use ;
// 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!
shaders/custom_material_2d.wgsl:
#import VertexOutput
// we can import items from shader modules in the assets folder with a quoted path
#import "shaders/custom_material_import.wgsl"COLOR_MULTIPLIER
@group @binding material_color: ;
@group @binding var base_color_texture: ;
@group @binding var base_color_sampler: sampler;
@fragment
@location