props: register "pbr" components

This commit is contained in:
Carter Anderson 2020-05-25 21:57:48 -07:00
parent c8d55fe030
commit e337ff59b8
5 changed files with 17 additions and 6 deletions

View File

@ -7,9 +7,11 @@ edition = "2018"
[dependencies]
bevy_app = { path = "../bevy_app" }
bevy_asset = { path = "../bevy_asset" }
bevy_component_registry = { path = "../bevy_component_registry" }
bevy_core = { path = "../bevy_core" }
bevy_derive = { path = "../bevy_derive" }
bevy_render = { path = "../bevy_render" }
bevy_property = { path = "../bevy_property" }
bevy_transform = { path = "../bevy_transform" }
bevy_window = { path = "../bevy_window" }
legion = { path = "../bevy_legion"}

View File

@ -9,8 +9,10 @@ pub use forward_pbr_render_graph::*;
use bevy_app::{stage, AppBuilder, AppPlugin};
use bevy_asset::AddAsset;
use bevy_component_registry::RegisterComponent;
use bevy_render::{render_graph::RenderGraph, shader};
use legion::prelude::IntoSystem;
use light::Light;
use material::StandardMaterial;
/// NOTE: this isn't PBR yet. consider this name "aspirational" :)
@ -19,10 +21,12 @@ pub struct PbrPlugin;
impl AppPlugin for PbrPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<StandardMaterial>().add_system_to_stage(
stage::POST_UPDATE,
shader::asset_shader_def_system::<StandardMaterial>.system(),
);
app.add_asset::<StandardMaterial>()
.register_component::<Light>()
.add_system_to_stage(
stage::POST_UPDATE,
shader::asset_shader_def_system::<StandardMaterial>.system(),
);
let resources = app.resources();
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
render_graph.add_pbr_graph(resources);

View File

@ -1,9 +1,11 @@
use bevy_render::{Color, PerspectiveCamera};
use bevy_transform::components::Translation;
use bevy_property::Properties;
use glam::Mat4;
use std::ops::Range;
use zerocopy::{AsBytes, FromBytes};
#[derive(Properties)]
pub struct Light {
pub color: Color,
pub fov: f32,

View File

@ -3,7 +3,7 @@ use serde::Serialize;
use std::{
any::Any,
collections::{BTreeMap, HashMap, HashSet, VecDeque},
hash::Hash,
hash::Hash, ops::Range,
};
impl_property!(String);
@ -17,6 +17,7 @@ impl_property!(HashMap<K, V> where
impl_property!(BTreeMap<K, V> where
K: Clone + Ord + Send + Sync + Serialize + 'static,
V: Clone + Send + Sync + Serialize + 'static);
impl_property!(Range<T> where T: Clone + Send + Sync + Serialize + 'static);
impl Property for usize {
#[inline]

View File

@ -2,12 +2,14 @@ use super::texture::Texture;
use crate::shader::ShaderDefSuffixProvider;
use bevy_asset::Handle;
use bevy_core::bytes::GetBytes;
use serde::{Serialize, Deserialize};
use bevy_property::Property;
use glam::Vec4;
use std::ops::{Add, AddAssign};
use zerocopy::AsBytes;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, AsBytes)]
#[derive(Debug, Clone, Copy, PartialEq, AsBytes, Serialize, Deserialize, Property)]
pub struct Color {
pub r: f32,
pub g: f32,