Implement a Render Graph #16
|
@ -12,8 +12,6 @@ use crate::math::Transform;
|
||||||
|
|
||||||
use self::directional::DirectionalLight;
|
use self::directional::DirectionalLight;
|
||||||
|
|
||||||
use super::render_buffer::BindGroupPair;
|
|
||||||
|
|
||||||
const MAX_LIGHT_COUNT: usize = 16;
|
const MAX_LIGHT_COUNT: usize = 16;
|
||||||
|
|
||||||
/// A struct that stores a list of lights in a wgpu::Buffer.
|
/// A struct that stores a list of lights in a wgpu::Buffer.
|
||||||
|
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lyra-ecs = { path = "../lyra-ecs", features = [ "math" ] }
|
lyra-ecs = { path = "../lyra-ecs", features = [ "math" ] }
|
||||||
lyra-reflect = { path = "../lyra-reflect" }
|
lyra-reflect = { path = "../lyra-reflect", features = [ "math" ] }
|
||||||
lyra-math = { path = "../lyra-math" }
|
lyra-math = { path = "../lyra-math" }
|
||||||
lyra-scene = { path = "../lyra-scene" }
|
lyra-scene = { path = "../lyra-scene" }
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
|
|
|
@ -34,10 +34,10 @@ impl From<gltf::material::PbrMetallicRoughness<'_>> for PbrRoughness {
|
||||||
#[derive(Clone, Debug, Default, Reflect)]
|
#[derive(Clone, Debug, Default, Reflect)]
|
||||||
pub struct PbrGlossiness {
|
pub struct PbrGlossiness {
|
||||||
/// The rgba diffuse color of the material
|
/// The rgba diffuse color of the material
|
||||||
pub diffuse_color: glam::Vec4,
|
pub diffuse_color: lyra_math::Vec4,
|
||||||
// The base color texture
|
// The base color texture
|
||||||
// pub diffuse_texture // TODO
|
// pub diffuse_texture // TODO
|
||||||
pub specular: glam::Vec3,
|
pub specular: lyra_math::Vec3,
|
||||||
/// The glossiness factor of the material.
|
/// The glossiness factor of the material.
|
||||||
/// From 0.0 (no glossiness) to 1.0 (full glossiness)
|
/// From 0.0 (no glossiness) to 1.0 (full glossiness)
|
||||||
pub glossiness: f32,
|
pub glossiness: f32,
|
||||||
|
@ -101,7 +101,7 @@ pub struct Specular {
|
||||||
pub factor: f32,
|
pub factor: f32,
|
||||||
|
|
||||||
/// The color of the specular reflection
|
/// The color of the specular reflection
|
||||||
pub color_factor: glam::Vec3,
|
pub color_factor: lyra_math::Vec3,
|
||||||
|
|
||||||
/// A texture that defines the strength of the specular reflection,
|
/// A texture that defines the strength of the specular reflection,
|
||||||
/// stored in the alpha (`A`) channel. This will be multiplied by
|
/// stored in the alpha (`A`) channel. This will be multiplied by
|
||||||
|
@ -140,7 +140,7 @@ pub struct Material {
|
||||||
//pub pbr_roughness: PbrRoughness,
|
//pub pbr_roughness: PbrRoughness,
|
||||||
/// The RGBA base color of the model. If a texture is supplied with `base_color_texture`, this value
|
/// The RGBA base color of the model. If a texture is supplied with `base_color_texture`, this value
|
||||||
/// will tint the texture. If a texture is not provided, this value would be the color of the Material.
|
/// will tint the texture. If a texture is not provided, this value would be the color of the Material.
|
||||||
pub base_color: glam::Vec4,
|
pub base_color: lyra_math::Vec4,
|
||||||
/// The metalness of the material
|
/// The metalness of the material
|
||||||
/// From 0.0 (non-metal) to 1.0 (metal)
|
/// From 0.0 (non-metal) to 1.0 (metal)
|
||||||
pub metallic: f32,
|
pub metallic: f32,
|
||||||
|
|
|
@ -50,9 +50,9 @@ impl From<Vec<u32>> for MeshIndices {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Debug, PartialEq, Reflect)]
|
#[derive(Clone, Debug, PartialEq, Reflect)]
|
||||||
pub enum VertexAttributeData {
|
pub enum VertexAttributeData {
|
||||||
Vec2(Vec<glam::Vec2>),
|
Vec2(Vec<lyra_math::Vec2>),
|
||||||
Vec3(Vec<glam::Vec3>),
|
Vec3(Vec<lyra_math::Vec3>),
|
||||||
Vec4(Vec<glam::Vec4>),
|
Vec4(Vec<lyra_math::Vec4>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VertexAttributeData {
|
impl VertexAttributeData {
|
||||||
|
|
|
@ -374,7 +374,7 @@ pub(crate) mod tests {
|
||||||
|
|
||||||
use instant::Instant;
|
use instant::Instant;
|
||||||
|
|
||||||
use crate::{Image, ResourceData, Texture};
|
use crate::{Image, ResourceData};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -431,10 +431,10 @@ pub(crate) mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn ensure_single() {
|
fn ensure_single() {
|
||||||
let man = ResourceManager::new();
|
let man = ResourceManager::new();
|
||||||
let res = man.request::<Texture>(&get_image("squiggles.png")).unwrap();
|
let res = man.request::<Image>(&get_image("squiggles.png")).unwrap();
|
||||||
assert_eq!(Arc::strong_count(&res.handle.res), 3);
|
assert_eq!(Arc::strong_count(&res.handle.res), 3);
|
||||||
|
|
||||||
let resagain = man.request::<Texture>(&get_image("squiggles.png")).unwrap();
|
let resagain = man.request::<Image>(&get_image("squiggles.png")).unwrap();
|
||||||
assert_eq!(Arc::strong_count(&resagain.handle.res), 4);
|
assert_eq!(Arc::strong_count(&resagain.handle.res), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ pub(crate) mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn ensure_none() {
|
fn ensure_none() {
|
||||||
let man = ResourceManager::new();
|
let man = ResourceManager::new();
|
||||||
let res = man.request::<Texture>(&get_image("squigglesfff.png")).unwrap();
|
let res = man.request::<Image>(&get_image("squigglesfff.png")).unwrap();
|
||||||
//let err = res.err().unwrap();
|
//let err = res.err().unwrap();
|
||||||
|
|
||||||
// 1 second should be enough to run into an error
|
// 1 second should be enough to run into an error
|
||||||
|
@ -468,7 +468,7 @@ pub(crate) mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn reload_image() {
|
fn reload_image() {
|
||||||
let man = ResourceManager::new();
|
let man = ResourceManager::new();
|
||||||
let res = man.request::<Texture>(&get_image("squiggles.png")).unwrap();
|
let res = man.request::<Image>(&get_image("squiggles.png")).unwrap();
|
||||||
busy_wait_resource(&res, 10.0);
|
busy_wait_resource(&res, 10.0);
|
||||||
let img = res.data_ref();
|
let img = res.data_ref();
|
||||||
img.unwrap();
|
img.unwrap();
|
||||||
|
@ -489,7 +489,7 @@ pub(crate) mod tests {
|
||||||
std::fs::copy(orig_path, &image_path).unwrap();
|
std::fs::copy(orig_path, &image_path).unwrap();
|
||||||
|
|
||||||
let man = ResourceManager::new();
|
let man = ResourceManager::new();
|
||||||
let res = man.request::<Texture>(&image_path).unwrap();
|
let res = man.request::<Image>(&image_path).unwrap();
|
||||||
busy_wait_resource(&res, 10.0);
|
busy_wait_resource(&res, 10.0);
|
||||||
let img = res.data_ref();
|
let img = res.data_ref();
|
||||||
img.unwrap();
|
img.unwrap();
|
||||||
|
|
Loading…
Reference in New Issue