# how to generate a customized cumulative sky based on an arbitrarily defined sky brightness formular?

suppose I have a formular which defines the luminance of a point (L) in the
sky according to it's solar altitude and solar azimuth:

L = f(altitude, azimuth)

how to generate a sky file which describes the cumulative sky brightness
distribution pattern based on this formular.

I roughly know that gencumulativesky.exe can only take weather file as input
to create a .cal file which will be cited in the .sky file to generate the

But can we write our own sky.cal file to define the rationle to determine
sky radiance or luminace distribution pattern? and How to do that?

e.g. what if the sky brightness pattern is something like a checkerboard
pattern with black and white patches arranged in alternating way?

Thanks!

Ji

Hi Ji Zhang!

L = f(altitude, azimuth)

how to generate a sky file which describes the cumulative sky brightness
distribution pattern based on this formular.

Did you take a look at skybright.cal? It should serve as a starting point. Your file should be far less complicated, though. Learning the cal-file-language in Radiance is done best by

1) studying examples (the lib/ directory is full of them)

2) studying rayinit.cal (it contains all the variables that are available to you as well as functions - e.g. the surface normal Nx Ny Nz that should useful

4) trying with simple examples, debugging / comparing results to what is expected

Later, if you modify (using brightfunc) a source of type glow (RGB 1 1 1) calling the cal file, you can multiply the (1 1 1) by the variable selected in the brighfunc definition and (hopefully) defined in the cal-file.

Using gensky, everyone is already doing this. Looking at the output of calling "gensky 03 21 10CET +i -a 51 -o 7":

(...)
void brightfunc skyfunc
2 skybr skybright.cal
0
7 4 1.05e+01 3.82e+00 1.12e+00 0.807462 -0.462819 0.365792
(...)

This means that skyfunc is a modifier that, if applied to a glow material, will multiply each of the three channels (which is usually RGB) of the glow material with the value of variable skybr.

The value of skybr is found by evaluating the skybright.cal file (which is in your Radiance library directory):

(...)
skybr = wmean((Dz+1.01)^10,
select(A1, sunnysky, cloudysky, unifsky, intersky),
(Dz+1.01)^-10, A3);
(...)
A1 is the first parameter passed into the cal-file (the first parameter of the fourth line of the calling brightfunc definition, '4' in this example. The select command here checks the value, and, as it is '4' here, returns the 4th of the four skytype-variables - intersky. Compare to the gensky command line: gensky 03 21 10CET +i -a 51 -o 7 (+i means intermediate sky with sun).

A3 is 3.82e+00 according to my skyfunc definition (see above), and refers to the ground plane brightness.

Dz is defined in rayinit.cal: Dx, Dy, Dz is the ray direction vector at the time of evaluation - which means at the time the ray hits the geometry modified by the brightfunc, which is the sky dome here.

This is as an example how the typically used gensky tool makes use of cal-files. Again, yours should be less complicated. Just keep everything clean and in accordance with Radiance concepts and everything in SI units, and write comments

Another idea, you mention cumulative skies - unless there are problems with interpolation, you may consider brighdat, which uses data files for input.

Cheers, Lars.