mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
Make Core Pipeline Graph Nodes Public (#6605)
# Objective Make core pipeline graphic nodes, including `BloomNode`, `FxaaNode`, `TonemappingNode` and `UpscalingNode` public. This will allow users to construct their own render graphs with these build-in nodes. ## Solution Make them public. Also put node names into bevy's core namespace (`core_2d::graph::node`, `core_3d::graph::node`) which makes them consistent.
This commit is contained in:
parent
cb8fe5b7fd
commit
e0c3c6d166
6 changed files with 43 additions and 52 deletions
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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::<RenderGraph>();
|
||||
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::<RenderGraph>();
|
||||
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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue