Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporal Antialiasing (TAA) #7291

Merged
merged 392 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
392 commits
Select commit Hold shift + click to select a range
3923ede
Reduce TAA flickering
JMS55 Dec 8, 2022
cbbee68
Add taa velocity dilation
JMS55 Dec 8, 2022
83f82a6
Camera jitter cleanup
JMS55 Dec 8, 2022
dade3a1
Remove TAA blit pass
JMS55 Dec 8, 2022
6f699a4
TAA pipeline specialization
JMS55 Dec 8, 2022
526de34
Fix TAA hdr shader defs
JMS55 Dec 8, 2022
fed969e
Default to SSAO high, add custom quality
JMS55 Dec 8, 2022
bb4d157
Fix SSAO example
JMS55 Dec 8, 2022
3b57a03
Misc doc fix
JMS55 Dec 8, 2022
9928498
Double buffer TAA textures
JMS55 Dec 9, 2022
82088fb
Fix karis weight
JMS55 Dec 9, 2022
f355dfc
Fix TAA anti flicker
JMS55 Dec 10, 2022
783e020
Add TAA references
JMS55 Dec 10, 2022
4949cab
Misc fix
JMS55 Dec 10, 2022
bc14ad2
Ensure TAA goes before bloom
JMS55 Dec 10, 2022
e100d65
Remove failed anti flicker
JMS55 Dec 10, 2022
54997e3
Misc fix
JMS55 Dec 10, 2022
49af70d
Add second SSAO denoise pass
JMS55 Dec 10, 2022
71703b4
Misc fix
JMS55 Dec 10, 2022
d588b7e
Use R16 textures for SSAO
JMS55 Dec 10, 2022
5b54ab6
Misc tweaks
JMS55 Dec 10, 2022
9b191ad
Fix denoise missing right visibility
JMS55 Dec 11, 2022
2a12bf0
Unroll GTAO side loop
JMS55 Dec 11, 2022
04c114e
Misc cleanup
JMS55 Dec 11, 2022
ade10a5
Revert "Add second SSAO denoise pass"
JMS55 Dec 11, 2022
d077237
address pr comments
IceSentry Dec 12, 2022
ef4b3e9
Merge branch 'main' into depth-prepass
IceSentry Dec 12, 2022
314dea0
docs
IceSentry Dec 12, 2022
8719d47
Add depth based disocclusion test for TAA
JMS55 Dec 15, 2022
3c17e29
Doc comment
JMS55 Dec 15, 2022
8f269ca
Add another TAA reference
JMS55 Dec 15, 2022
a6b120d
Add more TAA references
JMS55 Dec 18, 2022
42f9282
Make TAA settings field public
JMS55 Dec 18, 2022
b904fb7
Misc GTAO optimization
JMS55 Dec 21, 2022
f2a84cf
Fix SSAO shadow acne
JMS55 Dec 22, 2022
266ac9e
Scale SSAO radius based on sample distance
JMS55 Dec 23, 2022
e6ac9e9
TAA velocity based dissoclusion detection
JMS55 Dec 23, 2022
a0f8af4
Misc cleanup
JMS55 Dec 23, 2022
ad3ce40
Misc cleanup
JMS55 Dec 23, 2022
c7a673b
TAA velocity fixes
JMS55 Dec 24, 2022
c4a60fb
Fix double buffer velocity prepass
JMS55 Dec 24, 2022
e6c0d5d
Disable TAA history rejection by default
JMS55 Dec 24, 2022
7cceee8
SSAO temporal noise reduction
JMS55 Dec 24, 2022
0e8a133
Rename SSAO denoise function
JMS55 Dec 24, 2022
2dcadff
Reduce TAA color clamping when velocity is small
JMS55 Dec 24, 2022
4e8890f
Misc tweaks
JMS55 Dec 24, 2022
4ebf55c
Merge branch 'main' into depth-prepass
IceSentry Dec 24, 2022
433605d
use separate prepass components
IceSentry Dec 24, 2022
722b580
fix ci
IceSentry Dec 24, 2022
98d526d
Merge commit '722b58024274f4585839e0df0effb15e2aaf1fb3' into gtao
JMS55 Dec 25, 2022
b9a5f39
Rebase fixes
JMS55 Dec 25, 2022
645bee1
Misc rebase fixes
JMS55 Dec 25, 2022
1e5fb5a
derive default and don't run when not present
IceSentry Dec 25, 2022
324eecf
Merge branch 'main' into depth-prepass
IceSentry Dec 25, 2022
4999f28
Merge commit '324eecfb4e9ce115f3febf08e99c953f1d212159' into gtao
JMS55 Dec 25, 2022
e20e15f
use depth buffer if present
IceSentry Dec 25, 2022
7b2fbbc
enable prepass by default
IceSentry Dec 25, 2022
b0039a4
Merge commit '7b2fbbc2a7b9bb91a8ce93ed65dd189a0785f76d' into gtao
JMS55 Dec 25, 2022
89e1f43
Adapt to changes
JMS55 Dec 25, 2022
005dcb8
extract prepass to module and standardize naming
IceSentry Dec 25, 2022
301d664
Finish adapting to merge
JMS55 Dec 25, 2022
e34179e
Misc fix
JMS55 Dec 25, 2022
a54b73e
register type in core_pipeline
IceSentry Dec 25, 2022
430ad2d
Misc
JMS55 Dec 25, 2022
9ce26ec
Remove TAA huerisitics
JMS55 Dec 25, 2022
0884758
Merge commit 'a54b73e0b7bbd90489c26c95c3abd9d3d8723f07' into gtao
JMS55 Dec 25, 2022
52157df
Merge fix
JMS55 Dec 25, 2022
e74265c
Rebase fixes
JMS55 Dec 25, 2022
013d2ef
Fix prepass shaders
JMS55 Dec 25, 2022
908a892
More rebase fixes
JMS55 Dec 25, 2022
b38b58f
Apply extra TAA variance only to the luma channel
JMS55 Dec 25, 2022
fab7dc3
fix FragmentInput
IceSentry Dec 26, 2022
1fc3fa1
Rename ambient occlusion to diffuse occlusion
JMS55 Dec 26, 2022
59d9907
Fix prepass fragment input
JMS55 Dec 26, 2022
7948684
Add TODO
JMS55 Dec 26, 2022
e201fb4
Misc format
JMS55 Dec 26, 2022
e083a7d
better example
IceSentry Dec 26, 2022
b5d37d9
Merge branch 'main' into depth-prepass
IceSentry Dec 26, 2022
d42b611
Apply suggestions from code review
IceSentry Dec 30, 2022
684a061
Apply suggestions from code review
IceSentry Dec 30, 2022
c3fa4e0
Apply suggestions from code review
IceSentry Dec 30, 2022
d134000
Update crates/bevy_pbr/src/prepass/prepass.wgsl
IceSentry Dec 30, 2022
1cb5ed6
Merge branch 'main' into depth-prepass
IceSentry Dec 30, 2022
51c7eea
remove unnecessary comment
IceSentry Dec 30, 2022
f61053e
use pbr_functions import
IceSentry Dec 30, 2022
1e3b173
clean up example
IceSentry Dec 30, 2022
969f3ad
add TODOs
IceSentry Dec 30, 2022
2f83d4b
add comment
IceSentry Dec 30, 2022
134b27c
clean up pbr_prepass
IceSentry Dec 30, 2022
2b0f4f9
Apply suggestions from code review
IceSentry Dec 30, 2022
c157cae
Extract constants
JMS55 Jan 1, 2023
b6acf22
Remove newline
JMS55 Jan 1, 2023
715ca65
fix unwrap on empty frag shader in prepass
IceSentry Jan 2, 2023
35093ed
docs
IceSentry Jan 2, 2023
5c9bb20
Merge commit '35093ed2e81b737fadfa5b50c32a6e49245acdf0' into gtao
JMS55 Jan 8, 2023
826b19a
Fix merge
JMS55 Jan 8, 2023
060c52d
WIP FSR2 plugin
JMS55 Jan 11, 2023
14efad2
Further plugin setup
JMS55 Jan 12, 2023
77ca0c8
WIP: FSR2Plugin
JMS55 Jan 15, 2023
8f5fda4
FSR2 jitter (breaks TAA for now)
JMS55 Jan 16, 2023
1bb796f
Fix shader ifdefs
JMS55 Jan 16, 2023
63003f7
Extract projection
JMS55 Jan 16, 2023
0b757e0
Misc
JMS55 Jan 16, 2023
f48bb83
Fix dep path
JMS55 Jan 16, 2023
1d48c29
Add neccesary texture usages
JMS55 Jan 16, 2023
3d5c81c
Misc
JMS55 Jan 17, 2023
ff68974
Add device field
JMS55 Jan 17, 2023
e9942d7
Cleanup jitter
JMS55 Jan 18, 2023
0e38fb4
Error checking
JMS55 Jan 18, 2023
b35586f
Store device in context
JMS55 Jan 19, 2023
cada547
WIP: Update TAA impl
JMS55 Jan 20, 2023
88112be
Fixes
JMS55 Jan 20, 2023
2cc10d5
Move TAA to core pipeline
JMS55 Jan 20, 2023
bc87f4c
Merge commit 'cab065bad4302e4df427ffbafcdb112e755321ce' into taa-only
JMS55 Jan 20, 2023
bf89ceb
Misc
JMS55 Jan 20, 2023
a545e2a
Merge fixes
JMS55 Jan 20, 2023
c44c33a
Documentation
JMS55 Jan 20, 2023
1ddfa48
Misc formatting
JMS55 Jan 20, 2023
e76cd0e
Appease clippy
JMS55 Jan 20, 2023
bf36eb0
Add plugin note to docs
JMS55 Jan 20, 2023
6b90c2c
Clippy is not yet appeased
JMS55 Jan 20, 2023
a1ca8db
Fix prepass vertex shader ifdefs
JMS55 Jan 20, 2023
742d0a1
Doc improvements
JMS55 Jan 20, 2023
e3f6a7e
Extract temporal jitter elsewhere
JMS55 Jan 20, 2023
f894e83
Merge commit '02637b609e8c9371e8f8b54deae5ee8594fb76c1' into taa-only
JMS55 Jan 20, 2023
0ae10d6
Fix merge
JMS55 Jan 20, 2023
bc5574c
Update crates/bevy_render/src/camera/camera.rs
JMS55 Jan 20, 2023
dd99d43
Merge commit '38691ee95c7f58918aa13264a8a9c91f52fe1355' into taa-only
JMS55 Jan 22, 2023
2aad44e
Fix merge
JMS55 Jan 22, 2023
d138306
Add con of TAA to docs
JMS55 Jan 23, 2023
dc291f0
Combine AA examples
JMS55 Jan 23, 2023
db2e5e5
Fix example metadata
JMS55 Jan 23, 2023
052817a
Doc note
JMS55 Jan 23, 2023
8812cd8
Change tonemapping solution for TAA
JMS55 Jan 24, 2023
7ae829f
Merge commit 'cf612c8349068c2250dddf8190cd9cc5c24763d8' into taa-only
JMS55 Jan 24, 2023
9846dd9
Merge commit 'aab518af925e3f3b5d9b6a014faaab588ee43047' into taa-only
JMS55 Jan 27, 2023
b0bed7b
Merge commit '1e591bf7a5b491ca699ebe1eb3736c04d3cdffb7' into taa-only
JMS55 Jan 30, 2023
230e5fc
Address review feedback
JMS55 Jan 30, 2023
2d3fb83
Fix NaNs
JMS55 Feb 4, 2023
21bbe66
Update crates/bevy_core_pipeline/src/prepass/mod.rs
JMS55 Feb 4, 2023
fe67b5a
Update crates/bevy_core_pipeline/src/prepass/mod.rs
JMS55 Feb 4, 2023
ea22039
Update crates/bevy_core_pipeline/src/taa/taa.wgsl
JMS55 Feb 4, 2023
dbbce60
Gate update_mesh_previous_global_transforms
JMS55 Feb 4, 2023
5091758
Use before() instead of at_start() for prepare_taa_jitter()
JMS55 Feb 4, 2023
d0108eb
Save 4 velocity samples per pixel
JMS55 Feb 4, 2023
c4faea1
Merge commit '12f30f56675220275568d5a51afd32f14e608fd4' into taa-only
JMS55 Feb 4, 2023
bcd0698
Don't allow reinserting taa bundle in example
JMS55 Feb 6, 2023
bcd7a5d
Add TAA reset
JMS55 Feb 6, 2023
13e8ea1
Migrate to stageless: Merge commit 'dcc03724a57e0980bb98d1b642e80fb2d…
JMS55 Feb 6, 2023
e9e0ef6
Prepare non-reset pipeline early
JMS55 Feb 6, 2023
1455078
Fix update_previous_view_projections
JMS55 Feb 6, 2023
039e081
Clear velocity to yellow
JMS55 Feb 6, 2023
d456a1f
Improve TAA docs
JMS55 Feb 6, 2023
ef0845f
Possible faster velocity clear
JMS55 Feb 7, 2023
42c3671
Add TODO about velocity format
JMS55 Feb 7, 2023
9a54c54
Merge commit '943499fcdf2301ea4091b8c4ebaa491dd8c26c33' into taa-only
JMS55 Feb 7, 2023
c845115
Fix schedule import
JMS55 Feb 7, 2023
47bf23f
Switch tonemapping to max3
JMS55 Feb 7, 2023
a577c23
Remove outdated doc comment
JMS55 Feb 7, 2023
5fd9c98
Move TAA to experimental module
JMS55 Feb 7, 2023
4366dd2
Misc rename
JMS55 Feb 7, 2023
52fc423
Reduce noise in static scenes
JMS55 Feb 8, 2023
4feab0e
Misc
JMS55 Feb 8, 2023
69c1dfe
Remove velocity_prepass_location
JMS55 Feb 8, 2023
e179e8a
Merge commit 'fefe5297ad00f93cc92df61153cb15dad3ae4857' into taa-only
JMS55 Feb 9, 2023
2cae300
Misc doc tweak
JMS55 Feb 9, 2023
87ef413
wip
IceSentry Feb 10, 2023
557a278
Merge pull request #6 from IceSentry/taa-moving-sphere
JMS55 Feb 10, 2023
0df70a2
Revert "moving sphere"
JMS55 Feb 10, 2023
e516f88
Merge pull request #7 from JMS55/revert-6-taa-moving-sphere
JMS55 Feb 10, 2023
49e21f6
Misc example cleanup
JMS55 Feb 10, 2023
80ae486
Merge branch 'taa-only' of https://github.com/JMS55/bevy into taa-only
JMS55 Feb 10, 2023
e7e228e
Merge commit 'eaac730617103b61fd5ede9dca463243f2d7900e' into taa-only
JMS55 Feb 12, 2023
2fb3291
Tweak min history blend rate
JMS55 Feb 12, 2023
64a52bf
Misc refactor
JMS55 Feb 12, 2023
f388878
Increase history confidence faster
JMS55 Feb 12, 2023
a10faa3
Update docs
JMS55 Feb 13, 2023
dd80e7c
Merge remote-tracking branch 'bevy/staging' into taa-only
JMS55 Feb 13, 2023
af38b4c
Tweak MIN_HISTORY_BLEND_RATE for smoother edges, at the cost of more …
JMS55 Feb 16, 2023
9f1a497
Tweak blend rate, probably for the final time
JMS55 Feb 17, 2023
5593ef9
Merge commit 'b24ed8bb0cf5567fd2467751d673754d102b47e4' into taa-only
JMS55 Feb 17, 2023
0f79160
Add MSAA sample count selection to AA example
JMS55 Feb 17, 2023
90725a2
Merge commit '3ec87e49ca49767fad658e72fbae353f6687198c' into taa-only
JMS55 Feb 21, 2023
191d1d8
Update Cargo.toml
JMS55 Feb 22, 2023
791460d
Consistent spelling of anti-aliasing
JMS55 Feb 22, 2023
6de0f46
Merge commit '15c55a12ff53c702acb167761424182f77f64dd7' into taa-only
JMS55 Feb 26, 2023
7c19b60
Rustfmt
JMS55 Feb 27, 2023
33012fb
Merge commit '9733613c07d65bc726f0eb1d955c363fb8e2b5c7' into taa-only
JMS55 Mar 2, 2023
56329de
Remove dead code
JMS55 Mar 2, 2023
de7d75b
Add neccesary command flush
JMS55 Mar 2, 2023
9891e8a
Misc
JMS55 Mar 2, 2023
68dbaf5
Revert "Misc"
JMS55 Mar 2, 2023
ea1840f
Shader ifdef fixes
JMS55 Mar 2, 2023
c416630
Rename velocity prepass to motion vector prepasss
JMS55 Mar 2, 2023
51631c0
Misc tweak
JMS55 Mar 2, 2023
b6d8b67
Merge remote-tracking branch 'bevyengine/main' into patch-taa
robtfm Mar 3, 2023
8cbc894
fix target/attach vecs
robtfm Mar 3, 2023
754192d
center jitter at zero
robtfm Mar 3, 2023
a7b0103
alpha-blend comment
robtfm Mar 3, 2023
17771e5
ci
robtfm Mar 3, 2023
81e9d29
Merge pull request #9 from robtfm/patch-taa
JMS55 Mar 3, 2023
aa0310e
Improve TAA jitter
JMS55 Mar 3, 2023
241875b
Update crates/bevy_pbr/src/prepass/mod.rs
JMS55 Mar 3, 2023
84cec18
Fix compile error
JMS55 Mar 3, 2023
04a9722
Fix shader_prepass
JMS55 Mar 3, 2023
415620d
Misc
JMS55 Mar 3, 2023
cccb2c2
Output motion vectors at render resolution, not ndc
JMS55 Mar 3, 2023
946f8d8
Add motion vectors to shader_prepass example
JMS55 Mar 3, 2023
66960e6
Fix label color in shader_prepass example
JMS55 Mar 3, 2023
ad4e19f
Revert "Output motion vectors at render resolution, not ndc"
JMS55 Mar 3, 2023
503deda
Fix update_mesh_previous_global_transforms() missing from schedule
JMS55 Mar 3, 2023
554c9a0
Update crates/bevy_pbr/src/prepass/mod.rs
JMS55 Mar 3, 2023
4af080c
Misc fixes
JMS55 Mar 3, 2023
2fb717e
Fix wrong system set
JMS55 Mar 4, 2023
fd5eeb5
Add comment
JMS55 Mar 4, 2023
d875e1c
Fix missing system
JMS55 Mar 4, 2023
6ec93f7
Improve show_prepass motion vectors
JMS55 Mar 4, 2023
d0ce763
Merge remote-tracking branch 'bevy/main' into taa-only
JMS55 Mar 4, 2023
7537c24
Fix shadow pass when no prepass is enabled
JMS55 Mar 4, 2023
9893d90
Misc formatting
JMS55 Mar 5, 2023
e289178
Merge commit '6124b20f4bb6c706f01c7a71259989696c91dea5' into taa-only
JMS55 Mar 5, 2023
c365924
Merge commit 'f3cf734659dc9e7f33e67364920231f1c51782dd' into taa-only
JMS55 Mar 7, 2023
15b050c
Merge commit '2908bb5e8a3ec00b883c7120a7a69f6e34bb642e' into taa-only
JMS55 Mar 9, 2023
4dd6d63
Misc formatting
JMS55 Mar 9, 2023
956d825
Merge commit 'fd1af7c8b8a737b4da79615741f8844069bc6a5c' into taa-only
JMS55 Mar 11, 2023
4e96e73
Remove unnecsary trace
JMS55 Mar 11, 2023
a2b7e61
Fix typo
JMS55 Mar 11, 2023
e5b64a6
Misc fix
JMS55 Mar 12, 2023
1295cb0
Merge commit '13196613ee3a1add2e525dc8d6a52d8534ebef81' into taa-only
JMS55 Mar 14, 2023
6242fd8
Update crates/bevy_core_pipeline/src/prepass/node.rs
JMS55 Mar 16, 2023
f61be1b
Doc tweak
JMS55 Mar 16, 2023
98baa5c
Misc refactor
JMS55 Mar 16, 2023
dc22250
Merge commit '7b7294b8a7c5f7531c52a2524a6a3a456c0519c0' into taa-only
JMS55 Mar 20, 2023
b3de57e
Merge commit 'caa662272ce91028cef6e237bb7c2a3e78727ef4' into taa-only
JMS55 Mar 21, 2023
765fa48
Misc fix
JMS55 Mar 21, 2023
4c03655
Merge commit '2c21d423fde265d1108270bd835b95a5164361cb' into taa-only
JMS55 Mar 21, 2023
12dd618
Remove view entity slot
JMS55 Mar 21, 2023
4227fa6
Update crates/bevy_core_pipeline/src/taa/taa.wgsl
JMS55 Mar 26, 2023
769b0af
Misc refactor
JMS55 Mar 26, 2023
a438db7
Merge branch 'taa-only' of https://github.com/JMS55/bevy into taa-only
JMS55 Mar 26, 2023
46aadc7
Rename TemporalAntialias -> TemporalAntiAlias
JMS55 Mar 26, 2023
b75aa88
Switch MOTION_VECTOR_PREPASS_FORMAT to Rg16Float
JMS55 Mar 26, 2023
a79cfdf
Doc comment
JMS55 Mar 26, 2023
6bb7fd2
Fix clip_towards_aabb_center
JMS55 Mar 26, 2023
c452322
Add docs for blend rates
JMS55 Mar 26, 2023
2479118
Misc
JMS55 Mar 26, 2023
8f6e0f7
Update docs
JMS55 Mar 26, 2023
3ae680c
Update crates/bevy_pbr/src/prepass/prepass.wgsl
JMS55 Mar 26, 2023
d4803b1
Update crates/bevy_pbr/src/render/pbr_prepass.wgsl
JMS55 Mar 26, 2023
c514535
Merge branch 'main' into taa-only
superdump Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ description = "A scene showcasing the built-in 3D shapes"
category = "3D Rendering"
wasm = true

[[example]]
name = "anti_aliasing"
path = "examples/3d/anti_aliasing.rs"

[package.metadata.example.anti_aliasing]
name = "Anti-aliasing"
description = "Compares different anti-aliasing methods"
category = "3D Rendering"
wasm = false

[[example]]
name = "3d_gizmos"
path = "examples/3d/3d_gizmos.rs"
Expand Down Expand Up @@ -515,26 +525,6 @@ description = "Compares tonemapping options"
category = "3D Rendering"
wasm = true

[[example]]
name = "fxaa"
path = "examples/3d/fxaa.rs"

[package.metadata.example.fxaa]
name = "FXAA"
description = "Compares MSAA (Multi-Sample Anti-Aliasing) and FXAA (Fast Approximate Anti-Aliasing)"
category = "3D Rendering"
wasm = true

[[example]]
name = "msaa"
path = "examples/3d/msaa.rs"

[package.metadata.example.msaa]
name = "MSAA"
description = "Configures MSAA (Multi-Sample Anti-Aliasing) for smoother edges"
category = "3D Rendering"
wasm = true

[[example]]
name = "orthographic"
path = "examples/3d/orthographic.rs"
Expand Down
4 changes: 4 additions & 0 deletions assets/shaders/show_prepass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
struct ShowPrepassSettings {
show_depth: u32,
show_normals: u32,
show_motion_vectors: u32,
padding_1: u32,
padding_2: u32,
}
Expand All @@ -23,6 +24,9 @@ fn fragment(
} else if settings.show_normals == 1u {
let normal = prepass_normal(frag_coord, sample_index);
return vec4(normal, 1.0);
} else if settings.show_motion_vectors == 1u {
let motion_vector = prepass_motion_vector(frag_coord, sample_index);
JMS55 marked this conversation as resolved.
Show resolved Hide resolved
return vec4(motion_vector / globals.delta_time, 0.0, 1.0);
}

return vec4(0.0);
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core_pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tonemapping_luts = []
# bevy
bevy_app = { path = "../bevy_app", version = "0.11.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.11.0-dev" }
bevy_core = { path = "../bevy_core", version = "0.11.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.11.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.11.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.11.0-dev" }
Expand Down
5 changes: 0 additions & 5 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use bevy_render::{
view::ViewTarget,
Render, RenderApp, RenderSet,
};
#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;
use downsampling_pipeline::{
prepare_downsampling_pipeline, BloomDownsamplingPipeline, BloomDownsamplingPipelineIds,
BloomUniforms,
Expand Down Expand Up @@ -150,9 +148,6 @@ impl Node for BloomNode {
render_context: &mut RenderContext,
world: &World,
) -> Result<(), NodeRunError> {
#[cfg(feature = "trace")]
let _bloom_span = info_span!("bloom").entered();

superdump marked this conversation as resolved.
Show resolved Hide resolved
let downsampling_pipeline_res = world.resource::<BloomDownsamplingPipeline>();
let pipeline_cache = world.resource::<PipelineCache>();
let uniforms = world.resource::<ComponentUniforms<BloomUniforms>>();
Expand Down
9 changes: 7 additions & 2 deletions crates/bevy_core_pipeline/src/core_3d/main_pass_3d_node.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
clear_color::{ClearColor, ClearColorConfig},
core_3d::{AlphaMask3d, Camera3d, Opaque3d, Transparent3d},
prepass::{DepthPrepass, NormalPrepass},
prepass::{DepthPrepass, MotionVectorPrepass, NormalPrepass},
};
use bevy_ecs::prelude::*;
use bevy_render::{
Expand Down Expand Up @@ -29,6 +29,7 @@ pub struct MainPass3dNode {
&'static ViewDepthTexture,
Option<&'static DepthPrepass>,
Option<&'static NormalPrepass>,
Option<&'static MotionVectorPrepass>,
),
With<ExtractedView>,
>,
Expand Down Expand Up @@ -64,6 +65,7 @@ impl Node for MainPass3dNode {
depth,
depth_prepass,
normal_prepass,
motion_vector_prepass,
)) = self.query.get_manual(world, view_entity) else {
// No window
return Ok(());
Expand Down Expand Up @@ -94,7 +96,10 @@ impl Node for MainPass3dNode {
view: &depth.view,
// NOTE: The opaque main pass loads the depth buffer and possibly overwrites it
depth_ops: Some(Operations {
load: if depth_prepass.is_some() || normal_prepass.is_some() {
load: if depth_prepass.is_some()
|| normal_prepass.is_some()
|| motion_vector_prepass.is_some()
{
// if any prepass runs, it will generate a depth buffer so we should use it,
// even if only the normal_prepass is used.
Camera3dDepthLoadOp::Load
Expand Down
8 changes: 8 additions & 0 deletions crates/bevy_core_pipeline/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ pub mod fullscreen_vertex_shader;
pub mod fxaa;
pub mod msaa_writeback;
pub mod prepass;
mod taa;
pub mod tonemapping;
pub mod upscaling;

/// Experimental features that are not yet finished. Please report any issues you encounter!
pub mod experimental {
JMS55 marked this conversation as resolved.
Show resolved Hide resolved
pub mod taa {
pub use crate::taa::*;
}
}

pub mod prelude {
#[doc(hidden)]
pub use crate::{
Expand Down
17 changes: 13 additions & 4 deletions crates/bevy_core_pipeline/src/prepass/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Run a prepass before the main pass to generate depth and/or normals texture, sometimes called a thin g-buffer.
//! Run a prepass before the main pass to generate depth, normals, and/or motion vectors textures, sometimes called a thin g-buffer.
//! These textures are useful for various screen-space effects and reducing overdraw in the main pass.
//!
//! The prepass only runs for opaque meshes or meshes with an alpha mask. Transparent meshes are ignored.
Expand All @@ -7,6 +7,7 @@
//!
//! [`DepthPrepass`]
//! [`NormalPrepass`]
//! [`MotionVectorPrepass`]
//!
//! The textures are automatically added to the default mesh view bindings. You can also get the raw textures
//! by querying the [`ViewPrepassTextures`] component on any camera with a prepass component.
Expand All @@ -15,9 +16,9 @@
//! to a separate texture unless the [`DepthPrepass`] is activated. This means that if any prepass component is present
//! it will always create a depth buffer that will be used by the main pass.
//!
//! When using the default mesh view bindings you should be able to use `prepass_depth()`
//! and `prepass_normal()` to load the related textures. These functions are defined in `bevy_pbr::prepass_utils`.
//! See the `shader_prepass` example that shows how to use it.
//! When using the default mesh view bindings you should be able to use `prepass_depth()`,
//! `prepass_normal()`, and `prepass_motion_vector()` to load the related textures.
//! These functions are defined in `bevy_pbr::prepass_utils`. See the `shader_prepass` example that shows how to use them.
//!
//! The prepass runs for each `Material`. You can control if the prepass should run per-material by setting the `prepass_enabled`
//! flag on the `MaterialPlugin`.
Expand All @@ -39,6 +40,7 @@ use bevy_utils::FloatOrd;

pub const DEPTH_PREPASS_FORMAT: TextureFormat = TextureFormat::Depth32Float;
pub const NORMAL_PREPASS_FORMAT: TextureFormat = TextureFormat::Rgb10a2Unorm;
pub const MOTION_VECTOR_PREPASS_FORMAT: TextureFormat = TextureFormat::Rg16Float;

/// If added to a [`crate::prelude::Camera3d`] then depth values will be copied to a separate texture available to the main pass.
#[derive(Component, Default, Reflect)]
Expand All @@ -49,6 +51,10 @@ pub struct DepthPrepass;
#[derive(Component, Default, Reflect)]
pub struct NormalPrepass;

/// If added to a [`crate::prelude::Camera3d`] then screen space motion vectors will be copied to a separate texture available to the main pass.
#[derive(Component, Default, Reflect)]
pub struct MotionVectorPrepass;

/// Textures that are written to by the prepass.
///
/// This component will only be present if any of the relevant prepass components are also present.
Expand All @@ -60,6 +66,9 @@ pub struct ViewPrepassTextures {
/// The normals texture generated by the prepass.
/// Exists only if [`NormalPrepass`] is added to the `ViewTarget`
pub normal: Option<CachedTexture>,
/// The motion vectors texture generated by the prepass.
/// Exists only if [`MotionVectorPrepass`] is added to the `ViewTarget`
pub motion_vectors: Option<CachedTexture>,
/// The size of the textures.
pub size: Extent3d,
}
Expand Down
29 changes: 24 additions & 5 deletions crates/bevy_core_pipeline/src/prepass/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,34 @@ impl Node for PrepassNode {
};

let mut color_attachments = vec![];
if let Some(view_normals_texture) = &view_prepass_textures.normal {
color_attachments.push(Some(RenderPassColorAttachment {
view: &view_normals_texture.default_view,
color_attachments.push(
view_prepass_textures
.normal
.as_ref()
.map(|view_normals_texture| RenderPassColorAttachment {
view: &view_normals_texture.default_view,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK.into()),
store: true,
},
}),
);
color_attachments.push(view_prepass_textures.motion_vectors.as_ref().map(
|view_motion_vectors_texture| RenderPassColorAttachment {
view: &view_motion_vectors_texture.default_view,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK.into()),
// Blue channel doesn't matter, but set to 1.0 for possible faster clear
// https://gpuopen.com/performance/#clears
load: LoadOp::Clear(Color::rgb_linear(1.0, 1.0, 1.0).into()),
store: true,
},
}));
},
));
if color_attachments.iter().all(Option::is_none) {
// all attachments are none: clear the attachment list so that no fragment shader is required
color_attachments.clear();
}

{
Expand Down
Loading