Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1// For 2d replace `bevy_pbr::render::mesh_functions` with `bevy_sprite_render::mesh2d::functions`
2// and `mesh_position_local_to_clip` with `mesh2d_position_local_to_clip`.
3import bevy_pbr::render::mesh_functions::{get_world_from_local, mesh_position_local_to_clip};
5struct CustomMaterial {
6 color: vec4<f32>,
7};
8@group(constants::MATERIAL_BIND_GROUP) @binding(0) var<uniform> material: CustomMaterial;
10struct Vertex {
11 @builtin(instance_index) instance_index: u32,
12 @location(0) position: vec3<f32>,
13 @location(1) blend_color: vec4<f32>,
14};
16struct VertexOutput {
17 @builtin(position) clip_position: vec4<f32>,
18 @location(0) blend_color: vec4<f32>,
19};
21@vertex
22fn vertex(vertex: Vertex) -> VertexOutput {
23 var out: VertexOutput;
24 out.clip_position = mesh_position_local_to_clip(
25 get_world_from_local(vertex.instance_index),
26 vec4<f32>(vertex.position, 1.0),
27 );
28 out.blend_color = vertex.blend_color;
29 return out;
32struct FragmentInput {
33 @location(0) blend_color: vec4<f32>,
34};
36@fragment
37fn fragment(input: FragmentInput) -> @location(0) vec4<f32> {
38 return material.color * input.blend_color;
Contents