wde_pbr/lib.rs
1//! Physically based rendering (PBR) integration for WaterDropEngine.
2//!
3//! This crate wires the PBR rendering stack into the engine and exposes the core
4//! building blocks to configure deferred PBR rendering.
5//!
6//! The PBR rendering stack is built on top of the deferred rendering pipeline, and consists of the following passes:
7//! - [`RenderPassEnvironment`] (feature `atmosphere`): Bakes the ambient lighting of the
8//! [`EnvironmentData`] from the sky when the sun moves: spherical harmonics for the diffuse
9//! light, and a prefiltered cube map for the reflections.
10//! - [`RenderPassDeferredGBuffer`](crate::passes::RenderPassDeferredGBuffer): Renders the scene geometry into the G-buffer (only opaque objects). It writes to the [`DepthTexture`](crate::textures::DepthTexture) and the G-buffer [`DeferredTextures`](crate::textures::DeferredTextures) (depth, albedo, normal, AO, emissive). Nothing is multisampled: averaging G-buffer samples would mix objects with the background at their edges.
11//! - [`RenderPassAmbientOcclusion`](crate::passes::RenderPassAmbientOcclusion): GTAO at half resolution from the G-buffer depth, then a depth-aware blur, configured by the [`AmbientOcclusionSettings`](crate::passes::AmbientOcclusionSettings) resource (disabled by default).
12//! - [`RenderPassDeferredLighting`](crate::passes::RenderPassDeferredLighting): Performs the lighting pass, reading from the G-buffer textures, the ambient occlusion (applied to the ambient light only), the cascaded shadow maps and the environment lighting, and writing to the HDR [`RenderTexture`](crate::textures::RenderTexture).
13//! - [`RenderPassTransparent`](crate::passes::RenderPassTransparent): Renders transparent objects, using the [`DepthTexture`](crate::textures::DepthTexture) for depth testing, and writing to the same [`RenderTexture`](crate::textures::RenderTexture) as the lighting pass.
14//! - The [`post_process`](crate::post_process) passes: fog (before the transparent objects), then the temporal anti-aliasing (TAA), the bloom, the composite (color grading, tonemapping, ...), and the anti-aliasing (FXAA or SMAA) to the swapchain. They are configured by the [`PostProcessSettings`](crate::post_process::PostProcessSettings) resource.
15//!
16//! To find out more about the deferred rendering pipeline and how to add custom render subpasses, see the documentation of the [`deferred`](crate::deferred) module.
17use crate::prelude::*;
18use bevy::prelude::*;
19
20#[doc(hidden)]
21pub mod prelude {
22 pub use crate::deferred::*;
23 pub use crate::passes::*;
24 pub use crate::post_process::*;
25 pub use crate::textures::*;
26}
27
28pub mod deferred;
29mod passes;
30pub mod post_process;
31mod textures;
32
33pub struct PbrPlugin;
34impl Plugin for PbrPlugin {
35 fn build(&self, app: &mut App) {
36 app.add_plugins(CorePlugin)
37 .add_plugins(PassesPlugin)
38 .add_plugins(PostProcessPlugin)
39 .add_plugins(DeferredPlugin);
40 }
41}