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_render::view::View
2#import bevy_core_pipeline::fullscreen_vertex_shader::FullscreenVertexOutput
3#import bevy_pbr::view_transformations::uv_to_ndc
5struct PreviousViewUniforms {
6 view_from_world: mat4x4<f32>,
7 clip_from_world: mat4x4<f32>,
8 clip_from_view: mat4x4<f32>,
9 world_from_clip: mat4x4<f32>,
10 view_from_clip: mat4x4<f32>,
13@group(0) @binding(0) var<uniform> view: View;
14@group(0) @binding(1) var<uniform> previous_view: PreviousViewUniforms;
16@fragment
17fn fragment(in: FullscreenVertexOutput) -> @location(1) vec4<f32> {
18 let clip_pos = uv_to_ndc(in.uv); // Convert from uv to clip space
19 let world_pos = view.world_from_clip * vec4(clip_pos, 0.0, 1.0);
20 let prev_clip_pos = (previous_view.clip_from_world * world_pos).xy;
21 let velocity = (clip_pos - prev_clip_pos) * vec2(0.5, -0.5); // Copied from mesh motion vectors
23 return vec4(velocity.x, velocity.y, 0.0, 1.0);
Contents