This is a topic I came across a long time ago when I was confronted with the following question: How do you distribute objects in a way, that for a particular location and for a given time frame, the overall amount of sunlight on the surface get’s maximized? Well, theoretically it’s quite easy since it is a classical optimization problem but how does one accurately calculate the illuminance values needed for this? The first and obvious choice is probably to use Mantra. Even though Mantra is a fantastic render engine it won’t work well for a number of reasons. Mainly because Mantra is simply not meant to be used for daylight and solar analysis but to render huge amount of data and to produce stunning images.
However, a render engine which is quite the opposite in this regard and extensively used for such simulations is Radiance. It provides everything needed for this kind of work and furthermore it is fairly easy to use. For this very reason I thought it might be a good idea to write some python scripts to share geometry and data between Houdini and Radiance. While this worked quite hassle-free in general, it was unfortunately slow and the lack of interactivity became a problem. The reason for this was mainly because of the somewhat cumbersome workflow and data exchange between the two programs which was as follow:
- Export geometry and sample grids as OBJ
- Generate Radiance description files for materials, sky and so on
- Render the scene in Radiance
- Retrieve the result and bring it back into Houdini for visualization and optimization
This was more or less acceptable for simple tests but for using it on an optimization problem it was simply to slow. Nearly half of the computation time got lost in sharing data between Houdini and Radiance and it became quite apparent that I have to leave Radiance aside and implement everything in Houdini.
And that’s exactly what I finally did. To calculate the sun position I implemented NREL’s Solar Position Algorithm (SPA). It is available as C version but I used Python since it’s calendar library made things easier. This first step was pretty easy. The hard part was to find a good radiance and luminance distribution model for the sky. Most of the physical sky models used by render engines are largely based on the paper “A Practical Analytic Model for Daylight” by Preetham, Shirley and Smits. For simulation purposes however, it is more common to rely on the CIE Standard Sky like Radiance does. Since I couldn’t decide which one is best to implement I finally did the implementation for both, together with the CIE Standard General Sky and the Perez Sky Model.
In the UI you have to set up the position in regards to latitude and longitude and the time period for which the calculation should be performed. Currently the following sky models with different luminance distributions are implemented: CIE overcast sky, CIE standard, clear sky, CIE standard general sky, Preetham, Perez
The different luminance distributions of the CIE standard sky can be seen on the fourth image below.
Currently the following sunlight/daylight simulation types are implemented: illuminance analysis, solar radiation, daylight factor and sun hours. To check their accuracy I’ve set up some test scenes and compared the result to results from Radiance. They are not completely identical but the average difference is under 1.5% what’s more than enough for my usage.
Below are some example images showing the results of an sun hour analysis over different calculation periods. The vector field in the last image is showing the average luminance direction which is quite useful for various things. For instance, to simulate different growth processes based on sunlight and direction.