2023-01-19 22:11:13 +00:00
|
|
|
#import bevy_pbr::prepass_bindings
|
|
|
|
#import bevy_pbr::mesh_functions
|
|
|
|
|
|
|
|
// Most of these attributes are not used in the default prepass fragment shader, but they are still needed so we can
|
|
|
|
// pass them to custom prepass shaders like pbr_prepass.wgsl.
|
|
|
|
struct Vertex {
|
|
|
|
@location(0) position: vec3<f32>,
|
|
|
|
|
|
|
|
#ifdef VERTEX_UVS
|
|
|
|
@location(1) uv: vec2<f32>,
|
|
|
|
#endif // VERTEX_UVS
|
|
|
|
|
|
|
|
#ifdef NORMAL_PREPASS
|
|
|
|
@location(2) normal: vec3<f32>,
|
|
|
|
#ifdef VERTEX_TANGENTS
|
|
|
|
@location(3) tangent: vec4<f32>,
|
|
|
|
#endif // VERTEX_TANGENTS
|
|
|
|
#endif // NORMAL_PREPASS
|
|
|
|
|
|
|
|
#ifdef SKINNED
|
|
|
|
@location(4) joint_indices: vec4<u32>,
|
|
|
|
@location(5) joint_weights: vec4<f32>,
|
|
|
|
#endif // SKINNED
|
|
|
|
}
|
|
|
|
|
|
|
|
struct VertexOutput {
|
|
|
|
@builtin(position) clip_position: vec4<f32>,
|
|
|
|
|
|
|
|
#ifdef VERTEX_UVS
|
|
|
|
@location(0) uv: vec2<f32>,
|
|
|
|
#endif // VERTEX_UVS
|
|
|
|
|
|
|
|
#ifdef NORMAL_PREPASS
|
|
|
|
@location(1) world_normal: vec3<f32>,
|
|
|
|
#ifdef VERTEX_TANGENTS
|
|
|
|
@location(2) world_tangent: vec4<f32>,
|
|
|
|
#endif // VERTEX_TANGENTS
|
|
|
|
#endif // NORMAL_PREPASS
|
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
|
|
|
|
|
|
|
#ifdef MOTION_VECTOR_PREPASS
|
|
|
|
@location(3) world_position: vec4<f32>,
|
|
|
|
@location(4) previous_world_position: vec4<f32>,
|
|
|
|
#endif // MOTION_VECTOR_PREPASS
|
2023-01-19 22:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@vertex
|
|
|
|
fn vertex(vertex: Vertex) -> VertexOutput {
|
|
|
|
var out: VertexOutput;
|
|
|
|
|
|
|
|
#ifdef SKINNED
|
|
|
|
var model = skin_model(vertex.joint_indices, vertex.joint_weights);
|
|
|
|
#else // SKINNED
|
|
|
|
var model = mesh.model;
|
|
|
|
#endif // SKINNED
|
|
|
|
|
|
|
|
out.clip_position = mesh_position_local_to_clip(model, vec4(vertex.position, 1.0));
|
2023-03-02 08:21:21 +00:00
|
|
|
#ifdef DEPTH_CLAMP_ORTHO
|
|
|
|
out.clip_position.z = min(out.clip_position.z, 1.0);
|
|
|
|
#endif // DEPTH_CLAMP_ORTHO
|
2023-01-19 22:11:13 +00:00
|
|
|
|
|
|
|
#ifdef VERTEX_UVS
|
|
|
|
out.uv = vertex.uv;
|
|
|
|
#endif // VERTEX_UVS
|
|
|
|
|
|
|
|
#ifdef NORMAL_PREPASS
|
|
|
|
#ifdef SKINNED
|
|
|
|
out.world_normal = skin_normals(model, vertex.normal);
|
|
|
|
#else // SKINNED
|
|
|
|
out.world_normal = mesh_normal_local_to_world(vertex.normal);
|
|
|
|
#endif // SKINNED
|
|
|
|
|
|
|
|
#ifdef VERTEX_TANGENTS
|
|
|
|
out.world_tangent = mesh_tangent_local_to_world(model, vertex.tangent);
|
|
|
|
#endif // VERTEX_TANGENTS
|
|
|
|
#endif // NORMAL_PREPASS
|
|
|
|
|
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
|
|
|
#ifdef MOTION_VECTOR_PREPASS
|
|
|
|
out.world_position = mesh_position_local_to_world(model, vec4<f32>(vertex.position, 1.0));
|
|
|
|
out.previous_world_position = mesh_position_local_to_world(mesh.previous_model, vec4<f32>(vertex.position, 1.0));
|
|
|
|
#endif // MOTION_VECTOR_PREPASS
|
|
|
|
|
2023-01-19 22:11:13 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
#ifdef PREPASS_FRAGMENT
|
2023-01-19 22:11:13 +00:00
|
|
|
struct FragmentInput {
|
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
|
|
|
#ifdef NORMAL_PREPASS
|
2023-01-19 22:11:13 +00:00
|
|
|
@location(1) world_normal: vec3<f32>,
|
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
|
|
|
#endif // NORMAL_PREPASS
|
|
|
|
|
|
|
|
#ifdef MOTION_VECTOR_PREPASS
|
|
|
|
@location(3) world_position: vec4<f32>,
|
|
|
|
@location(4) previous_world_position: vec4<f32>,
|
|
|
|
#endif // MOTION_VECTOR_PREPASS
|
|
|
|
}
|
|
|
|
|
|
|
|
struct FragmentOutput {
|
|
|
|
#ifdef NORMAL_PREPASS
|
|
|
|
@location(0) normal: vec4<f32>,
|
|
|
|
#endif // NORMAL_PREPASS
|
|
|
|
|
|
|
|
#ifdef MOTION_VECTOR_PREPASS
|
|
|
|
@location(1) motion_vector: vec2<f32>,
|
|
|
|
#endif // MOTION_VECTOR_PREPASS
|
2023-01-19 22:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@fragment
|
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
|
|
|
fn fragment(in: FragmentInput) -> FragmentOutput {
|
|
|
|
var out: FragmentOutput;
|
|
|
|
|
|
|
|
#ifdef NORMAL_PREPASS
|
|
|
|
out.normal = vec4(in.world_normal * 0.5 + vec3(0.5), 1.0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOTION_VECTOR_PREPASS
|
|
|
|
let clip_position_t = view.unjittered_view_proj * in.world_position;
|
|
|
|
let clip_position = clip_position_t.xy / clip_position_t.w;
|
|
|
|
let previous_clip_position_t = previous_view_proj * in.previous_world_position;
|
|
|
|
let previous_clip_position = previous_clip_position_t.xy / previous_clip_position_t.w;
|
|
|
|
// These motion vectors are used as offsets to UV positions and are stored
|
|
|
|
// in the range -1,1 to allow offsetting from the one corner to the
|
|
|
|
// diagonally-opposite corner in UV coordinates, in either direction.
|
|
|
|
// A difference between diagonally-opposite corners of clip space is in the
|
|
|
|
// range -2,2, so this needs to be scaled by 0.5. And the V direction goes
|
|
|
|
// down where clip space y goes up, so y needs to be flipped.
|
|
|
|
out.motion_vector = (clip_position - previous_clip_position) * vec2(0.5, -0.5);
|
|
|
|
#endif // MOTION_VECTOR_PREPASS
|
|
|
|
|
|
|
|
return out;
|
2023-01-19 22:11:13 +00:00
|
|
|
}
|
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
|
|
|
#endif // PREPASS_FRAGMENT
|