Commit 3da4116
Add bevy_light::SunDisk (#20434)
# Objective
* Fixes **#20425** (GI probes capture the sun disk while a
`DirectionalLight` also lights the scene, so we need a way to skip the
disk during probe baking).
* ~~**Add `sun_disk_intensity: f32` to `AtmosphereSettings`** so you can
smoothly hide, dim, or over‑brighten the sun disk without affecting the
visible illumination of scene objects, while still allowing the sun’s
radiance to scatter into the atmosphere even when the disk itself is
hidden.~~
* Add a bevy_light::SunDisk component that acts as an add‑on to
DirectionalLight.
#20434 (comment)
## Testing
* Ran the official `atmosphere` example on a MacBook M1 (see showcase
below).
* Toggled bloom on/off and tried intensities 0, 0.01, 1, and 10 — the
sky looks correct and no warnings appear.
* Noticed a small dark “hole” in the center of the sun disk under some
settings; this artifact was present before these changes (often hidden
by bloom) and probably deserves further investigation. (FIXED IN THIS
PR)
I’m new to WGSL/shader code — please point out anything silly! 🙂
---
## Showcase
* Scene brightness changes with intensity only because bloom amplifies
the bright disk; sky illumination stays unchanged.
* With bloom disabled, the disk is the only thing that changes — the
rest of the scene looks identical.
* Raising intensity above 1.0 doesn’t affect the scene without bloom
(the disk is already 100 % white) but boosts the bloom halo when bloom
is enabled.
* Lowering intensity reduces the bloom halo; drop it far enough and the
disk blends into the sky, which is physically plausible for very dim
suns.
<details>
<summary><strong>1.0</strong> (bloom on) — normal</summary>
<img width="1680" height="1050" alt="default 1 0"
src="https://github.com/user-attachments/assets/89144e52-1159-42c6-9325-f80f986349ec"
/>
</details>
<details>
<summary><strong>0.0</strong> (bloom on) — no disk</summary>
<img width="1680" height="1050" alt="no sun 0 0"
src="https://github.com/user-attachments/assets/2b3842ae-26ed-45bf-9266-20189bc487a7"
/>
</details>
<details>
<summary><strong>0.01</strong> (bloom on) — low brightness, tiny bloom
effect</summary>
<img width="1680" height="1050" alt="0 21"
src="https://github.com/user-attachments/assets/8c3943df-74b6-4422-8c9b-061e56ee33f8"
/>
</details>
<details>
<summary><strong>0.00001</strong> (bloom on) — disk blends into the
sky</summary>
<img width="1680" height="1050" alt="0 00001"
src="https://github.com/user-attachments/assets/e1228131-41b2-4f30-b50d-ebceebc8cabb"
/>
</details>
<details>
<summary><strong>10.0</strong> (bloom on) — blinding glare</summary>
<img width="1680" height="1050" alt="10"
src="https://github.com/user-attachments/assets/3527c6d6-27ec-4e6f-9e9f-564a6b246bba"
/>
</details>
<details>
<summary><strong>1.0</strong> (bloom off) — normal sun with no
bloom</summary>
<img width="1680" height="1050" alt="1 no bloom"
src="https://github.com/user-attachments/assets/b62ce660-cb65-46b1-b211-a5d330b08719"
/>
</details>
<details>
<summary><strong>10.0</strong> (bloom off) — indistinguishable from 1.0
when bloom is off</summary>
<img width="1680" height="1050" alt="10 no bloom"
src="https://github.com/user-attachments/assets/17ea20dd-3de7-4bb9-82a1-16f7df9a9994"
/>
</details>
Quick question for reviewers: (not part of this PR) I’ve already
experimented with parameterizing the **sun angular size** and it works
well. It could serve as a cool artistic control or let you match skies
for planets that aren’t Earth. Would folks be interested in a follow‑up
PR?
<details>
<summary>4× sun size</summary>
<img width="1680" height="1050" alt="4x sun"
src="https://github.com/user-attachments/assets/5c39ef98-0376-48b7-b845-bfad6d87c09b"
/>
</details>
---------
Co-authored-by: Ivan Ivashchenko <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: JMS55 <[email protected]>1 parent 21dbf59 commit 3da4116
File tree
6 files changed
+74
-14
lines changed- crates
- bevy_light/src
- bevy_pbr/src
- atmosphere
- render
- bevy_solari/src/scene
6 files changed
+74
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
275 | 274 | | |
276 | 275 | | |
277 | 276 | | |
278 | | - | |
279 | | - | |
280 | 277 | | |
281 | 278 | | |
282 | 279 | | |
| |||
285 | 282 | | |
286 | 283 | | |
287 | 284 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
| 144 | + | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| |||
327 | 332 | | |
328 | 333 | | |
329 | 334 | | |
| 335 | + | |
330 | 336 | | |
331 | 337 | | |
332 | 338 | | |
| |||
508 | 514 | | |
509 | 515 | | |
510 | 516 | | |
| 517 | + | |
511 | 518 | | |
512 | 519 | | |
513 | 520 | | |
| |||
574 | 581 | | |
575 | 582 | | |
576 | 583 | | |
| 584 | + | |
| 585 | + | |
577 | 586 | | |
578 | 587 | | |
579 | 588 | | |
| |||
1200 | 1209 | | |
1201 | 1210 | | |
1202 | 1211 | | |
| 1212 | + | |
| 1213 | + | |
1203 | 1214 | | |
1204 | 1215 | | |
1205 | 1216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 26 | | |
31 | 27 | | |
32 | 28 | | |
| |||
407 | 403 | | |
408 | 404 | | |
409 | 405 | | |
410 | | - | |
| 406 | + | |
411 | 407 | | |
412 | 408 | | |
413 | 409 | | |
| |||
0 commit comments