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#import bevy_pbr::mesh_view_bindings::view
2#import bevy_pbr::mesh_functions::get_world_from_local
4#import bevy_pbr::forward_io::Vertex
6struct VertexOutput {
7 @builtin(position) clip_position: vec4<f32>,
8 @location(0) height: f32,
9};
11@vertex
12fn vertex(vertex: Vertex) -> VertexOutput {
13 var out: VertexOutput;
14 let model_matrix = get_world_from_local(vertex.instance_index);
15 let world_position = model_matrix * vec4<f32>(vertex.position, 1.0);
17 out.clip_position = view.clip_from_world * world_position;
19 out.height = vertex.position.y;
21 return out;
24struct HeightSettings {
25 min_height: f32,
26 max_height: f32,
27};
29@group(3) @binding(0)
30var<uniform> settings: HeightSettings;
32@fragment
33fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
34 let span = settings.max_height - settings.min_height;
36 if (span <= 0.0) {
37 return vec4<f32>(0.0, 0.0, 0.0, 1.0);
38 }
40 let normalized_height = (in.height - settings.min_height) / span;
42 return vec4<f32>(normalized_height, 0.0, 0.0, 1.0);
Contents