props: register "pbr" components
This commit is contained in:
parent
c8d55fe030
commit
e337ff59b8
@ -7,9 +7,11 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bevy_app = { path = "../bevy_app" }
|
bevy_app = { path = "../bevy_app" }
|
||||||
bevy_asset = { path = "../bevy_asset" }
|
bevy_asset = { path = "../bevy_asset" }
|
||||||
|
bevy_component_registry = { path = "../bevy_component_registry" }
|
||||||
bevy_core = { path = "../bevy_core" }
|
bevy_core = { path = "../bevy_core" }
|
||||||
bevy_derive = { path = "../bevy_derive" }
|
bevy_derive = { path = "../bevy_derive" }
|
||||||
bevy_render = { path = "../bevy_render" }
|
bevy_render = { path = "../bevy_render" }
|
||||||
|
bevy_property = { path = "../bevy_property" }
|
||||||
bevy_transform = { path = "../bevy_transform" }
|
bevy_transform = { path = "../bevy_transform" }
|
||||||
bevy_window = { path = "../bevy_window" }
|
bevy_window = { path = "../bevy_window" }
|
||||||
legion = { path = "../bevy_legion"}
|
legion = { path = "../bevy_legion"}
|
||||||
|
|||||||
@ -9,8 +9,10 @@ pub use forward_pbr_render_graph::*;
|
|||||||
|
|
||||||
use bevy_app::{stage, AppBuilder, AppPlugin};
|
use bevy_app::{stage, AppBuilder, AppPlugin};
|
||||||
use bevy_asset::AddAsset;
|
use bevy_asset::AddAsset;
|
||||||
|
use bevy_component_registry::RegisterComponent;
|
||||||
use bevy_render::{render_graph::RenderGraph, shader};
|
use bevy_render::{render_graph::RenderGraph, shader};
|
||||||
use legion::prelude::IntoSystem;
|
use legion::prelude::IntoSystem;
|
||||||
|
use light::Light;
|
||||||
use material::StandardMaterial;
|
use material::StandardMaterial;
|
||||||
|
|
||||||
/// NOTE: this isn't PBR yet. consider this name "aspirational" :)
|
/// NOTE: this isn't PBR yet. consider this name "aspirational" :)
|
||||||
@ -19,10 +21,12 @@ pub struct PbrPlugin;
|
|||||||
|
|
||||||
impl AppPlugin for PbrPlugin {
|
impl AppPlugin for PbrPlugin {
|
||||||
fn build(&self, app: &mut AppBuilder) {
|
fn build(&self, app: &mut AppBuilder) {
|
||||||
app.add_asset::<StandardMaterial>().add_system_to_stage(
|
app.add_asset::<StandardMaterial>()
|
||||||
stage::POST_UPDATE,
|
.register_component::<Light>()
|
||||||
shader::asset_shader_def_system::<StandardMaterial>.system(),
|
.add_system_to_stage(
|
||||||
);
|
stage::POST_UPDATE,
|
||||||
|
shader::asset_shader_def_system::<StandardMaterial>.system(),
|
||||||
|
);
|
||||||
let resources = app.resources();
|
let resources = app.resources();
|
||||||
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
|
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
|
||||||
render_graph.add_pbr_graph(resources);
|
render_graph.add_pbr_graph(resources);
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
use bevy_render::{Color, PerspectiveCamera};
|
use bevy_render::{Color, PerspectiveCamera};
|
||||||
use bevy_transform::components::Translation;
|
use bevy_transform::components::Translation;
|
||||||
|
use bevy_property::Properties;
|
||||||
use glam::Mat4;
|
use glam::Mat4;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use zerocopy::{AsBytes, FromBytes};
|
use zerocopy::{AsBytes, FromBytes};
|
||||||
|
|
||||||
|
#[derive(Properties)]
|
||||||
pub struct Light {
|
pub struct Light {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
pub fov: f32,
|
pub fov: f32,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use serde::Serialize;
|
|||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
collections::{BTreeMap, HashMap, HashSet, VecDeque},
|
collections::{BTreeMap, HashMap, HashSet, VecDeque},
|
||||||
hash::Hash,
|
hash::Hash, ops::Range,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl_property!(String);
|
impl_property!(String);
|
||||||
@ -17,6 +17,7 @@ impl_property!(HashMap<K, V> where
|
|||||||
impl_property!(BTreeMap<K, V> where
|
impl_property!(BTreeMap<K, V> where
|
||||||
K: Clone + Ord + Send + Sync + Serialize + 'static,
|
K: Clone + Ord + Send + Sync + Serialize + 'static,
|
||||||
V: Clone + 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 {
|
impl Property for usize {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@ -2,12 +2,14 @@ use super::texture::Texture;
|
|||||||
use crate::shader::ShaderDefSuffixProvider;
|
use crate::shader::ShaderDefSuffixProvider;
|
||||||
use bevy_asset::Handle;
|
use bevy_asset::Handle;
|
||||||
use bevy_core::bytes::GetBytes;
|
use bevy_core::bytes::GetBytes;
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
use bevy_property::Property;
|
||||||
use glam::Vec4;
|
use glam::Vec4;
|
||||||
use std::ops::{Add, AddAssign};
|
use std::ops::{Add, AddAssign};
|
||||||
use zerocopy::AsBytes;
|
use zerocopy::AsBytes;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, AsBytes)]
|
#[derive(Debug, Clone, Copy, PartialEq, AsBytes, Serialize, Deserialize, Property)]
|
||||||
pub struct Color {
|
pub struct Color {
|
||||||
pub r: f32,
|
pub r: f32,
|
||||||
pub g: f32,
|
pub g: f32,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user