Skip to content

Commit

Permalink
removed extraneous crates dir, broke out shader compilation and linka…
Browse files Browse the repository at this point in the history
…ge generation into xtask, debugging shadow mapping
  • Loading branch information
schell committed Dec 27, 2024
1 parent e94d5d3 commit 4e7e18c
Show file tree
Hide file tree
Showing 60 changed files with 2,703 additions and 2,474 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[alias]
shaders = "gpu toml crates/renderling"
xtask = "run --package xtask --"

[build]
rustflags = ["--cfg=web_sys_unstable_apis"]
Expand Down
37 changes: 29 additions & 8 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ members = [
"crates/example-wasm",
"crates/loading-bytes",
"crates/renderling",
"crates/renderling-build",
"crates/renderling-ui",
"crates/sandbox"
"crates/sandbox",
"crates/xtask"
]

exclude = ["./shaders"]
Expand All @@ -17,6 +19,8 @@ resolver = "2"
assert_approx_eq = "1.1.0"
async-channel = "1.8"
bytemuck = { version = "1.13.0", features = ["derive"] }
clap = { version = "4.5.23", features = ["derive"] }
cfg_aliases = "0.2"
crabslab = { version = "0.6.2", default-features = false }
ctor = "0.2.2"
dagga = "0.2.1"
Expand All @@ -29,7 +33,9 @@ log = "0.4"
naga = { version = "23.0.0", features = ["spv-in", "wgsl-out", "wgsl-in", "msl-out"] }
pretty_assertions = "1.4.0"
proc-macro2 = { version = "1.0", features = ["span-locations"] }
quote = "1.0"
rustc-hash = "1.1"
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.117"
send_wrapper = "0.6.0"
snafu = "0.7"
Expand Down
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,7 +9,7 @@ use renderling::{
atlas::AtlasImage,
bvol::{Aabb, BoundingSphere},
camera::Camera,
light::{DirectionalLight, Light},
light::{DirectionalLight, Light, ShadowMap},
math::{Mat4, UVec2, Vec2, Vec3, Vec4},
skybox::Skybox,
slab::{GpuArray, Hybrid},
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
16 changes: 16 additions & 0 deletions crates/renderling-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "renderling_build"
version = "0.1.0"
edition = "2021"
description = "Builds shader linkage for the Renderling project"
repository = "https://github.com/schell/renderling"
license = "MIT OR Apache-2.0"
keywords = ["game", "graphics", "shader", "rendering"]
categories = ["rendering", "game-development", "graphics"]

[dependencies]
log.workspace = true
naga.workspace = true
quote.workspace = true
serde.workspace = true
serde_json.workspace = true
Loading

0 comments on commit 4e7e18c

Please sign in to comment.