2020-07-17 02:27:19 +00:00
|
|
|
pub mod render_graph;
|
2020-04-25 00:46:54 +00:00
|
|
|
|
2020-08-09 23:13:04 +00:00
|
|
|
mod entity;
|
|
|
|
mod light;
|
|
|
|
mod material;
|
|
|
|
|
2020-12-16 05:57:16 +00:00
|
|
|
use bevy_ecs::IntoSystem;
|
2020-08-09 23:13:04 +00:00
|
|
|
pub use entity::*;
|
|
|
|
pub use light::*;
|
|
|
|
pub use material::*;
|
|
|
|
|
2020-07-17 02:27:19 +00:00
|
|
|
pub mod prelude {
|
|
|
|
pub use crate::{entity::*, light::Light, material::StandardMaterial};
|
|
|
|
}
|
2020-04-25 00:46:54 +00:00
|
|
|
|
2020-07-17 01:47:51 +00:00
|
|
|
use bevy_app::prelude::*;
|
2020-10-18 20:48:15 +00:00
|
|
|
use bevy_asset::{AddAsset, Assets, Handle};
|
2020-11-28 00:39:59 +00:00
|
|
|
use bevy_reflect::RegisterTypeBuilder;
|
2020-10-18 20:48:15 +00:00
|
|
|
use bevy_render::{prelude::Color, render_graph::RenderGraph, shader};
|
2020-05-01 08:50:07 +00:00
|
|
|
use material::StandardMaterial;
|
2020-08-09 23:13:04 +00:00
|
|
|
use render_graph::add_pbr_graph;
|
2020-04-25 00:46:54 +00:00
|
|
|
|
2020-05-03 17:54:30 +00:00
|
|
|
/// NOTE: this isn't PBR yet. consider this name "aspirational" :)
|
2020-04-25 00:46:54 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct PbrPlugin;
|
|
|
|
|
2020-08-08 03:22:17 +00:00
|
|
|
impl Plugin for PbrPlugin {
|
2020-04-25 00:46:54 +00:00
|
|
|
fn build(&self, app: &mut AppBuilder) {
|
2020-05-26 04:57:48 +00:00
|
|
|
app.add_asset::<StandardMaterial>()
|
2020-11-28 00:39:59 +00:00
|
|
|
.register_type::<Light>()
|
2020-05-26 04:57:48 +00:00
|
|
|
.add_system_to_stage(
|
2021-02-18 21:20:37 +00:00
|
|
|
CoreStage::PostUpdate,
|
2020-12-16 05:57:16 +00:00
|
|
|
shader::asset_shader_defs_system::<StandardMaterial>.system(),
|
2020-11-15 19:34:55 +00:00
|
|
|
)
|
|
|
|
.init_resource::<AmbientLight>();
|
2020-04-25 00:46:54 +00:00
|
|
|
let resources = app.resources();
|
|
|
|
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
|
2020-08-09 23:13:04 +00:00
|
|
|
add_pbr_graph(&mut render_graph, resources);
|
2020-10-18 20:48:15 +00:00
|
|
|
|
|
|
|
// add default StandardMaterial
|
|
|
|
let mut materials = app
|
|
|
|
.resources()
|
|
|
|
.get_mut::<Assets<StandardMaterial>>()
|
|
|
|
.unwrap();
|
|
|
|
materials.set_untracked(
|
|
|
|
Handle::<StandardMaterial>::default(),
|
|
|
|
StandardMaterial {
|
|
|
|
albedo: Color::PINK,
|
2021-02-01 01:13:16 +00:00
|
|
|
unlit: true,
|
2020-10-18 20:48:15 +00:00
|
|
|
albedo_texture: None,
|
|
|
|
},
|
|
|
|
);
|
2020-04-25 00:46:54 +00:00
|
|
|
}
|
|
|
|
}
|