Skip to content

Commit

Permalink
Refactor TLAS creation into the API, remove Scene
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Oct 31, 2023
1 parent a7efd1b commit 29fb16f
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 306 deletions.
21 changes: 21 additions & 0 deletions blade-graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@
pub use naga::{StorageAccess, VectorSize};
pub type Transform = mint::RowMatrix3x4<f32>;

pub const IDENTITY_TRANSFORM: Transform = mint::RowMatrix3x4 {
x: mint::Vector4 {
x: 1.0,
y: 0.0,
z: 0.0,
w: 0.0,
},
y: mint::Vector4 {
x: 0.0,
y: 1.0,
z: 0.0,
w: 0.0,
},
z: mint::Vector4 {
x: 0.0,
y: 0.0,
z: 1.0,
w: 0.0,
},
};

#[cfg_attr(
all(not(vulkan), not(gles), any(target_os = "ios", target_os = "macos")),
path = "metal/mod.rs"
Expand Down
33 changes: 2 additions & 31 deletions blade-render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,44 +40,15 @@ pub struct Camera {
}

pub struct Object {
pub model: blade_asset::Handle<Model>,
pub transform: blade_graphics::Transform,
pub model: blade_asset::Handle<Model>,
}

impl From<blade_asset::Handle<Model>> for Object {
fn from(model: blade_asset::Handle<Model>) -> Self {
Self {
transform: blade_graphics::IDENTITY_TRANSFORM,
model,
transform: [
[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
]
.into(),
}
}
}

#[derive(Clone, Debug)]
pub struct PostProcessing {
//TODO: remove this, compute automatically
pub average_luminocity: f32,
pub exposure_key_value: f32,
pub white_level: f32,
}
impl Default for PostProcessing {
fn default() -> Self {
Self {
average_luminocity: 1.0,
exposure_key_value: 1.0,
white_level: 1.0,
}
}
}

#[derive(Default)]
pub struct Scene {
pub objects: Vec<Object>,
pub environment_map: Option<blade_asset::Handle<Texture>>,
pub post_processing: PostProcessing,
}
Loading

0 comments on commit 29fb16f

Please sign in to comment.