Use PluginGroup for SolariPlugins (#20044)
This commit is contained in:
parent
d45ae74286
commit
1a3b26d433
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
//! Provides raytraced lighting.
|
//! Provides raytraced lighting.
|
||||||
//!
|
//!
|
||||||
//! See [`SolariPlugin`] for more info.
|
//! See [`SolariPlugins`] for more info.
|
||||||
//!
|
//!
|
||||||
//! 
|
//! 
|
||||||
pub mod pathtracer;
|
pub mod pathtracer;
|
||||||
@ -13,33 +13,35 @@ pub mod scene;
|
|||||||
///
|
///
|
||||||
/// This includes the most common types in this crate, re-exported for your convenience.
|
/// This includes the most common types in this crate, re-exported for your convenience.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use super::SolariPlugin;
|
pub use super::SolariPlugins;
|
||||||
pub use crate::realtime::SolariLighting;
|
pub use crate::realtime::SolariLighting;
|
||||||
pub use crate::scene::RaytracingMesh3d;
|
pub use crate::scene::RaytracingMesh3d;
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::realtime::SolariLightingPlugin;
|
use crate::realtime::SolariLightingPlugin;
|
||||||
use crate::scene::RaytracingScenePlugin;
|
use crate::scene::RaytracingScenePlugin;
|
||||||
use bevy_app::{App, Plugin};
|
use bevy_app::{PluginGroup, PluginGroupBuilder};
|
||||||
use bevy_render::settings::WgpuFeatures;
|
use bevy_render::settings::WgpuFeatures;
|
||||||
|
|
||||||
/// An experimental plugin for raytraced lighting.
|
/// An experimental set of plugins for raytraced lighting.
|
||||||
///
|
///
|
||||||
/// This plugin provides:
|
/// This plugin group provides:
|
||||||
/// * [`SolariLightingPlugin`] - Raytraced direct and indirect lighting (indirect lighting not yet implemented).
|
/// * [`SolariLightingPlugin`] - Raytraced direct and indirect lighting (indirect lighting not yet implemented).
|
||||||
/// * [`RaytracingScenePlugin`] - BLAS building, resource and lighting binding.
|
/// * [`RaytracingScenePlugin`] - BLAS building, resource and lighting binding.
|
||||||
/// * [`pathtracer::PathtracingPlugin`] - A non-realtime pathtracer for validation purposes.
|
/// * [`pathtracer::PathtracingPlugin`] - A non-realtime pathtracer for validation purposes (not added by default).
|
||||||
///
|
///
|
||||||
/// To get started, add `RaytracingMesh3d` and `MeshMaterial3d::<StandardMaterial>` to your entities.
|
/// To get started, add `RaytracingMesh3d` and `MeshMaterial3d::<StandardMaterial>` to your entities.
|
||||||
pub struct SolariPlugin;
|
pub struct SolariPlugins;
|
||||||
|
|
||||||
impl Plugin for SolariPlugin {
|
impl PluginGroup for SolariPlugins {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(self) -> PluginGroupBuilder {
|
||||||
app.add_plugins((RaytracingScenePlugin, SolariLightingPlugin));
|
PluginGroupBuilder::start::<Self>()
|
||||||
|
.add(RaytracingScenePlugin)
|
||||||
|
.add(SolariLightingPlugin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SolariPlugin {
|
impl SolariPlugins {
|
||||||
/// [`WgpuFeatures`] required for this plugin to function.
|
/// [`WgpuFeatures`] required for this plugin to function.
|
||||||
pub fn required_wgpu_features() -> WgpuFeatures {
|
pub fn required_wgpu_features() -> WgpuFeatures {
|
||||||
WgpuFeatures::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE
|
WgpuFeatures::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE
|
||||||
|
@ -2,7 +2,7 @@ mod extract;
|
|||||||
mod node;
|
mod node;
|
||||||
mod prepare;
|
mod prepare;
|
||||||
|
|
||||||
use crate::SolariPlugin;
|
use crate::SolariPlugins;
|
||||||
use bevy_app::{App, Plugin};
|
use bevy_app::{App, Plugin};
|
||||||
use bevy_asset::embedded_asset;
|
use bevy_asset::embedded_asset;
|
||||||
use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d};
|
use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d};
|
||||||
@ -37,10 +37,10 @@ impl Plugin for PathtracingPlugin {
|
|||||||
|
|
||||||
let render_device = render_app.world().resource::<RenderDevice>();
|
let render_device = render_app.world().resource::<RenderDevice>();
|
||||||
let features = render_device.features();
|
let features = render_device.features();
|
||||||
if !features.contains(SolariPlugin::required_wgpu_features()) {
|
if !features.contains(SolariPlugins::required_wgpu_features()) {
|
||||||
warn!(
|
warn!(
|
||||||
"PathtracingPlugin not loaded. GPU lacks support for required features: {:?}.",
|
"PathtracingPlugin not loaded. GPU lacks support for required features: {:?}.",
|
||||||
SolariPlugin::required_wgpu_features().difference(features)
|
SolariPlugins::required_wgpu_features().difference(features)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ mod extract;
|
|||||||
mod node;
|
mod node;
|
||||||
mod prepare;
|
mod prepare;
|
||||||
|
|
||||||
use crate::SolariPlugin;
|
use crate::SolariPlugins;
|
||||||
use bevy_app::{App, Plugin};
|
use bevy_app::{App, Plugin};
|
||||||
use bevy_asset::embedded_asset;
|
use bevy_asset::embedded_asset;
|
||||||
use bevy_core_pipeline::{
|
use bevy_core_pipeline::{
|
||||||
@ -38,10 +38,10 @@ impl Plugin for SolariLightingPlugin {
|
|||||||
|
|
||||||
let render_device = render_app.world().resource::<RenderDevice>();
|
let render_device = render_app.world().resource::<RenderDevice>();
|
||||||
let features = render_device.features();
|
let features = render_device.features();
|
||||||
if !features.contains(SolariPlugin::required_wgpu_features()) {
|
if !features.contains(SolariPlugins::required_wgpu_features()) {
|
||||||
warn!(
|
warn!(
|
||||||
"SolariLightingPlugin not loaded. GPU lacks support for required features: {:?}.",
|
"SolariLightingPlugin not loaded. GPU lacks support for required features: {:?}.",
|
||||||
SolariPlugin::required_wgpu_features().difference(features)
|
SolariPlugins::required_wgpu_features().difference(features)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ mod types;
|
|||||||
pub use binder::RaytracingSceneBindings;
|
pub use binder::RaytracingSceneBindings;
|
||||||
pub use types::RaytracingMesh3d;
|
pub use types::RaytracingMesh3d;
|
||||||
|
|
||||||
use crate::SolariPlugin;
|
use crate::SolariPlugins;
|
||||||
use bevy_app::{App, Plugin};
|
use bevy_app::{App, Plugin};
|
||||||
use bevy_ecs::schedule::IntoScheduleConfigs;
|
use bevy_ecs::schedule::IntoScheduleConfigs;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
@ -41,10 +41,10 @@ impl Plugin for RaytracingScenePlugin {
|
|||||||
let render_app = app.sub_app_mut(RenderApp);
|
let render_app = app.sub_app_mut(RenderApp);
|
||||||
let render_device = render_app.world().resource::<RenderDevice>();
|
let render_device = render_app.world().resource::<RenderDevice>();
|
||||||
let features = render_device.features();
|
let features = render_device.features();
|
||||||
if !features.contains(SolariPlugin::required_wgpu_features()) {
|
if !features.contains(SolariPlugins::required_wgpu_features()) {
|
||||||
warn!(
|
warn!(
|
||||||
"RaytracingScenePlugin not loaded. GPU lacks support for required features: {:?}.",
|
"RaytracingScenePlugin not loaded. GPU lacks support for required features: {:?}.",
|
||||||
SolariPlugin::required_wgpu_features().difference(features)
|
SolariPlugins::required_wgpu_features().difference(features)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use bevy::{
|
|||||||
scene::SceneInstanceReady,
|
scene::SceneInstanceReady,
|
||||||
solari::{
|
solari::{
|
||||||
pathtracer::{Pathtracer, PathtracingPlugin},
|
pathtracer::{Pathtracer, PathtracingPlugin},
|
||||||
prelude::{RaytracingMesh3d, SolariLighting, SolariPlugin},
|
prelude::{RaytracingMesh3d, SolariLighting, SolariPlugins},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use camera_controller::{CameraController, CameraControllerPlugin};
|
use camera_controller::{CameraController, CameraControllerPlugin};
|
||||||
@ -28,7 +28,7 @@ fn main() {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins((DefaultPlugins, SolariPlugin, CameraControllerPlugin))
|
app.add_plugins((DefaultPlugins, SolariPlugins, CameraControllerPlugin))
|
||||||
.insert_resource(args)
|
.insert_resource(args)
|
||||||
.add_systems(Startup, setup);
|
.add_systems(Startup, setup);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user