Skip to content

Commit

Permalink
Shadow mapping
Browse files Browse the repository at this point in the history
Added shadow mapping shaders

reset shaders

generate linkage

thrash on gitattributes

thrash on gitattributes

thrash on gitattributes

thrash on gitattributes
  • Loading branch information
schell committed Dec 27, 2024
1 parent 09f1ea4 commit 30ae2a9
Show file tree
Hide file tree
Showing 53 changed files with 6,396 additions and 3,608 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*.md text
*.yaml text
*.spv binary
*.wgsl binary
**/*.wgsl linguist-generated binary
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,16 @@ The `crates/renderling/shaders/` folder contains the generated SPIR-V files.
To regenerate the shaders, run:

```
cargo shaders
cargo xtask compile-shaders
```

There is a `.cargo/config.toml` alias for `cargo shaders` that expands into a larger
shader compilation command.
And to explicitly re-generate `wgpu` linkage, you can run:

```
cargo xtask generate-linkage
```

...but the `build.rs` script will do this for you, so it's not strictly necessary.

## Building on WASM

Expand Down
39 changes: 31 additions & 8 deletions crates/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use renderling::{
atlas::AtlasImage,
bvol::{Aabb, BoundingSphere},
camera::Camera,
light::{DirectionalLight, Light, ShadowMap},
math::{Mat4, UVec2, Vec2, Vec3, Vec4},
pbr::light::{DirectionalLight, Light},
skybox::Skybox,
slab::{GpuArray, Hybrid},
stage::{Animator, GltfDocument, Renderlet, Stage, Vertex},
Expand Down Expand Up @@ -129,6 +129,7 @@ pub struct App {
pub stage: Stage,
camera: Hybrid<Camera>,
_light: Option<(Hybrid<DirectionalLight>, Hybrid<Light>)>,
// shadows: ShadowMap,
model: Model,
animators: Option<Vec<Animator>>,
animations_conflict: bool,
Expand All @@ -146,12 +147,21 @@ impl App {
.with_msaa_sample_count(4)
.with_debug_overlay(true);
let camera = stage.new_value(Camera::default());
// let sunlight = stage.new_value(DirectionalLight {
// direction: Vec3::NEG_Y,
// color: hex_to_vec4(0xFDFBD3FF),
// intensity: 10.0,
// });
// let light = stage.new_value(Light::from(sunlight.id()));
let sunlight = stage.new_value(DirectionalLight {
direction: Vec3::NEG_Y,
color: renderling::math::hex_to_vec4(0xFDFBD3FF),
intensity: 10.0,
});
let light = stage.new_value(Light::from(sunlight.id()));
// let shadows = ShadowMap::new(
// &ctx,
// light.id(),
// wgpu::Extent3d {
// width: 256,
// height: 256,
// depth_or_array_layers: 1,
// },
// );
// stage.set_lights([light.id()]);

stage
Expand All @@ -178,7 +188,7 @@ impl App {
stage,
camera,
_light: None,

// shadows,
model: Model::None,
animators: None,
animations_conflict: false,
Expand All @@ -204,6 +214,19 @@ impl App {

pub fn render(&self, ctx: &Context) {
let frame = ctx.get_next_frame().unwrap();
self.stage.tick();
// self.shadows.update(
// ctx,
// &self.stage.get_buffer().unwrap(),
// match &self.model {
// Model::Gltf(doc) => {
// Box::new(doc.renderlets_iter()) as Box<dyn Iterator<Item = &Hybrid<Renderlet>>>
// }
// Model::Default(def) => Box::new(std::iter::once(&def.renderlet))
// as Box<dyn Iterator<Item = &Hybrid<Renderlet>>>,
// Model::None => Box::new(std::iter::empty()),
// },
// );
self.stage.render(&frame.view());
self.ui.ui.render(&frame.view());
frame.present();
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading

0 comments on commit 30ae2a9

Please sign in to comment.