diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index f94232ec156e0..519a50a69fc23 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -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::{ @@ -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); @@ -68,12 +55,12 @@ 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(); @@ -81,12 +68,12 @@ impl Plugin for BloomPlugin { 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(); @@ -98,12 +85,12 @@ 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(); @@ -111,12 +98,12 @@ impl Plugin for BloomPlugin { 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(); @@ -164,7 +151,7 @@ impl Default for BloomSettings { } } -struct BloomNode { +pub struct BloomNode { view_query: QueryState<( &'static ExtractedCamera, &'static ViewTarget, @@ -175,9 +162,9 @@ struct BloomNode { } impl BloomNode { - const IN_VIEW: &'static str = "view"; + pub const IN_VIEW: &'static str = "view"; - fn new(world: &mut World) -> Self { + pub fn new(world: &mut World) -> Self { Self { view_query: QueryState::new(world), } diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index 64362f722e59e..c51e1ad67c910 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -8,7 +8,9 @@ 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 FXAA: &str = "fxaa"; pub const UPSCALING: &str = "upscaling"; pub const END_MAIN_PASS_POST_PROCESSING: &str = "end_main_pass_post_processing"; } diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index 893c1dfe4fbb1..29e2073415d02 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -8,7 +8,9 @@ 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 FXAA: &str = "fxaa"; pub const UPSCALING: &str = "upscaling"; pub const END_MAIN_PASS_POST_PROCESSING: &str = "end_main_pass_post_processing"; } diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index 02d4d0ca257e5..5e7173ddbbaba 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -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; @@ -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, @@ -79,9 +78,6 @@ impl ExtractComponent for Fxaa { const FXAA_SHADER_HANDLE: HandleUntyped = HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 4182761465141723543); -pub const FXAA_NODE_3D: &str = "fxaa_node_3d"; -pub const FXAA_NODE_2D: &str = "fxaa_node_2d"; - /// Adds support for Fast Approximate Anti-Aliasing (FXAA) pub struct FxaaPlugin; impl Plugin for FxaaPlugin { @@ -104,23 +100,26 @@ impl Plugin for FxaaPlugin { let mut binding = render_app.world.resource_mut::(); let graph = binding.get_sub_graph_mut(core_3d::graph::NAME).unwrap(); - graph.add_node(FXAA_NODE_3D, fxaa_node); + graph.add_node(core_3d::graph::node::FXAA, fxaa_node); graph .add_slot_edge( graph.input_node().unwrap().id, core_3d::graph::input::VIEW_ENTITY, - FXAA_NODE_3D, + core_3d::graph::node::FXAA, FxaaNode::IN_VIEW, ) .unwrap(); graph - .add_node_edge(core_3d::graph::node::TONEMAPPING, FXAA_NODE_3D) + .add_node_edge( + core_3d::graph::node::TONEMAPPING, + core_3d::graph::node::FXAA, + ) .unwrap(); graph .add_node_edge( - FXAA_NODE_3D, + core_3d::graph::node::FXAA, core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING, ) .unwrap(); @@ -130,23 +129,26 @@ impl Plugin for FxaaPlugin { let mut binding = render_app.world.resource_mut::(); let graph = binding.get_sub_graph_mut(core_2d::graph::NAME).unwrap(); - graph.add_node(FXAA_NODE_2D, fxaa_node); + graph.add_node(core_2d::graph::node::FXAA, fxaa_node); graph .add_slot_edge( graph.input_node().unwrap().id, core_2d::graph::input::VIEW_ENTITY, - FXAA_NODE_2D, + core_2d::graph::node::FXAA, FxaaNode::IN_VIEW, ) .unwrap(); graph - .add_node_edge(core_2d::graph::node::TONEMAPPING, FXAA_NODE_2D) + .add_node_edge( + core_2d::graph::node::TONEMAPPING, + core_2d::graph::node::FXAA, + ) .unwrap(); graph .add_node_edge( - FXAA_NODE_2D, + core_2d::graph::node::FXAA, core_2d::graph::node::END_MAIN_PASS_POST_PROCESSING, ) .unwrap(); diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index 3b417e8c82af9..8c08d596054e1 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -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}; @@ -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); diff --git a/crates/bevy_core_pipeline/src/upscaling/mod.rs b/crates/bevy_core_pipeline/src/upscaling/mod.rs index 139d060eaf7c7..b8fa9718d000f 100644 --- a/crates/bevy_core_pipeline/src/upscaling/mod.rs +++ b/crates/bevy_core_pipeline/src/upscaling/mod.rs @@ -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);