Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Mar 24, 2023
1 parent b47af22 commit 22d741f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 75 deletions.
44 changes: 3 additions & 41 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Expand Up @@ -16,7 +16,7 @@ use bevy_render::{
ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin,
},
prelude::Color,
render_graph::{Node, NodeRunError, RenderGraph, RenderGraphContext},
render_graph::{Node, NodeRunError, RenderGraphContext},
render_resource::*,
renderer::{RenderContext, RenderDevice},
texture::{CachedTexture, TextureCache},
Expand Down Expand Up @@ -80,62 +80,24 @@ impl Plugin for BloomPlugin {
render_app,
core_3d::graph::NAME,
core_3d::graph::node::BLOOM,
core_3d::graph::input::VIEW_ENTITY,
BloomNode::IN_VIEW,
&[
core_3d::graph::node::MAIN_PASS,
core_3d::graph::node::BLOOM,
core_3d::graph::node::TONEMAPPING,
],
);
{
let bloom_node = BloomNode::new(&mut render_app.world);
let mut graph = render_app.world.resource_mut::<RenderGraph>();
let draw_3d_graph = graph
.get_sub_graph_mut(crate::core_3d::graph::NAME)
.unwrap();
draw_3d_graph.add_node(core_3d::graph::node::BLOOM, bloom_node);
// MAIN_PASS -> BLOOM -> TONEMAPPING
draw_3d_graph.add_node_edge(
crate::core_3d::graph::node::MAIN_PASS,
core_3d::graph::node::BLOOM,
);
draw_3d_graph.add_node_edge(
core_3d::graph::node::BLOOM,
crate::core_3d::graph::node::TONEMAPPING,
);
}

// Add bloom to the 2d render graph
add_node::<BloomNode>(
render_app,
core_2d::graph::NAME,
core_2d::graph::node::BLOOM,
core_2d::graph::input::VIEW_ENTITY,
BloomNode::IN_VIEW,
&[
core_2d::graph::node::MAIN_PASS,
core_2d::graph::node::BLOOM,
core_2d::graph::node::TONEMAPPING,
],
);
{
let bloom_node = BloomNode::new(&mut render_app.world);
let mut graph = render_app.world.resource_mut::<RenderGraph>();
let draw_2d_graph = graph
.get_sub_graph_mut(crate::core_2d::graph::NAME)
.unwrap();
draw_2d_graph.add_node(core_2d::graph::node::BLOOM, bloom_node);
// MAIN_PASS -> BLOOM -> TONEMAPPING
draw_2d_graph.add_node_edge(
crate::core_2d::graph::node::MAIN_PASS,
core_2d::graph::node::BLOOM,
);
draw_2d_graph.add_node_edge(
core_2d::graph::node::BLOOM,
crate::core_2d::graph::node::TONEMAPPING,
);
}
}
}

Expand All @@ -152,8 +114,8 @@ pub struct BloomNode {
)>,
}

impl BloomNode {
pub fn new(world: &mut World) -> Self {
impl FromWorld for BloomNode {
fn from_world(world: &mut World) -> Self {
Self {
view_query: QueryState::new(world),
}
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_core_pipeline/src/core_2d/mod.rs
Expand Up @@ -73,8 +73,9 @@ impl Plugin for Core2dPlugin {
draw_2d_graph.add_node(graph::node::TONEMAPPING, tonemapping);
draw_2d_graph.add_node(graph::node::END_MAIN_PASS_POST_PROCESSING, EmptyNode);
draw_2d_graph.add_node(graph::node::UPSCALING, upscaling);
draw_2d_graph.add_node_edge(graph::node::MAIN_PASS, graph::node::TONEMAPPING);
draw_2d_graph.add_node_edge(

draw_2d_graph.add_node_edges(&[
graph::node::MAIN_PASS,
graph::node::TONEMAPPING,
graph::node::END_MAIN_PASS_POST_PROCESSING,
graph::node::UPSCALING,
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Expand Up @@ -94,9 +94,8 @@ impl Plugin for Core3dPlugin {
draw_3d_graph.add_node(graph::node::END_MAIN_PASS_POST_PROCESSING, EmptyNode);
draw_3d_graph.add_node(graph::node::UPSCALING, upscaling);

draw_3d_graph.add_node_edge(graph::node::PREPASS, graph::node::MAIN_PASS);
draw_3d_graph.add_node_edge(graph::node::MAIN_PASS, graph::node::TONEMAPPING);
draw_3d_graph.add_node_edge(
draw_3d_graph.add_node_edges(&[
graph::node::MAIN_PASS,
graph::node::TONEMAPPING,
graph::node::END_MAIN_PASS_POST_PROCESSING,
graph::node::UPSCALING,
Expand Down
13 changes: 7 additions & 6 deletions crates/bevy_core_pipeline/src/fxaa/mod.rs
@@ -1,4 +1,4 @@
use crate::{add_node, core_2d, core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state};
use crate::{core_2d, core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state};
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, HandleUntyped};
use bevy_derive::Deref;
Expand All @@ -9,6 +9,7 @@ use bevy_reflect::{
use bevy_render::{
extract_component::{ExtractComponent, ExtractComponentPlugin},
prelude::Camera,
render_graph::RenderGraph,
render_resource::*,
renderer::RenderDevice,
texture::BevyDefault,
Expand Down Expand Up @@ -98,11 +99,11 @@ impl Plugin for FxaaPlugin {

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

graph.add_node_edge(
graph.add_node_edges(&[
core_3d::graph::node::TONEMAPPING,
core_3d::graph::node::FXAA,
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING,
);
]);
}
{
let fxaa_node = FxaaNode::new(&mut render_app.world);
Expand All @@ -111,12 +112,12 @@ impl Plugin for FxaaPlugin {

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

graph.add_node_edge(
graph.add_node_edges(&[
core_2d::graph::node::TONEMAPPING,
core_2d::graph::node::FXAA,
core_2d::graph::node::END_MAIN_PASS_POST_PROCESSING,
],
);
]);
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions crates/bevy_core_pipeline/src/lib.rs
Expand Up @@ -78,8 +78,6 @@ pub fn add_node<T: Node + FromWorld>(
render_app: &mut App,
sub_graph_name: &'static str,
node_name: &'static str,
output_slot: &'static str,
input_slot: &'static str,
edges: &[&'static str],
) {
let node = T::from_world(&mut render_app.world);
Expand All @@ -88,6 +86,4 @@ pub fn add_node<T: Node + FromWorld>(
let graph = render_graph.get_sub_graph_mut(sub_graph_name).unwrap();
graph.add_node(node_name, node);
graph.add_node_edges(edges);

graph.add_slot_edge(graph.input_node().id, output_slot, node_name, input_slot);
}
28 changes: 9 additions & 19 deletions examples/shader/post_process_pass.rs
Expand Up @@ -78,26 +78,16 @@ impl Plugin for PostProcessPlugin {
// A node only has access to the render world, so if you need data from the main world
// you need to extract it manually or with the plugin like above.

// Create the node with the render world
let node = PostProcessNode::new(&mut render_app.world);

// Get the render graph for the entire app
let mut graph = render_app.world.resource_mut::<RenderGraph>();

// Get the render graph for 3d cameras/views
let core_3d_graph = graph.get_sub_graph_mut(core_3d::graph::NAME).unwrap();

// Register the post process node in the 3d render graph
core_3d_graph.add_node(PostProcessNode::NAME, node);

// We now need to add an edge between our node and the nodes from bevy
// to make sure our node is ordered correctly relative to other nodes.
//
// Here we want our effect to run after tonemapping and before the end of the main pass post processing
core_3d_graph.add_node_edge(core_3d::graph::node::TONEMAPPING, PostProcessNode::NAME);
core_3d_graph.add_node_edge(
/// Utility function to add a [`Node`] to the [`RenderGraph`]
add_node::<PostProcessNode>(
render_app,
core_3d::graph::NAME,
PostProcessNode::NAME,
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING,
&[
core_3d::graph::node::TONEMAPPING,
PostProcessNode::NAME,
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING,
],
);
}
}
Expand Down

0 comments on commit 22d741f

Please sign in to comment.