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.
1import bevy_pbr::{
2 render::{mesh_view_bindings::globals, forward_io::VertexOutput},
3 prepass::utils,
4};
6struct ShowPrepassSettings {
7 show_depth: u32,
8 show_normals: u32,
9 show_motion_vectors: u32,
10 padding_1: u32,
11 padding_2: u32,
13@group(constants::MATERIAL_BIND_GROUP) @binding(0) var<uniform> settings: ShowPrepassSettings;
15@fragment
16fn fragment(
17 @if(MULTISAMPLED) @builtin(sample_index) sample_index: u32,
18 mesh: VertexOutput,
19) -> @location(0) vec4<f32> {
20 @if(!MULTISAMPLED) let sample_index = 0u;
21 if settings.show_depth == 1u {
22 let depth = bevy_pbr::prepass::utils::prepass_depth(mesh.position, sample_index);
23 return vec4(depth, depth, depth, 1.0);
24 } else if settings.show_normals == 1u {
25 let normal = bevy_pbr::prepass::utils::prepass_normal(mesh.position, sample_index);
26 return vec4(normal, 1.0);
27 } else if settings.show_motion_vectors == 1u {
28 let motion_vector = bevy_pbr::prepass::utils::prepass_motion_vector(mesh.position, sample_index);
29 return vec4(motion_vector / globals.delta_time, 0.0, 1.0);
30 }
32 return vec4(0.0);
Contents