Files
bevy/assets/shaders/storage_buffer.wgsl
charlotte 🌸 e6ec2c181d Material bind group shader def (#20069)
Use a shader def for the material bind group index to make it easier for
when we want to switch back to group 2 in the future without breaking
everyone again.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: atlv <email@atlasdostal.com>
Co-authored-by: atlas dostal <rodol@rivalrebels.com>
2025-08-06 05:09:12 +00:00

36 lines
1014 B
WebGPU Shading Language

#import bevy_pbr::{
mesh_functions,
view_transformations::position_world_to_clip
}
@group(#{MATERIAL_BIND_GROUP}) @binding(0) var<storage, read> colors: array<vec4<f32>, 5>;
struct Vertex {
@builtin(instance_index) instance_index: u32,
@location(0) position: vec3<f32>,
};
struct VertexOutput {
@builtin(position) clip_position: vec4<f32>,
@location(0) world_position: vec4<f32>,
@location(1) color: vec4<f32>,
};
@vertex
fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
let tag = mesh_functions::get_tag(vertex.instance_index);
var world_from_local = mesh_functions::get_world_from_local(vertex.instance_index);
out.world_position = mesh_functions::mesh_position_local_to_world(world_from_local, vec4(vertex.position, 1.0));
out.clip_position = position_world_to_clip(out.world_position.xyz);
out.color = colors[tag];
return out;
}
@fragment
fn fragment(
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
return mesh.color;
}