During this summer my GSoC project was to improve the current Physical Sun and Sky model fixing the blue/green tint on the sky and add features, such as a visible solar disk, the ability to configure the sun and the sky model with geographic location and other improvements and for the sun and sky.
- #2811 Fix spectral illuminance to CIE XYZ conversions.
- #2873 Fix compilation when spectral support is disabled.
- #2870 Sun position algorithm.
- #2866 Add sun disc.
- #518 Add sun positioning algorithm.
- #365 Add sun positioner.
- #265 Add solar positional algorithm.
Before the beginning of GSoC, I start working on the PR #2811 to fix the spectral to cieXYZ conversions. Previously, Appleseed was using spectral reflectance to Before the beginning of GSoC, I start working on the PR #2811 to fix the spectral to CIE XYZ method to convert emissive cases. This was giving a blue/green tint every time that a spectral light was being used. Fixing the problem not only fixed the blue/green tint present on the sky models but also improved the overall fidelity of appleseed:
Old version on the left and newer version on the right
During the community bonding period, I had to refactor most of the code of this PR and fix some small bugs in its implementation.
A full comparison among appleseed before and after #2811 and Corona renderer and Arnold. https://mororo250.github.io/Gsoc-sun-sky/Appleseed_comparison/appleseed_compare
Even though appleseed's physical sky already had a solar radiance function implemented, it was missing a visible solar disc. Initially, I used the already implemented Preetham's radiance function to implement a visible solar disc with limb darkening. In my proposal, I included some extra optical phenomena for the sun, such as red flash and mirrages. Unfortunately, those phenomena are impossible to be implemented on an analytical sun/sky model, also mirages needs curved ray tracing5 which are not supported by appleseed.
Later, I also implemented the solar radiance function presented by Hosek-Wilkie[2].
The goal here was to allow the users to control the sun position based on options such as hours, minutes, seconds, month, day, year, latitude and longitude, that allow the user to simulate a precise sun position. To achieve this I used the algorithm presented by Jean Meeus in his book Astronomical Algorithms. This algorithm is also used by the solar position calculator of the National Oceanic and Atmospheric Administration (NOAA).
Currently, this method of positioning the sun is available in all the plug-ins: Blender, 3dMax, and Maya, but it is not possible to use it inside appleseed.studio.
Now the user can select any color as the ground albedo and the ground color is set based on ground albedo specified by the user.
Backing the sun disc into the sky causes several fireflies to appear:
The artifacts happen due to the fact that, after backing the sun into the sky, it becomes one of the most difficult to sample types of environment maps, those with the majority of their illumination concentrated in a set of small bright areas. Usually, to solve this problem we importance sample the env map. This would be the optimal solution for this problem, but it is necessary to precompute the sky into a texture for it to be possible. As a temporary solution for this, I changed the pdf function, so that when a ray hit the sun its pdf is bigger than the sky's pdf by a factor of (sun radiance / sky radiance).
When comparing the results of appleseed with other renderers, I noticed that appleseed's sun radiance was 3 to 4 times weaker than the results from other renderers, even though the sky radiance was the same.
The problem was related to how appleseed was calculating the sky radiance.
radiance *=
luminance // start with computed luminance
/ sum_value(radiance * XYZCMFCIE19312Deg[1]) // normalize to unit luminance
* (1.0f / 683.0f) // convert lumens to Watts
* RcpPi(); // convert irradiance to radiance
There are two problems here. First, the normalization is wrong. The correct formula is radiance * XYZCMFCIE19312Deg[1] * step_lambda 7, being step_lamda the range between two wavelengths. Second, we don't need to convert irradiance to radiance because we are already computing radiance.
There are several ways to improve the current physical sky model in appleseed. I have selected some features and improvements which I am planning to implement in appleseed in the next few months:
In the current implementation, we compute the sun/sky radiance every time we either sample or evaluate it. The problem of this is that we compute the radiance coming from a specific direction of the sky several times over. One way to speed up the current implementation of the sun and sky model is to precompute the sky into a texture. This also provides a better solution for the fireflies.
The ability to bind multiple suns to the sky texture and ability to change the sun's blackbody radiation.[6] I initially planned to implement this during this summer. Unfortunately, I didn’t have time to do it.
There are several ways to improve the Hosek sky model. Some of them are:
- Recompute all the input values using a more accurate non-analytical sky model, as libradtran for example.
- Include after sunset conditions to the original model.
- Add aerial perspective.
Some other renderers have implemented an improved version of the Hosek model, as V-Ray and Corona Renderer, providing much more pleasant and accurate results.
Currently, the user needs to manually set latitude, longitude, and time zone. This is not very intuitive and could be improved by allowing the user to set those variables by either selecting it on a map or searching for a specific city by name.
I am very grateful to GSoC and appleseed for the opportunity to work on a project for a renderer engine like appleseed. I learned far more than I thought I would from color science on how to properly sample an environmental map. A special thanks to François Beaune, for the many insights and advice, and the whole appleseed's community who creates an amazing and supportive atmosphere around appleseed.
[4] Lintu, Andrei et al. “Realistic Solar Disc Rendering.” WSCG (2005).