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

[Merged by Bors] - Make Core Pipeline Graph Nodes Public #6605

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
37 changes: 12 additions & 25 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use crate::{core_2d, core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state};
use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, HandleUntyped};
use bevy_ecs::{
Expand All @@ -25,19 +25,6 @@ use bevy_utils::tracing::info_span;
use bevy_utils::HashMap;
use std::num::NonZeroU32;

pub mod draw_3d_graph {
pub mod node {
/// Label for the bloom render node.
pub const BLOOM: &str = "bloom_3d";
}
}
pub mod draw_2d_graph {
pub mod node {
/// Label for the bloom render node.
pub const BLOOM: &str = "bloom_2d";
}
}

const BLOOM_SHADER_HANDLE: HandleUntyped =
HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 929599476923908);

Expand Down Expand Up @@ -68,25 +55,25 @@ impl Plugin for BloomPlugin {
let draw_3d_graph = graph
.get_sub_graph_mut(crate::core_3d::graph::NAME)
.unwrap();
draw_3d_graph.add_node(draw_3d_graph::node::BLOOM, bloom_node);
draw_3d_graph.add_node(core_3d::graph::node::BLOOM, bloom_node);
draw_3d_graph
.add_slot_edge(
draw_3d_graph.input_node().unwrap().id,
crate::core_3d::graph::input::VIEW_ENTITY,
draw_3d_graph::node::BLOOM,
core_3d::graph::node::BLOOM,
BloomNode::IN_VIEW,
)
.unwrap();
// MAIN_PASS -> BLOOM -> TONEMAPPING
draw_3d_graph
.add_node_edge(
crate::core_3d::graph::node::MAIN_PASS,
draw_3d_graph::node::BLOOM,
core_3d::graph::node::BLOOM,
)
.unwrap();
draw_3d_graph
.add_node_edge(
draw_3d_graph::node::BLOOM,
core_3d::graph::node::BLOOM,
crate::core_3d::graph::node::TONEMAPPING,
)
.unwrap();
Expand All @@ -98,25 +85,25 @@ impl Plugin for BloomPlugin {
let draw_2d_graph = graph
.get_sub_graph_mut(crate::core_2d::graph::NAME)
.unwrap();
draw_2d_graph.add_node(draw_2d_graph::node::BLOOM, bloom_node);
draw_2d_graph.add_node(core_2d::graph::node::BLOOM, bloom_node);
draw_2d_graph
.add_slot_edge(
draw_2d_graph.input_node().unwrap().id,
crate::core_2d::graph::input::VIEW_ENTITY,
draw_2d_graph::node::BLOOM,
core_2d::graph::node::BLOOM,
BloomNode::IN_VIEW,
)
.unwrap();
// MAIN_PASS -> BLOOM -> TONEMAPPING
draw_2d_graph
.add_node_edge(
crate::core_2d::graph::node::MAIN_PASS,
draw_2d_graph::node::BLOOM,
core_2d::graph::node::BLOOM,
)
.unwrap();
draw_2d_graph
.add_node_edge(
draw_2d_graph::node::BLOOM,
core_2d::graph::node::BLOOM,
crate::core_2d::graph::node::TONEMAPPING,
)
.unwrap();
Expand Down Expand Up @@ -164,7 +151,7 @@ impl Default for BloomSettings {
}
}

struct BloomNode {
pub struct BloomNode {
view_query: QueryState<(
&'static ExtractedCamera,
&'static ViewTarget,
Expand All @@ -175,9 +162,9 @@ struct BloomNode {
}

impl BloomNode {
const IN_VIEW: &'static str = "view";
pub const IN_VIEW: &'static str = "view";
Comment on lines -178 to +165
Copy link
Member

@mockersf mockersf Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is going to be public and reused, should it have a more unique value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is in the scope of this PR, currently other core nodes all have the same input slot name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense that the input slots have the same name if they serve the same purpose for their respective nodes.


fn new(world: &mut World) -> Self {
pub fn new(world: &mut World) -> Self {
Self {
view_query: QueryState::new(world),
}
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core_pipeline/src/core_2d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod graph {
}
pub mod node {
pub const MAIN_PASS: &str = "main_pass";
pub const BLOOM: &str = "bloom";
pub const TONEMAPPING: &str = "tonemapping";
pub const UPSCALING: &str = "upscaling";
pub const END_MAIN_PASS_POST_PROCESSING: &str = "end_main_pass_post_processing";
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod graph {
}
pub mod node {
pub const MAIN_PASS: &str = "main_pass";
pub const BLOOM: &str = "bloom";
pub const TONEMAPPING: &str = "tonemapping";
pub const UPSCALING: &str = "upscaling";
pub const END_MAIN_PASS_POST_PROCESSING: &str = "end_main_pass_post_processing";
Expand Down
11 changes: 5 additions & 6 deletions crates/bevy_core_pipeline/src/fxaa/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
mod node;

use crate::{
core_2d, core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state,
fxaa::node::FxaaNode,
};
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 @@ -20,6 +15,10 @@ use bevy_render::{
RenderApp, RenderStage,
};

mod node;

pub use node::FxaaNode;

#[derive(Eq, PartialEq, Hash, Clone, Copy)]
pub enum Sensitivity {
Low,
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
mod node;

pub use node::TonemappingNode;

use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, HandleUntyped};
Expand All @@ -14,6 +10,10 @@ use bevy_render::renderer::RenderDevice;
use bevy_render::view::ViewTarget;
use bevy_render::{render_resource::*, RenderApp, RenderStage};

mod node;

pub use node::TonemappingNode;

const TONEMAPPING_SHADER_HANDLE: HandleUntyped =
HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 17015368199668024512);

Expand Down
10 changes: 4 additions & 6 deletions crates/bevy_core_pipeline/src/upscaling/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
mod node;

pub use node::UpscalingNode;

use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, HandleUntyped};
use bevy_ecs::prelude::*;
use bevy_reflect::TypeUuid;
use bevy_render::renderer::RenderDevice;
use bevy_render::view::ViewTarget;
use bevy_render::{render_resource::*, RenderApp, RenderStage};

use bevy_reflect::TypeUuid;
mod node;

use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
pub use node::UpscalingNode;

const UPSCALING_SHADER_HANDLE: HandleUntyped =
HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 14589267395627146578);
Expand Down