wde_renderer/utils/
mod.rs

1//! Utility functions and resources for the renderer.
2//!
3//! This includes:
4//! - The mesh used for rendering with SSBOs, described in [`SsboMesh`].
5//! - The mesh used for post-processing passes, described in [`PostProcessingMesh`].
6//! - The transform uniform utility resource, described in [`TransformUniform`].
7//! - The lightweight color helper enum, described in [`Color`].
8
9use bevy::prelude::*;
10
11use crate::{
12    assets::{RenderBindingRegisterPlugin, RenderDataRegisterPlugin}, core::RenderApp, sync::ExtractResourcePlugin, utils::ssbo_mesh::SsboMeshDescriptor
13};
14
15mod color;
16mod post_process_mesh;
17pub(crate) mod ssbo_mesh;
18
19pub use color::Color;
20pub use post_process_mesh::PostProcessingMesh;
21pub use ssbo_mesh::{SsboMesh, SsboMeshBinding};
22
23/** Multisample anti-aliasing sample count used throughout the renderer. */
24pub const MSAA_SAMPLE_COUNT: u32 = 4;
25
26pub(crate) struct UtilsPlugin;
27impl Plugin for UtilsPlugin {
28    fn build(&self, app: &mut App) {
29        // Add the ssbo
30        app.add_plugins((
31            RenderDataRegisterPlugin::<SsboMesh>::default(),
32            RenderBindingRegisterPlugin::<SsboMeshBinding>::default()
33        ));
34        app.get_sub_app_mut(RenderApp)
35            .unwrap()
36            .init_resource::<SsboMeshDescriptor>();
37
38        // Add the creation of the mesh for post-processing passes
39        app.init_resource::<PostProcessingMesh>()
40            .add_systems(Startup, PostProcessingMesh::init)
41            .add_plugins(ExtractResourcePlugin::<PostProcessingMesh>::default());
42    }
43}