# Notes on misty sky

Another weekend excursion had me wondering if I can generate a sky using the `mist` material. Maybe… Here are some notes for now.

Earth atmosphere is continuous, with its density decreasing exponentially as altitude increases. `mist` however, is a single-scattering homogenous volume, so we’d have to approximate using ‘slabs’ of `mist` volumes, with the thickness of each slab increase exponentially to save computation (so that we don’t trace 100 layers of `mist`). Similar concept can be found from the Nishita paper:

Modeling atmosphere scattering can be simplified down to Rayleigh and Mie scattering. Rayleigh scattering part takes care of particles smaller than wavelength, whereas Mie scattering takes care of particles that are larger than wavelength, at least for the part we care about 300-800nm. So naturally, Rayleigh scattering models air molecules and Mie models aerosol particles.

Starting with Rayleigh scattering, the equation for the scattering coefficient is simple: (air density x Rayleigh cross-section). Rayleigh cross-section is wavelength dependent, and we can search for measured values from the internet, e.g. here. Using 680nm, 550nm, and 440nm for blue green and red channel, we arrive at 4.75e-06, 1.27e-05, 2.81e-05 m-1 for our Rayleigh scattering at sea level. Similarly, we can get scattering coefficient at different altitudes (for each of our `mist` slab) using different air density number, which we can find from the internet, e.g. libradtran uses Air Force Geophysics Lab data. Parameter to the `mist` materials are extinction coefficients, albedo, and asymmetry factor. For Rayleigh scattering, we can assume there is no absorption with air molecules, and isotropic scattering. This means that we can use scattering coefficients as extinction coefficients for the `mist`. Once all parameters are set for each ‘slab’ of mist, we can trace rays starting from the lower bound of each ‘slab’, starting from the earth surface. After combining at results from each slab, here is sky with only Rayleigh scattering:

We can do similar things with Mie scattering. With aerosol, we’d have non-zero absorption, and a strong forward scattering (instead of isotropic scattering with Rayleigh). I got all the coefficients from libradtran continental_average aerosol profile here. Here is one with Aerosol scattering only:

Similar combine the two would give us a nice clear sky image:

But I am not sure simply combine the two is the correct way. Any ideas?

1 Like

Here is the Rayleigh part of the model.

``````void light solar
0
0
3 10026204 10026204 10026204

solar source sun
0
0
4 0.003145686615941524 -0.6046320940399825 0.7964986726370232 0.533

void mist atmo120000
1 sun
0
6 1.0588e-07 2.8396e-07 6.2706e-07 1 1 1

void mist atmo16501
1 sun
0
6 1.1527e-06 3.0914e-06 6.8265e-06 1 1 1

void mist atmo9501
1 sun
0
6 2.4698e-06 6.6237e-06 1.4627e-05 1 1 1

void mist atmo3501
1 sun
0
6 4.1057e-06 1.1011e-05 2.4315e-05 1 1 1

void plastic l.2
0
0
5 .2 .2 .2 0 0

l.2 sphere earth
0
0
4 0 0 0 6360e3

atmo120000 sphere atmo_120000
0
0
4 0 0 0 6480000

atmo120000 bubble atmo_16502
0
0
4 0 0 0 6376502

atmo16501 sphere atmo_16501
0
0
4 0 0 0 6376501

atmo16501 bubble atmo_9502
0
0
4 0 0 0 6369502

atmo9501 sphere atmo_9501
0
0
4 0 0 0 6369501

atmo9501 bubble atmo_3502
0
0
4 0 0 0 6363502

atmo3501 sphere atmo_3501
0
0
4 0 0 0 6363501

atmo3501 bubble atmo_1
0
0
4 0 0 0 6360001
``````

Nice work, Taoning!

Adding the Rayleigh and Mie scattering together makes sense, since interaction between the two types will be a 2nd-order effect in a transparent-dominant setting. That’s my guess, anyway. I’m happy to be contradicted.

-Greg

1 Like

Yes - thank you Taoning! A blue sky without gensky (or genutahsky), for the cost of a 300MB octree - but space is cheap, right?

You inspired me to convert some vdb cloud volumes to meshes and render a puffy cloud, now using only “source”, “mist”, and “mesh” for the whole scene.

OpenVDB cloud files are at JangaFX. Conversion to isosurface took some work, and still wasn’t perfect (note the black spot near the top).

3 Likes

Mark, this looks fantastic. I remember you had some tips in modeling clouds but couldn’t find it anymore on the internet?
The octree size is indeed strange. I don’t know what’s oconv doing with large spheres. If you remove the last two `mist` slab, the octree file size collapse. If you set resolution with `-r` in oconv to something like 100, the octree size also collapse? Any idea @Greg_Ward ?

I’ve only been experimenting with rendering realistic participating volumes in Radiance for a little over two decades! But only in 2022 have I finally been able to put disparate techniques and data sources together - thanks to you. Very exciting!

The octree size is no surprise. The ratio of the largest to smallest dimensions is huge - that causes the recursive subsampling that makes the octree large. And then I added in the meter-level details in a cloud, which alone is a 425MB Radiance mesh file.

Cloud mesh uses

``````void mist cm01
1 sun
0
7 1.0e-01 1.0e-01 1.0e-01 0.95 0.95 0.95 0.0
``````

The render command for 6pm on June 10 is:
`rvu -vp 0 0 6360010 -vd 0 -1 0.7 -vh 90 -vv 90 -ms 1.0 -aa 0 -ab 3 -pe -6 scene05.oct`

1 Like

Could you combine the two scattering physics (Mie and Rayleigh) in alternating spherical shells of mist? Half of the shells would be isotropic Rayleigh mist volumes (with double the appropriate coefficients to compensate for the reduced thicknesses), and the other half would be the anisotropic (Mie) mist volumes. With a sufficient number of layers, I feel this would return a reasonable approximation of the combined effect.

I was only able to get a yellow/orange hue during sunset when I trace one layer of mist at a time, with each time attenuates the solar disk brightness and shifts its spectra. (Probably because I still not sure how `mist` works).

I modeled only two layers of Mie scattering (aerosol density drops quite sharply above 3km). Probably need more layers to get the solar color shifts right. Solar disk shifts towards “red” due to Rayleigh at the same time going through Mie scattering, causing the ‘sunset’, doesn’t it?

Here is the Mie part:

``````void light solar
0
0
3 10068932 11308521 11372983

void light solar1
0
0
3 9.452836e+06 9.737031e+06 7.824844e+06

void light solar2
0
0
3 8.856646e+06 8.344204e+06 5.320114e+06

void light solar3
0
0
3 7.789896e+06 6.156198e+06 2.487878e+06

solar3 source sun
0
0
4 -0.749218 -0.653717 0.106422 0.533

void plastic l.2
0
0
5 .2 .2 .2 0 0

l.2 sphere earth
0
0
4 0 0 0 6360e3

void mist mie35000
1 sun
0
7 5.2378e-07 6.5619e-07 8.1926e-07 0.9528 0.9564 0.9599 0.7079

void mist mie1501
1 sun
0
7 3.9247e-05 5.2872e-05 7.0418e-05 0.8901 0.8998 0.9066 0.6881

mie35000 sphere mie_35000
0
0
4 0 0 0 6395000

mie35000 bubble mie_1502
0
0
4 0 0 0 6361502

mie1501 sphere mie_1501
0
0
4 0 0 0 6361501

mie1501 bubble mie_1
0
0
4 0 0 0 6360001
``````

These three images are using the Rayleigh-only sky from @Taoning_Wang1 's top post. The place is in South-Central Colorado: ACME Mapper 2.2 LiDAR made the nearest 4-5km and third-arcsecond DEMs and Sentinel-2 satellite photos made the landscape.

2 Likes

Okay, it’s a code now. Check out genmistsky on github. It makes a plain Earth, sun, and some number of layers of Rayleigh scattering mist, between which are layers of Mie scattering. Here is a pre-dawn sky from the same spot in Colorado.

The Rayleigh layers can be spaced evenly (1 to 5 km each) for a decent view from space (-unif), or they can be spaced by equal air density steps for a good view from the ground (default). If you use a number in `oconv -n [objlim]` equal to about 3 times the number of layers, the octree is generated very quickly and takes up very little space. See the `Makefile` for a sample.

A caveat: I added code for `interface` layers, to allow the sun’s rays to bend slightly as they descend through the atmosphere. Multiple layers of these look bad, but one layer, above the highest mountains, seems to redden the twilight skies AND shows the sun a bit higher in the sky! Unfortunately, it also eliminates the wonderful alpenglow that you see in the above image.

You can get the earth textures from Blue Marble and use them with `sphere.cal`.

Thanks to everyone for the encouraging remarks, and to @Taoning_Wang1 and Nishita for the idea.

1 Like