-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add low level post process example using a custom render pass #6909
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6c2518b
Basic example
IceSentry a56afa3
remove extract
IceSentry 9889c7c
fix readme
IceSentry fd62a03
fix comment
IceSentry a1a1e1e
specify node
IceSentry 0617845
Update examples/shader/post_process_pass.rs
IceSentry 466df59
Update examples/shader/post_process_pass.rs
IceSentry 0e2d95d
Update examples/shader/post_process_pass.rs
IceSentry 8b2dc08
Update examples/shader/post_process_pass.rs
IceSentry dcf1ef0
docs
IceSentry d3adbfc
fullsreen triangle
IceSentry e65d0c7
source/destination note
IceSentry e2bd972
Apply suggestions from code review
IceSentry 95fe6a9
better fullscreen triangle diagram
IceSentry 9b94c7a
fix
IceSentry 3073d23
clean up
IceSentry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // This shader computes the chromatic aberration effect | ||
|
|
||
| #import bevy_pbr::utils | ||
|
|
||
| // Since post processing is a fullscreen effect, we use the fullscreen vertex shader provided by bevy. | ||
| // This will import a vertex shader that renders a single fullscreen triangle. | ||
| // | ||
| // A fullscreen triangle is a single triangle that covers the entire screen. | ||
| // The box in the top left in that diagram is the screen. The 4 x are the corner of the screen | ||
| // | ||
| // Y axis | ||
| // 1 | x-----x...... | ||
| // 0 | | s | . ´ | ||
| // -1 | x_____x´ | ||
| // -2 | : .´ | ||
| // -3 | :´ | ||
| // +--------------- X axis | ||
| // -1 0 1 2 3 | ||
| // | ||
| // As you can see, the triangle ends up bigger than the screen. | ||
| // | ||
| // You don't need to worry about this too much since bevy will compute the correct UVs for you. | ||
| #import bevy_core_pipeline::fullscreen_vertex_shader | ||
|
|
||
| @group(0) @binding(0) | ||
| var screen_texture: texture_2d<f32>; | ||
| @group(0) @binding(1) | ||
| var texture_sampler: sampler; | ||
| struct PostProcessSettings { | ||
| intensity: f32, | ||
| } | ||
| @group(0) @binding(2) | ||
| var<uniform> settings: PostProcessSettings; | ||
|
|
||
| @fragment | ||
| fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> { | ||
| // Chromatic aberration strength | ||
| let offset_strength = settings.intensity; | ||
|
|
||
| // Sample each color channel with an arbitrary shift | ||
| return vec4<f32>( | ||
| textureSample(screen_texture, texture_sampler, in.uv + vec2<f32>(offset_strength, -offset_strength)).r, | ||
| textureSample(screen_texture, texture_sampler, in.uv + vec2<f32>(-offset_strength, 0.0)).g, | ||
| textureSample(screen_texture, texture_sampler, in.uv + vec2<f32>(0.0, offset_strength)).b, | ||
| 1.0 | ||
| ); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.