Commit 1108f27
Fix energy loss in multi-scattering term (#23203)
# Objective
With #23194 applied, the white furnace test passes for pure metals and
dielectrics, but fails for anything in between.
## Solution
The issue seems to be the multi-scattering term used in
`environment_map_light`.
The current code computes `FmsEms(mix(F0_dielectric, F0_metal,
metalness))` when it should be computing `mix(FmsEms(F0_dielectric),
FmsEms(F0_metal), metalness)`, which causes an issue as FmsEms is
non-linear in F0.
The bug is also present in the [blogpost](https://bruop.github.io/ibl/)
that was used as inspiration for the implementation, where the author
mentions that the results with multi-scattering are darker than they
should be.
## Testing
- Ran `cargo run --example testbed_white_furnace`. I've never been so
happy to see a gray image :)
- Ran `cargo run --example pbr`.
---
## Showcase
White furnace test (with #23194 also applied):
**Before:**
<img width="1280" height="720" alt="fix_vndf"
src="https://github.com/user-attachments/assets/03d93be5-7a7f-4015-9cd7-2d1f3b25f09d"
/>
**After:**
<img width="1280" height="720" alt="fix_multiscatter+vndf"
src="https://github.com/user-attachments/assets/2aa6fc31-f25c-420a-a759-44e83f47cf9f"
/>
PBR test [also on imgsli](https://imgsli.com/NDUzNjU2)
**Before:**
<img width="1280" height="720" alt="main"
src="https://github.com/user-attachments/assets/2cd1622a-42a0-4595-ae26-5cc4f50a9221"
/>
**After:**
<img width="1280" height="720" alt="this_pr"
src="https://github.com/user-attachments/assets/d29773a0-8445-4942-b118-6905e01b2f0a"
/>
---------
Co-authored-by: François Mockers <francois.mockers@vleue.com>1 parent a9192fa commit 1108f27
File tree
5 files changed
+81
-23
lines changed- crates/bevy_pbr/src
- light_probe
- render
- ssr
- release-content/release-notes
5 files changed
+81
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
307 | 313 | | |
308 | 314 | | |
309 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
310 | 334 | | |
311 | 335 | | |
312 | 336 | | |
| |||
315 | 339 | | |
316 | 340 | | |
317 | 341 | | |
| 342 | + | |
318 | 343 | | |
319 | 344 | | |
320 | | - | |
| 345 | + | |
| 346 | + | |
321 | 347 | | |
322 | 348 | | |
323 | 349 | | |
| |||
338 | 364 | | |
339 | 365 | | |
340 | 366 | | |
341 | | - | |
| 367 | + | |
| 368 | + | |
342 | 369 | | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 370 | + | |
| 371 | + | |
347 | 372 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
353 | 380 | | |
354 | 381 | | |
355 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
279 | 284 | | |
280 | 285 | | |
281 | 286 | | |
282 | | - | |
| 287 | + | |
283 | 288 | | |
284 | 289 | | |
285 | 290 | | |
| |||
388 | 393 | | |
389 | 394 | | |
390 | 395 | | |
391 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
392 | 399 | | |
393 | 400 | | |
394 | 401 | | |
| |||
415 | 422 | | |
416 | 423 | | |
417 | 424 | | |
418 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
419 | 428 | | |
420 | 429 | | |
421 | 430 | | |
| |||
735 | 744 | | |
736 | 745 | | |
737 | 746 | | |
738 | | - | |
| 747 | + | |
739 | 748 | | |
740 | 749 | | |
741 | 750 | | |
| |||
755 | 764 | | |
756 | 765 | | |
757 | 766 | | |
758 | | - | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
759 | 770 | | |
760 | 771 | | |
761 | 772 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | | - | |
83 | | - | |
84 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
403 | | - | |
| 406 | + | |
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
| |||
456 | 459 | | |
457 | 460 | | |
458 | 461 | | |
459 | | - | |
| 462 | + | |
460 | 463 | | |
461 | 464 | | |
462 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
283 | 285 | | |
284 | 286 | | |
285 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments