Skip to content

feature: shadow mapping#158

Merged
schell merged 33 commits intomainfrom
feature/shadow-mapping
Mar 10, 2025
Merged

feature: shadow mapping#158
schell merged 33 commits intomainfrom
feature/shadow-mapping

Conversation

@schell
Copy link
Owner

@schell schell commented Feb 10, 2025

These changes provide a shadow mapping implementation for casting shadows from analytical lights.

Includes:

  • POC directional light shadows
    • ensure rendering without shadows works as expected
    • ensure bias is configurable
    • account for peter panning
  • Refactor to move lights to lighting slab
  • Multiple lights as shadow map sources
  • Support for spot light shadow maps
    • Fix spot lights shading calculations
  • Support for point light shadow maps
    • Support sampling cubemaps in Rust code
  • API refactor work

@schell schell force-pushed the feature/shadow-mapping branch from b2d0be9 to 52756b0 Compare February 10, 2025 22:55
// 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,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has affected the stag::gltf_support::test::normal_mapping_brick_sphere test.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expectedly, multiplying the intensity by 683.0 fixes the test, so no biggy.

@schell schell force-pushed the feature/shadow-mapping branch from 2f1fba8 to c9aadda Compare February 17, 2025 21:38
schell added 19 commits March 4, 2025 08:31
* lighting bindgroup

* initial shadow mapping API in place

* pin cargo gpu

* lots of bug fixes in the shadow mapping path

* more debugging shadow mapping

* can programmatically capture gpu traces, ugly shadows are working

* added configurable bias to shadow mapping

* shadow mapping culls front face to cut down peter panning

* 1 Cargo Files:
   • Cargo.lock and Cargo.toml have been updated to change the version of the
     craballoc dependency from 0.1.3 to 0.1.5.
2 Example Crate:
   • crates/example/src/lib.rs has been modified to update the lighting and shadow
     mapping logic, including changes to how shadow maps are created and used.
3 Shaders:
   • Several shader files (.spv and .wgsl) have binary differences, indicating
     updates to the compiled shader code.
4 Renderling Crate:
   • Multiple files in the crates/renderling/src directory have been updated,
     including atlas.rs, atlas/atlas_image.rs, atlas/cpu.rs, context.rs,
     draw/cpu.rs, lib.rs, light.rs, light/cpu.rs, math.rs, pbr.rs, stage.rs, and
     stage/cpu.rs.
   • These changes involve updates to the atlas and texture handling, lighting and
     shadow mapping improvements, and modifications to the rendering pipeline.
5 GLTF File:
   • The gltf/shadow_mapping_sanity_spot.blend file has binary changes, suggesting
     updates to the 3D model or scene configuration.

Overall, the changes focus on improving the rendering and lighting systems,
particularly around shadow mapping and texture management.

* feat: Add shadow map view management for directional and point lights

* feat: Implement `ShadowMapViews::new_six` for point light shadow maps

* moved shadow maps to a shadow map atlas, included atlas blitting

* WIP moving all lighting to the lighting slab w/ AnalayticalLightBundle

* functional shadows read out of the shadow map atlas
…ight intensity, move ShadowMap into its own cpu module
* WIP

* move stage's render of objects to StageRendering to reuse in SceneCubemap

* chore: hand rolled cubemap sampling
@schell schell force-pushed the feature/shadow-mapping branch from 15eb9f0 to f5557b5 Compare March 3, 2025 19:32
* cubemap sampling fixes

* fixed hand-rolled cubemap sampling

* point light shadows use disk sampling for PCF, added z_far to ShadowMapDescriptor

* update shadow map descriptor with light bundle
@schell schell marked this pull request as ready for review March 8, 2025 03:37
@schell schell merged commit 5459ea3 into main Mar 10, 2025
8 checks passed
@schell schell deleted the feature/shadow-mapping branch March 10, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant