mirror of
https://github.com/bevyengine/bevy
synced 2024-12-20 10:03:07 +00:00
6d6bc2a8b4
This is extracted out of eb8f973646476b4a4926ba644a77e2b3a5772159 and includes some additional changes to remove all references to AppBuilder and fix examples that still used App::build() instead of App::new(). In addition I didn't extract the sub app feature as it isn't ready yet. You can use `git diff --diff-filter=M eb8f973646476b4a4926ba644a77e2b3a5772159` to find all differences in this PR. The `--diff-filtered=M` filters all files added in the original commit but not in this commit away. Co-Authored-By: Carter Anderson <mcanders1@gmail.com>
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
pub mod render_graph;
|
|
|
|
mod entity;
|
|
mod light;
|
|
mod material;
|
|
|
|
pub use entity::*;
|
|
pub use light::*;
|
|
pub use material::*;
|
|
|
|
pub mod prelude {
|
|
#[doc(hidden)]
|
|
pub use crate::{
|
|
entity::*,
|
|
light::{DirectionalLight, PointLight},
|
|
material::StandardMaterial,
|
|
};
|
|
}
|
|
|
|
use bevy_app::prelude::*;
|
|
use bevy_asset::{AddAsset, Assets, Handle};
|
|
use bevy_ecs::system::IntoSystem;
|
|
use bevy_render::{prelude::Color, shader};
|
|
use material::StandardMaterial;
|
|
use render_graph::add_pbr_graph;
|
|
|
|
/// NOTE: this isn't PBR yet. consider this name "aspirational" :)
|
|
#[derive(Default)]
|
|
pub struct PbrPlugin;
|
|
|
|
impl Plugin for PbrPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_asset::<StandardMaterial>()
|
|
.register_type::<PointLight>()
|
|
.add_system_to_stage(
|
|
CoreStage::PostUpdate,
|
|
shader::asset_shader_defs_system::<StandardMaterial>.system(),
|
|
)
|
|
.init_resource::<AmbientLight>();
|
|
add_pbr_graph(&mut app.world);
|
|
|
|
// add default StandardMaterial
|
|
let mut materials = app
|
|
.world
|
|
.get_resource_mut::<Assets<StandardMaterial>>()
|
|
.unwrap();
|
|
materials.set_untracked(
|
|
Handle::<StandardMaterial>::default(),
|
|
StandardMaterial {
|
|
base_color: Color::PINK,
|
|
unlit: true,
|
|
..Default::default()
|
|
},
|
|
);
|
|
}
|
|
}
|