diff --git a/CHANGELOG.md b/CHANGELOG.md index 73e307c..f041763 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## Changed + +- Point lights colours are now added to ambient light, instead of multiplied by it (#24). + +## Migration guide + +- Point light intensity needs to be adjusted to account for changes to ambient light. Generally this means point light intensity values need to be lowered. See the relevant changes to the `dungeon` example. + ## [0.3.0] - 2024-08-05 ### Added diff --git a/examples/dungeon.rs b/examples/dungeon.rs index 922b3b4..48166da 100644 --- a/examples/dungeon.rs +++ b/examples/dungeon.rs @@ -72,7 +72,7 @@ fn spawn_candles(mut commands: Commands, spritesheet: Res) { point_light: PointLight2d { radius: 48.0, color: Color::Srgba(YELLOW), - intensity: 25.0, + intensity: 2.0, falloff: 4.0, ..default() }, diff --git a/examples/multiple.rs b/examples/multiple.rs index 5def599..2d6893e 100644 --- a/examples/multiple.rs +++ b/examples/multiple.rs @@ -30,7 +30,7 @@ fn setup(mut commands: Commands) { point_light: PointLight2d { color: Color::Srgba(Srgba::RED), radius: 50., - intensity: 5.0, + intensity: 1.0, ..default() }, transform: Transform::from_xyz(-50., 25., 0.), @@ -41,7 +41,7 @@ fn setup(mut commands: Commands) { point_light: PointLight2d { color: Color::WHITE, radius: 50., - intensity: 5.0, + intensity: 1.0, falloff: 5.0, ..default() }, @@ -53,7 +53,7 @@ fn setup(mut commands: Commands) { point_light: PointLight2d { color: Color::Srgba(Srgba::GREEN), radius: 75., - intensity: 5.0, + intensity: 1.0, ..default() }, transform: Transform::from_xyz(-10., -25., 0.), diff --git a/src/render/light_map/light_map.wgsl b/src/render/light_map/light_map.wgsl index 1918d2b..14484d3 100644 --- a/src/render/light_map/light_map.wgsl +++ b/src/render/light_map/light_map.wgsl @@ -8,7 +8,7 @@ world_to_ndc }; -// We're currently only using a single uniform binding for point lights in +// We're currently only using a single uniform binding for point lights in // WebGL2, which is limited to 4kb in BatchedUniformBuffer, so we need to // ensure our point lights can fit in 4kb. const MAX_POINT_LIGHTS: u32 = 82u; @@ -43,7 +43,7 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4 { return vec4(ambient_light.color.rgb, 1.0); } - var lighting_color = vec3(1.0); + var lighting_color = ambient_light.color.rgb; // WebGL2 does not support storage buffers (or runtime sized arrays), so we // need to use a fixed number of point lights. @@ -66,7 +66,7 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4 { } } - return vec4(ambient_light.color.rgb, 1.0) * vec4(lighting_color, 1.0); + return vec4(lighting_color, 1.0); } fn square(x: f32) -> f32 { @@ -122,4 +122,3 @@ fn raymarch(ray_origin: vec2, ray_target: vec2) -> f32 { // ray found occluder return 0.0; } -