Skip to content

Commit f3b9345

Browse files
committed
release notes and migration guide
1 parent 2181d5a commit f3b9345

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "Generalized Atmospheric Scattering Media"
3+
authors: ["@ecoskey"]
4+
pull_requests: [20838]
5+
---
6+
7+
Most of the fields on `Atmosphere` have been removed in favor of a handle
8+
to the new `ScatteringMedium` asset.
9+
10+
```diff
11+
pub struct Atmosphere {
12+
pub bottom_radius: f32,
13+
pub top_radius: f32,
14+
pub ground_albedo: Vec3,
15+
+ pub medium: Handle<ScatteringMedium>,
16+
- pub rayleigh_density_exp_scale: f32,
17+
- pub rayleigh_scattering: Vec3,
18+
- pub mie_density_exp_scale: f32,
19+
- pub mie_scattering: f32,
20+
- pub mie_absorption: f32,
21+
- pub mie_asymmetry: f32,
22+
- pub ozone_layer_altitude: f32,
23+
- pub ozone_layer_width: f32,
24+
- pub ozone_absorption: Vec3,
25+
}
26+
```
27+
28+
Unfortunately, this means `Atmosphere` no longer implements `Default`. Instead,
29+
you can still access the default earthlike atmosphere through the
30+
`EarthlikeAtmosphere` resource:
31+
32+
```rust
33+
fn setup_camera(
34+
mut commands: Commands,
35+
earthlike_atmosphere: Res<EarthlikeAtmosphere>
36+
) {
37+
commands.spawn((
38+
Camera3d,
39+
earthlike_atmosphere.get(),
40+
));
41+
}
42+
```
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: "Generalized Atmospheric Scattering Media"
3+
authors: ["@ecoskey"]
4+
pull_requests: [20838]
5+
---
6+
7+
Until now, Bevy's atmospheric scattering system has been fast and beautiful, but
8+
not very customizable. There's only a limited number of ways to customize the
9+
existing parameters, which constrain the system to mostly earth-like scenes.
10+
11+
Bevy 0.18 introduces a new `ScatteringMedium` asset for designing atmospheric
12+
scattering media of all kinds: clear desert skies, foggy coastlines, and
13+
even atmospheres of other planets! We've used Bevy's asset system to the
14+
fullest--alongside some custom optimizations--to make sure rendering stays
15+
fast even for complicated scattering media.
16+
17+
```rust
18+
fn setup_camera(
19+
mut commands: Commands,
20+
mut media: ResMut<Assets<ScatteringMedium>>,
21+
) {
22+
// Also feel free to use `ScatteringMedium::earthlike()`!
23+
let medium = media.add(ScatteringMedium::new(
24+
256,
25+
256,
26+
[
27+
ScatteringTerm {
28+
absorption: Vec3::ZERO,
29+
scattering: Vec3::new(5.802e-6, 13.558e-6, 33.100e-6),
30+
falloff: Falloff::Exponential { strength: 12.5 },
31+
phase: PhaseFunction::Rayleigh,
32+
},
33+
ScatteringTerm {
34+
absorption: Vec3::splat(3.996e-6),
35+
scattering: Vec3::splat(0.444e-6),
36+
falloff: Falloff::Exponential { strength: 83.5 },
37+
phase: PhaseFunction::Mie { asymmetry: 0.8 },
38+
},
39+
ScatteringTerm {
40+
absorption: Vec3::new(0.650e-6, 1.881e-6, 0.085e-6),
41+
scattering: Vec3::ZERO,
42+
falloff: Falloff::Tent {
43+
center: 0.75,
44+
width: 0.3,
45+
},
46+
phase: PhaseFunction::Isotropic,
47+
},
48+
],
49+
));
50+
51+
commands.spawn((
52+
Camera3d,
53+
Atmosphere::earthlike(medium)
54+
));
55+
}
56+
57+
// We've provided a nice `EarthlikeAtmosphere` resource
58+
// for the most common case :)
59+
fn setup_camera_simple(
60+
mut commands: Commands,
61+
earthlike_atmosphere: Res<EarthlikeAtmosphere>
62+
) {
63+
commands.spawn((
64+
Camera3d,
65+
earthlike_atmosphere.get(),
66+
));
67+
}
68+
```
69+
70+
(TODO: engine example of martian/extraterrestrial sunrise)
71+
72+
Alongside this change we've also added a bunch of documentation, and links to
73+
learn more about the technical terms used. It's definitely a complex feature
74+
under the hood, so we're hoping to make the learning curve a little less steep :)

0 commit comments

Comments
 (0)