# Refactoring Bevy Lighting and Shadows
## Who
* Rob
* Luis Almeida
* 1st year masters in Computer Engineering, undergraduate in Mechanical Engineering
* Python, C, C++
* Nate
* Junior in Computer Engineering, with a second focus on Software Engineering
* 2 years of C
* C++ Object-Oriented course
* Rust book, chapter 13, and redoing a project in Rust
## What and Why
* Bevy [lights](https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr/src/light.rs) and [more lights](https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr/src/render/light.rs)
* Built before I knew what I was doing, and iterated on by many
* Monolithic
## Notes
* Introduced rasterisation, clustering, shadow mapping, and other bits and pieces of how rendering works
* Nate had notes on https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr/src/light.rs so we walked through that and talked a about what each part was. The
## Plan
* Break down steps
* Get familiar with Bevy by working through the [Bevy book](https://bevyengine.org/learn/quick-start/getting-started/) to get an understanding of Bevy and its Entity-Component System
* Refactor the `check_light_mesh_visibility` system
* Make one system for handling directional lights, and one that handles point and spot lights
* Make changes, [test performance](https://github.com/bevyengine/bevy/blob/main/docs/profiling.md#tracy-profiler), make a pull request, iterate review.
* Separate out ambient lighting into its own module. Rob suggests:
* Make a light subdirectory at `bevy_pbr/src/light/``
* Move `bevy_pbr/src/light.rs` to `bevy_pbr/src/light/mod.rs`
* Move the ambient light code out of `mod.rs` to `bevy_pbr/src/light/ambient_light.rs`
* Add the ambient light module to the light module
* Update the surrounding code to make it easy to use the ambient light functionality like before
* Simple, small, often