Skip to content

Commit

Permalink
shadow mapping stub
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Dec 6, 2024
1 parent a062d62 commit 1ab3eeb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/renderling/src/light/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod test {
#[test]
fn shadow_mapping_sanity() {
let ctx = crate::Context::headless(1024, 800);
let mut stage = ctx.new_stage().with_lighting(false);
let mut stage = ctx.new_stage();
let camera = stage.new_value(Camera::default());
let doc = stage
.load_gltf_document_from_path(
Expand Down
10 changes: 9 additions & 1 deletion crates/renderling/src/stage/gltf_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,15 @@ impl GltfDocument {
let light = stage.new_value(DirectionalLight {
direction: Vec3::NEG_Z,
color,
intensity,
// TODO: Set a unit for lighting.
// We don't yet use a unit for our lighting, and we should.
// NOTE:
// glTF spec [1] says directional light is in lux, whereas spot and point are
// in candelas. I haven't really set a unit, it's implicit in the shader, but it seems we
// can roughly get candelas from lux by dividing by 683 [2].
// 1. https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/README.md
// 2. https://depts.washington.edu/mictech/optics/me557/Radiometry.pdf
intensity: intensity / 683.0,
});

(light.id().into(), LightDetails::Directional(light))
Expand Down
2 changes: 1 addition & 1 deletion gltf/shadow_mapping_sanity.gltf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
1,
1
],
"intensity":683000,
"intensity":6830,
"type":"directional",
"name":"Light"
}
Expand Down

0 comments on commit 1ab3eeb

Please sign in to comment.