aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-04-24 14:03:15 -0400
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-04-24 14:03:15 -0400
commitf98b27592b2482dc89adc055073a3ee015f2424e (patch)
tree43a52b2ba3640a0711306beee74cc27273d2f017 /src/lib.rs
Initial Commitv0.1.0
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..fdf3fa8
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,43 @@
+use bevy::{prelude::*, render::{RenderApp, render_graph::{RenderGraphApp, ViewNodeRunner}, extract_component::ExtractComponentPlugin}, asset::embedded_asset, core_pipeline::core_3d::graph::{Core3d, Node3d}};
+
+use crate::components::DitherPostProcessSettings;
+
+pub struct DitherPostProcessPlugin;
+
+pub mod components;
+mod resources;
+mod nodes;
+
+impl Plugin for DitherPostProcessPlugin {
+ fn build(&self, app: &mut App) {
+ embedded_asset!(app, "../assets/shaders/dither_post_process.wgsl");
+
+ app.add_plugins((
+ ExtractComponentPlugin::<DitherPostProcessSettings>::default(),
+ ));
+
+ let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
+ return;
+ };
+
+ render_app.add_render_graph_node::<ViewNodeRunner<nodes::DitherRenderNode>>(
+ Core3d,
+ nodes::DitherRenderLabel,
+ ).add_render_graph_edges(
+ Core3d,
+ (
+ Node3d::Tonemapping,
+ nodes::DitherRenderLabel,
+ Node3d::EndMainPassPostProcessing,
+ ),
+ );
+ }
+
+ fn finish(&self, app: &mut App) {
+ let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
+ return;
+ };
+
+ render_app.init_resource::<resources::DitherPostProcessPipeline>();
+ }
+}