Skip to main content

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},
13    core::RenderApp,
14    sync::ExtractResourcePlugin,
15    utils::ssbo_mesh::SsboMeshDescriptor
16};
17
18mod color;
19mod post_process_mesh;
20pub(crate) mod ssbo_mesh;
21
22pub use color::Color;
23pub use post_process_mesh::PostProcessingMesh;
24pub use ssbo_mesh::{SsboMesh, SsboMeshBinding};
25
26/** Multisample anti-aliasing sample count used throughout the renderer. */
27pub const MSAA_SAMPLE_COUNT: u32 = 4;
28
29pub(crate) struct UtilsPlugin;
30impl Plugin for UtilsPlugin {
31    fn build(&self, app: &mut App) {
32        // Add the ssbo
33        app.add_plugins((
34            RenderDataRegisterPlugin::<SsboMesh>::default(),
35            RenderBindingRegisterPlugin::<SsboMeshBinding>::default()
36        ));
37        app.get_sub_app_mut(RenderApp)
38            .unwrap()
39            .init_resource::<SsboMeshDescriptor>();
40
41        // Add the creation of the mesh for post-processing passes
42        app.init_resource::<PostProcessingMesh>()
43            .add_systems(Startup, PostProcessingMesh::init)
44            .add_plugins(ExtractResourcePlugin::<PostProcessingMesh>::default());
45    }
46}