2023-01-19 22:11:13 +00:00
|
|
|
#import bevy_pbr::mesh_types
|
|
|
|
#import bevy_pbr::mesh_view_bindings
|
2023-01-24 20:36:40 +00:00
|
|
|
#import bevy_pbr::prepass_utils
|
2023-01-19 22:11:13 +00:00
|
|
|
|
2023-03-02 02:23:06 +00:00
|
|
|
struct ShowPrepassSettings {
|
|
|
|
show_depth: u32,
|
|
|
|
show_normals: u32,
|
Temporal Antialiasing (TAA) (#7291)
![image](https://user-images.githubusercontent.com/47158642/214374911-412f0986-3927-4f7a-9a6c-413bdee6b389.png)
# Objective
- Implement an alternative antialias technique
- TAA scales based off of view resolution, not geometry complexity
- TAA filters textures, firefly pixels, and other aliasing not covered
by MSAA
- TAA additionally will reduce noise / increase quality in future
stochastic rendering techniques
- Closes https://github.com/bevyengine/bevy/issues/3663
## Solution
- Add a temporal jitter component
- Add a motion vector prepass
- Add a TemporalAntialias component and plugin
- Combine existing MSAA and FXAA examples and add TAA
## Followup Work
- Prepass motion vector support for skinned meshes
- Move uniforms needed for motion vectors into a separate bind group,
instead of using different bind group layouts
- Reuse previous frame's GPU view buffer for motion vectors, instead of
recomputing
- Mip biasing for sharper textures, and or unjitter texture UVs
https://github.com/bevyengine/bevy/issues/7323
- Compute shader for better performance
- Investigate FSR techniques
- Historical depth based disocclusion tests, for geometry disocclusion
- Historical luminance/hue based tests, for shading disocclusion
- Pixel "locks" to reduce blending rate / revamp history confidence
mechanism
- Orthographic camera support for TemporalJitter
- Figure out COD's 1-tap bicubic filter
---
## Changelog
- Added MotionVectorPrepass and TemporalJitter
- Added TemporalAntialiasPlugin, TemporalAntialiasBundle, and
TemporalAntialiasSettings
---------
Co-authored-by: IceSentry <c.giguere42@gmail.com>
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
Co-authored-by: Robert Swain <robert.swain@gmail.com>
Co-authored-by: Daniel Chia <danstryder@gmail.com>
Co-authored-by: robtfm <50659922+robtfm@users.noreply.github.com>
Co-authored-by: Brandon Dyer <brandondyer64@gmail.com>
Co-authored-by: Edgar Geier <geieredgar@gmail.com>
2023-03-27 22:22:40 +00:00
|
|
|
show_motion_vectors: u32,
|
2023-03-02 02:23:06 +00:00
|
|
|
padding_1: u32,
|
|
|
|
padding_2: u32,
|
|
|
|
}
|
2023-01-19 22:11:13 +00:00
|
|
|
@group(1) @binding(0)
|
2023-03-02 02:23:06 +00:00
|
|
|
var<uniform> settings: ShowPrepassSettings;
|
2023-01-19 22:11:13 +00:00
|
|
|
|
|
|
|
@fragment
|
|
|
|
fn fragment(
|
|
|
|
@builtin(position) frag_coord: vec4<f32>,
|
2023-05-29 15:25:32 +00:00
|
|
|
#ifdef MULTISAMPLED
|
2023-01-19 22:11:13 +00:00
|
|
|
@builtin(sample_index) sample_index: u32,
|
2023-05-29 15:25:32 +00:00
|
|
|
#endif
|
2023-01-19 22:11:13 +00:00
|
|
|
#import bevy_pbr::mesh_vertex_output
|
|
|
|
) -> @location(0) vec4<f32> {
|
2023-05-29 15:25:32 +00:00
|
|
|
#ifndef MULTISAMPLED
|
|
|
|
let sample_index = 0u;
|
|
|
|
#endif
|
2023-03-02 02:23:06 +00:00
|
|
|
if settings.show_depth == 1u {
|
2023-01-19 22:11:13 +00:00
|
|
|
let depth = prepass_depth(frag_coord, sample_index);
|
|
|
|
return vec4(depth, depth, depth, 1.0);
|
2023-03-02 02:23:06 +00:00
|
|
|
} else if settings.show_normals == 1u {
|
2023-01-19 22:11:13 +00:00
|
|
|
let normal = prepass_normal(frag_coord, sample_index);
|
|
|
|
return vec4(normal, 1.0);
|
Temporal Antialiasing (TAA) (#7291)
![image](https://user-images.githubusercontent.com/47158642/214374911-412f0986-3927-4f7a-9a6c-413bdee6b389.png)
# Objective
- Implement an alternative antialias technique
- TAA scales based off of view resolution, not geometry complexity
- TAA filters textures, firefly pixels, and other aliasing not covered
by MSAA
- TAA additionally will reduce noise / increase quality in future
stochastic rendering techniques
- Closes https://github.com/bevyengine/bevy/issues/3663
## Solution
- Add a temporal jitter component
- Add a motion vector prepass
- Add a TemporalAntialias component and plugin
- Combine existing MSAA and FXAA examples and add TAA
## Followup Work
- Prepass motion vector support for skinned meshes
- Move uniforms needed for motion vectors into a separate bind group,
instead of using different bind group layouts
- Reuse previous frame's GPU view buffer for motion vectors, instead of
recomputing
- Mip biasing for sharper textures, and or unjitter texture UVs
https://github.com/bevyengine/bevy/issues/7323
- Compute shader for better performance
- Investigate FSR techniques
- Historical depth based disocclusion tests, for geometry disocclusion
- Historical luminance/hue based tests, for shading disocclusion
- Pixel "locks" to reduce blending rate / revamp history confidence
mechanism
- Orthographic camera support for TemporalJitter
- Figure out COD's 1-tap bicubic filter
---
## Changelog
- Added MotionVectorPrepass and TemporalJitter
- Added TemporalAntialiasPlugin, TemporalAntialiasBundle, and
TemporalAntialiasSettings
---------
Co-authored-by: IceSentry <c.giguere42@gmail.com>
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
Co-authored-by: Robert Swain <robert.swain@gmail.com>
Co-authored-by: Daniel Chia <danstryder@gmail.com>
Co-authored-by: robtfm <50659922+robtfm@users.noreply.github.com>
Co-authored-by: Brandon Dyer <brandondyer64@gmail.com>
Co-authored-by: Edgar Geier <geieredgar@gmail.com>
2023-03-27 22:22:40 +00:00
|
|
|
} else if settings.show_motion_vectors == 1u {
|
|
|
|
let motion_vector = prepass_motion_vector(frag_coord, sample_index);
|
|
|
|
return vec4(motion_vector / globals.delta_time, 0.0, 1.0);
|
2023-01-19 22:11:13 +00:00
|
|
|
}
|
2023-03-02 02:23:06 +00:00
|
|
|
|
|
|
|
return vec4(0.0);
|
2023-01-19 22:11:13 +00:00
|
|
|
}
|