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::{
2 mesh_view_bindings::globals,
3 prepass_utils,
4 forward_io::VertexOutput,
5}
7struct ShowPrepassSettings {
8 show_depth: u32,
9 show_normals: u32,
10 show_motion_vectors: u32,
11 padding_1: u32,
12 padding_2: u32,
14@group(2) @binding(0) var<uniform> settings: ShowPrepassSettings;
16@fragment
17fn fragment(
18#ifdef MULTISAMPLED
19 @builtin(sample_index) sample_index: u32,
20#endif
21 mesh: VertexOutput,
22) -> @location(0) vec4<f32> {
23#ifndef MULTISAMPLED
24 let sample_index = 0u;
25#endif
26 if settings.show_depth == 1u {
27 let depth = bevy_pbr::prepass_utils::prepass_depth(mesh.position, sample_index);
28 return vec4(depth, depth, depth, 1.0);
29 } else if settings.show_normals == 1u {
30 let normal = bevy_pbr::prepass_utils::prepass_normal(mesh.position, sample_index);
31 return vec4(normal, 1.0);
32 } else if settings.show_motion_vectors == 1u {
33 let motion_vector = bevy_pbr::prepass_utils::prepass_motion_vector(mesh.position, sample_index);
34 return vec4(motion_vector / globals.delta_time, 0.0, 1.0);
35 }
37 return vec4(0.0);
Contents