HaloRay has taken a leap forward again, and version 3.0.0 was released today with plenty of new features, the most important ones being:

  • Realistic sky and sun rendering
  • More ways to adjust ice crystal shapes
  • Saving/loading simulations
  • Crystal shape preview window

In addition to these there are tons of small improvements and tweaks. You can go download the newest version on GitHub and take a look at the change log while you are at it.

Let’s take a closer look at some of the new features!

Realistic sky and sun

After rewriting most of the model/view GUI code in HaloRay, I wanted to work on something more visual. At first I thought rendering a realistic sky and sun would just be a vanity feature, but it turned out to be very useful when trying to understand how well or badly some dimmer halo phenomena actually show up against a bright blue sky.

All-sky image simulated with HaloRay
Realistic all-sky view rendered with HaloRay

The sky rendering code is based on the so called Preetham and Hosek-Wilkie models, which approximate sky radiance analytically, making it computationally very efficient compared to plain raytracing. The Hosek-Wilkie model is generally considered more accurate, but the model does not show any results when sun is below the horizon. Preetham still gives some results for twilight, but starts to fall apart when the sun is considerably below the horizon. For most sun elevations HaloRay uses the pure Hosek-Wilkie model, but starts to blend in results from the Preetham model when the sun is very close to the horizon, and finally fades to black when the sun is more than 10 degrees below the horizon.

The Preetham model was pretty straightforward to implement as an OpenGL compute shader after reading the article. Hosek-Wilkie was a bit more complicated, but they provide reference C code. I took parts of the reference code to generate the initialization data that was only dependent on the sun elevation and atmosphere turbidity. The rest I ported to the same OpenGL compute shader as the Preetham model, so I could easily mix them together.

Realistic sunset rendered with HaloRay
Realistic sunset rendered with HaloRay

Hosek and Wilkie also provide a very cool model to approximate solar radiance realistically, even including details like limb darkening. Limb darkening is pretty meaningless when it comes to simulating ice crystal halos, but I wanted to have fun and put it in anyway. Now I can generate realistic sunset photos!

I implemented a dumbed down version of the model, taking parts of their reference code and porting some to a compute shader. The biggest difference to the original is that I calculate the atmosphere transmittance at the highest and lowest points of the solar disk using their reference code and then linearly interpolate that value over the disk in the compute shader. In the original article Hosek and Wilkie calculate the transmittance again at every point of the disk, which makes it more accurate at very low sun elevations and high turbidities.

The main effect on the halo simulation is realistic coloration of the halo phenomena. At low sun elevations any bluish parts of the halos disappear, because the atmosphere has already scattered the smaller wavelengths away and only the longer wavelengths remain.

More versatile control of ice crystal shapes

In prior versions of HaloRay it was only possible to simulate ordinary hexagonal ice crystals. In version 3.0.0 it is possible to add pyramidal end caps to hexagonal crystals to simulate rare odd-radius halos, like in the screenshot below.

Screenshot of HaloRay showing a rendering of pyramidal halo display and ice crystal preview window
Pyramidal ice crystal halo display

In addition, HaloRay 3.0.0 allows adjusting the distances of each prism face of the ice crystal to the crystal C-axis. That way it is possible to fine-tune intensities of some halos to match photographs, or in extreme cases produce for example triangular ice crystals like the one in the image below.

Screenshot of HaloRay showing a simulated Kern arc and a preview of a triangular ice crystal
Extreme triangular ice crystal used to simulate a very well developed Kern arc

Crystal shape preview window

HaloRay already has quite a few different parameters to tweak when it comes to the ice crystal shape and orientation. It can be difficult to visualize what the crystal will be like when just looking at the sliders and numbers. Now you can see a preview of what the ice crystal you are working on looks like by going to the View menu and selecting Crystal preview.

Screenshot of crystal shape preview window, showing a wireframe model of a plate-oriented hexagonal crystal
Plate-oriented crystal in the new preview window

What’s next?

Despite all the new features added in version 3.0.0, there are still many things I’d like to add to HaloRay.

Different kinds of analysis features are important when trying to figure out how some rare halo phenomena form. These analysis features could mean for example getting statistics of the routes a ray of light has taken through ice crystals in some area of the sky, or visualizing these routes somehow. This can be technically challenging because the raytracing itself happens on the GPU and the data rates are large.

Another cool thing I’d like to work on is a command-line interface. That would enable scripting simulations, which would make it easy to for example generate images of a certain halo display at various sun elevations.