Skip to content

Commit 22d741f

Browse files
committed
fix rebase
1 parent b47af22 commit 22d741f

File tree

6 files changed

+24
-75
lines changed

6 files changed

+24
-75
lines changed

crates/bevy_core_pipeline/src/bloom/mod.rs

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bevy_render::{
1616
ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin,
1717
},
1818
prelude::Color,
19-
render_graph::{Node, NodeRunError, RenderGraph, RenderGraphContext},
19+
render_graph::{Node, NodeRunError, RenderGraphContext},
2020
render_resource::*,
2121
renderer::{RenderContext, RenderDevice},
2222
texture::{CachedTexture, TextureCache},
@@ -80,62 +80,24 @@ impl Plugin for BloomPlugin {
8080
render_app,
8181
core_3d::graph::NAME,
8282
core_3d::graph::node::BLOOM,
83-
core_3d::graph::input::VIEW_ENTITY,
84-
BloomNode::IN_VIEW,
8583
&[
8684
core_3d::graph::node::MAIN_PASS,
8785
core_3d::graph::node::BLOOM,
8886
core_3d::graph::node::TONEMAPPING,
8987
],
9088
);
91-
{
92-
let bloom_node = BloomNode::new(&mut render_app.world);
93-
let mut graph = render_app.world.resource_mut::<RenderGraph>();
94-
let draw_3d_graph = graph
95-
.get_sub_graph_mut(crate::core_3d::graph::NAME)
96-
.unwrap();
97-
draw_3d_graph.add_node(core_3d::graph::node::BLOOM, bloom_node);
98-
// MAIN_PASS -> BLOOM -> TONEMAPPING
99-
draw_3d_graph.add_node_edge(
100-
crate::core_3d::graph::node::MAIN_PASS,
101-
core_3d::graph::node::BLOOM,
102-
);
103-
draw_3d_graph.add_node_edge(
104-
core_3d::graph::node::BLOOM,
105-
crate::core_3d::graph::node::TONEMAPPING,
106-
);
107-
}
10889

10990
// Add bloom to the 2d render graph
11091
add_node::<BloomNode>(
11192
render_app,
11293
core_2d::graph::NAME,
11394
core_2d::graph::node::BLOOM,
114-
core_2d::graph::input::VIEW_ENTITY,
115-
BloomNode::IN_VIEW,
11695
&[
11796
core_2d::graph::node::MAIN_PASS,
11897
core_2d::graph::node::BLOOM,
11998
core_2d::graph::node::TONEMAPPING,
12099
],
121100
);
122-
{
123-
let bloom_node = BloomNode::new(&mut render_app.world);
124-
let mut graph = render_app.world.resource_mut::<RenderGraph>();
125-
let draw_2d_graph = graph
126-
.get_sub_graph_mut(crate::core_2d::graph::NAME)
127-
.unwrap();
128-
draw_2d_graph.add_node(core_2d::graph::node::BLOOM, bloom_node);
129-
// MAIN_PASS -> BLOOM -> TONEMAPPING
130-
draw_2d_graph.add_node_edge(
131-
crate::core_2d::graph::node::MAIN_PASS,
132-
core_2d::graph::node::BLOOM,
133-
);
134-
draw_2d_graph.add_node_edge(
135-
core_2d::graph::node::BLOOM,
136-
crate::core_2d::graph::node::TONEMAPPING,
137-
);
138-
}
139101
}
140102
}
141103

@@ -152,8 +114,8 @@ pub struct BloomNode {
152114
)>,
153115
}
154116

155-
impl BloomNode {
156-
pub fn new(world: &mut World) -> Self {
117+
impl FromWorld for BloomNode {
118+
fn from_world(world: &mut World) -> Self {
157119
Self {
158120
view_query: QueryState::new(world),
159121
}

crates/bevy_core_pipeline/src/core_2d/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ impl Plugin for Core2dPlugin {
7373
draw_2d_graph.add_node(graph::node::TONEMAPPING, tonemapping);
7474
draw_2d_graph.add_node(graph::node::END_MAIN_PASS_POST_PROCESSING, EmptyNode);
7575
draw_2d_graph.add_node(graph::node::UPSCALING, upscaling);
76-
draw_2d_graph.add_node_edge(graph::node::MAIN_PASS, graph::node::TONEMAPPING);
77-
draw_2d_graph.add_node_edge(
76+
77+
draw_2d_graph.add_node_edges(&[
78+
graph::node::MAIN_PASS,
7879
graph::node::TONEMAPPING,
7980
graph::node::END_MAIN_PASS_POST_PROCESSING,
8081
graph::node::UPSCALING,

crates/bevy_core_pipeline/src/core_3d/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ impl Plugin for Core3dPlugin {
9494
draw_3d_graph.add_node(graph::node::END_MAIN_PASS_POST_PROCESSING, EmptyNode);
9595
draw_3d_graph.add_node(graph::node::UPSCALING, upscaling);
9696

97-
draw_3d_graph.add_node_edge(graph::node::PREPASS, graph::node::MAIN_PASS);
98-
draw_3d_graph.add_node_edge(graph::node::MAIN_PASS, graph::node::TONEMAPPING);
99-
draw_3d_graph.add_node_edge(
97+
draw_3d_graph.add_node_edges(&[
98+
graph::node::MAIN_PASS,
10099
graph::node::TONEMAPPING,
101100
graph::node::END_MAIN_PASS_POST_PROCESSING,
102101
graph::node::UPSCALING,

crates/bevy_core_pipeline/src/fxaa/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{add_node, core_2d, core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state};
1+
use crate::{core_2d, core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state};
22
use bevy_app::prelude::*;
33
use bevy_asset::{load_internal_asset, HandleUntyped};
44
use bevy_derive::Deref;
@@ -9,6 +9,7 @@ use bevy_reflect::{
99
use bevy_render::{
1010
extract_component::{ExtractComponent, ExtractComponentPlugin},
1111
prelude::Camera,
12+
render_graph::RenderGraph,
1213
render_resource::*,
1314
renderer::RenderDevice,
1415
texture::BevyDefault,
@@ -98,11 +99,11 @@ impl Plugin for FxaaPlugin {
9899

99100
graph.add_node(core_3d::graph::node::FXAA, fxaa_node);
100101

101-
graph.add_node_edge(
102+
graph.add_node_edges(&[
102103
core_3d::graph::node::TONEMAPPING,
103104
core_3d::graph::node::FXAA,
104105
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING,
105-
);
106+
]);
106107
}
107108
{
108109
let fxaa_node = FxaaNode::new(&mut render_app.world);
@@ -111,12 +112,12 @@ impl Plugin for FxaaPlugin {
111112

112113
graph.add_node(core_2d::graph::node::FXAA, fxaa_node);
113114

114-
graph.add_node_edge(
115+
graph.add_node_edges(&[
115116
core_2d::graph::node::TONEMAPPING,
116117
core_2d::graph::node::FXAA,
117118
core_2d::graph::node::END_MAIN_PASS_POST_PROCESSING,
118-
],
119-
);
119+
]);
120+
}
120121
}
121122
}
122123

crates/bevy_core_pipeline/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ pub fn add_node<T: Node + FromWorld>(
7878
render_app: &mut App,
7979
sub_graph_name: &'static str,
8080
node_name: &'static str,
81-
output_slot: &'static str,
82-
input_slot: &'static str,
8381
edges: &[&'static str],
8482
) {
8583
let node = T::from_world(&mut render_app.world);
@@ -88,6 +86,4 @@ pub fn add_node<T: Node + FromWorld>(
8886
let graph = render_graph.get_sub_graph_mut(sub_graph_name).unwrap();
8987
graph.add_node(node_name, node);
9088
graph.add_node_edges(edges);
91-
92-
graph.add_slot_edge(graph.input_node().id, output_slot, node_name, input_slot);
9389
}

examples/shader/post_process_pass.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,16 @@ impl Plugin for PostProcessPlugin {
7878
// A node only has access to the render world, so if you need data from the main world
7979
// you need to extract it manually or with the plugin like above.
8080

81-
// Create the node with the render world
82-
let node = PostProcessNode::new(&mut render_app.world);
83-
84-
// Get the render graph for the entire app
85-
let mut graph = render_app.world.resource_mut::<RenderGraph>();
86-
87-
// Get the render graph for 3d cameras/views
88-
let core_3d_graph = graph.get_sub_graph_mut(core_3d::graph::NAME).unwrap();
89-
90-
// Register the post process node in the 3d render graph
91-
core_3d_graph.add_node(PostProcessNode::NAME, node);
92-
93-
// We now need to add an edge between our node and the nodes from bevy
94-
// to make sure our node is ordered correctly relative to other nodes.
95-
//
96-
// Here we want our effect to run after tonemapping and before the end of the main pass post processing
97-
core_3d_graph.add_node_edge(core_3d::graph::node::TONEMAPPING, PostProcessNode::NAME);
98-
core_3d_graph.add_node_edge(
81+
/// Utility function to add a [`Node`] to the [`RenderGraph`]
82+
add_node::<PostProcessNode>(
83+
render_app,
84+
core_3d::graph::NAME,
9985
PostProcessNode::NAME,
100-
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING,
86+
&[
87+
core_3d::graph::node::TONEMAPPING,
88+
PostProcessNode::NAME,
89+
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING,
90+
],
10191
);
10292
}
10393
}

0 commit comments

Comments
 (0)