bug(light): point/spot range is derived from intensity, making every light global #1088

Closed
opened 2026-11-10 01:29:56 +00:00 by SakulFlee · 1 comment
Owner

Summary

Point and spot lights are packed with a “range” of intensity / 0.01. For the all-in-one scene’s intensities of 30–60 this produces range_sq values of 3000–6000, i.e. a radius of ~55–77 world units. The scene is only ~40 units wide, so every point/spot light covers almost every pixel.

That explains the measurements:

  • Forced full-light-loop culling (variant E) is slightly faster than tiled culling.
  • Tile size 8/16/32 has no effect.
  • Disabling all shadow casters costs ~40 ms, but reducing PCF from 9 taps to 1 only saves ~4 ms; the cost is the number of light/shadow evaluations, not the tap count.
  • Removing the eight R5 point lights saves ~31.9 ms.
  • Both forward and deferred are affected.

The shader treats params.z as a distance-culling radius, but the packed value is derived from intensity, not from a real range.

Relevant code:

// Crates/orbital_light/src/descriptor.rs
LightType::Point { intensity } => (0.0, 0.0, intensity / 0.01),
LightType::Spot { intensity, .. } => (scale, offset, intensity / 0.01),

The existing tests explicitly assert range_sq == intensity / 0.01, so this is current behavior rather than accidental corruption.

Fix direction

  • Add an explicit light range (or radius) to the light descriptor/API and the ECS component.
  • Use glTF KHR_lights_punctual range when importing; use a sensible engine default when absent.
  • Stop deriving range from intensity. Intensity should affect brightness, not the culling radius.
  • Add a smooth range falloff in the BRDF so reducing the radius does not create a hard light cutoff.
  • Update the packing tests and all example constructors.
  • Keep the 64-byte light layout if possible; params.w is currently padding.

Quick confirmation

A temporary test can change the packed point/spot range_sq to a fixed value such as 100.0 (radius 10) and re-capture the all-in-one scene. If deferred lighting and both shadow costs drop sharply, this is confirmed.

Acceptance criteria

  • A point/spot light has a real range independent of intensity.
  • Tiled light culling contains only lights that can affect the tile.
  • The all-in-one phone capture improves materially without deleting the coloured ring or reducing resolution.
  • Both forward and deferred paths benefit.
  • No hard range cutoff is visible at the light boundary.
## Summary Point and spot lights are packed with a “range” of `intensity / 0.01`. For the all-in-one scene’s intensities of 30–60 this produces `range_sq` values of 3000–6000, i.e. a radius of ~55–77 world units. The scene is only ~40 units wide, so every point/spot light covers almost every pixel. That explains the measurements: - Forced full-light-loop culling (variant E) is slightly faster than tiled culling. - Tile size 8/16/32 has no effect. - Disabling all shadow casters costs ~40 ms, but reducing PCF from 9 taps to 1 only saves ~4 ms; the cost is the number of light/shadow evaluations, not the tap count. - Removing the eight R5 point lights saves ~31.9 ms. - Both forward and deferred are affected. The shader treats `params.z` as a distance-culling radius, but the packed value is derived from intensity, not from a real range. Relevant code: ```rust // Crates/orbital_light/src/descriptor.rs LightType::Point { intensity } => (0.0, 0.0, intensity / 0.01), LightType::Spot { intensity, .. } => (scale, offset, intensity / 0.01), ``` The existing tests explicitly assert `range_sq == intensity / 0.01`, so this is current behavior rather than accidental corruption. ## Fix direction - Add an explicit light range (or radius) to the light descriptor/API and the ECS component. - Use glTF `KHR_lights_punctual` range when importing; use a sensible engine default when absent. - Stop deriving range from intensity. Intensity should affect brightness, not the culling radius. - Add a smooth range falloff in the BRDF so reducing the radius does not create a hard light cutoff. - Update the packing tests and all example constructors. - Keep the 64-byte light layout if possible; `params.w` is currently padding. ## Quick confirmation A temporary test can change the packed point/spot `range_sq` to a fixed value such as `100.0` (radius 10) and re-capture the all-in-one scene. If deferred lighting and both shadow costs drop sharply, this is confirmed. ## Acceptance criteria - A point/spot light has a real range independent of intensity. - Tiled light culling contains only lights that can affect the tile. - The all-in-one phone capture improves materially without deleting the coloured ring or reducing resolution. - Both forward and deferred paths benefit. - No hard range cutoff is visible at the light boundary.
Author
Owner

Confirmed on device with fixed packed ranges:

Packed range² Radius gpu_deferred gpu_scene_total FPS
3000–6000 (old) ~55–78 73.83 78.13 9.50
400 20 44.00 48.03 13.65
100 10 21.26 25.25 20.00
25 5 17.73 21.70 21.94

All subpass sums stayed exact; gpu_light_culling stayed ~1.05–1.08 ms and the deferred cost collapsed because the lists became sparse. Radius 5/10 screenshots also show hard circular light pools, confirming the cutoff needs smoothing.

Implemented on feat/perf-timings in b7086621:

  • LightDescriptor has an explicit range with DEFAULT_LIGHT_RANGE = 10.0.
  • with_range builder on both orbital_light and ECS descriptors.
  • KHR_lights_punctual import uses the glTF range, falling back to 10.
  • params.z now packs range², no longer intensity / 0.01.
  • Added a smooth range window (1 - (d/r)^4)²) to forward/deferred PBR and volumetric lighting so the cutoff is not a hard edge.
  • Exported range through the ECS realize/import path.

Next: rebuild the test project from b7086621, capture the all-in-one scene at the default 10-unit range, and check the light boundaries visually. Then re-run the culling and shadow A/B tests; they should now be meaningful.

Confirmed on device with fixed packed ranges: | Packed range² | Radius | `gpu_deferred` | `gpu_scene_total` | FPS | |---:|---:|---:|---:|---:| | 3000–6000 (old) | ~55–78 | 73.83 | 78.13 | 9.50 | | 400 | 20 | 44.00 | 48.03 | 13.65 | | 100 | 10 | 21.26 | 25.25 | 20.00 | | 25 | 5 | 17.73 | 21.70 | 21.94 | All subpass sums stayed exact; `gpu_light_culling` stayed ~1.05–1.08 ms and the deferred cost collapsed because the lists became sparse. Radius 5/10 screenshots also show hard circular light pools, confirming the cutoff needs smoothing. Implemented on `feat/perf-timings` in `b7086621`: - `LightDescriptor` has an explicit `range` with `DEFAULT_LIGHT_RANGE = 10.0`. - `with_range` builder on both `orbital_light` and ECS descriptors. - `KHR_lights_punctual` import uses the glTF range, falling back to 10. - `params.z` now packs `range²`, no longer `intensity / 0.01`. - Added a smooth range window (`1 - (d/r)^4)²`) to forward/deferred PBR and volumetric lighting so the cutoff is not a hard edge. - Exported range through the ECS realize/import path. Next: rebuild the test project from `b7086621`, capture the all-in-one scene at the default 10-unit range, and check the light boundaries visually. Then re-run the culling and shadow A/B tests; they should now be meaningful.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SakulFlee/Orbital#1088
No description provided.