rcontrib with arbitrary light source positions

Hello,
I am new here and I hope to find someone that can guide me with the following problem.

I am trying to use rcontrib to calculate daylight coefficients for light sources at arbitrary positions.
From several tutorials I’ve learnt that I can set the light sources positioned according to Reinhart sky division with (e.g.) 2305 patches and obtain the daylight coefficients for these if I do the following:

  1. echo “void light solar 0 0 3 1e6 1e6 1e6” > light_sources.rad && cnt 2305 | rcalc -e MF:4 -f reinsrc.cal -e Rbin=recno -o ‘solar source sun 0 0 4 {Dx} {Dy} ${Dz} 0.533’ >> light_sources.rad
  2. oconv -f scene.rad lightsources.rad > scene_with_light_sources.oct
  3. rcontrib -I+ -ab 1 -y 1 -ad 256 -lw 1.0e-3 -dc 1 -dt 0 -dj 0 -faa -e MF:4 -f reinhart.cal -b rbin -bn Nrbins -m solar scene_with_light_sources.oct < sensor_point.pts

Now, I want to make rcontrib work with a different light_source.rad file that contains a number of light sources (e.g. Nrbin=100) at arbitrary positions on the sky. I am thinking that I need to write a new function file that can somehow generate rbin values from the ray direction (Dx, Dy, Dz), but I feel that there must be an easier solution.

Can someone please guide me a bit here?

Cheers!

Sam

Hi Sam, you need no calfile for that. Just give each source another modifer name. The rcontrib manpage has an example for splitting the irradiance contributions by two sources with modifiers light1 and light2:

rcontrib −I+ @render.opt −o c_%s.dat −m light1 −m light2 scene.oct < test.dat

You can do that also with 100 sources. It will be just more convenient to specify material names in a file rather than at the command line. So, based on above example, create a file sources.lst with source modifiers:

source001
source002
source003
source004

Now, we just specify that instead of the modifiers:

rcontrib −I+ @render.opt −o c_%s.dat −M sources.lst scene.oct < test.dat

This should produce c_source001.dat, c_source002.dat, c_source003.dat, c_source004.dat (the %2 formatter getting replaced with the modifier names).

To be a bit more flexible, you can generate the radfile with the sources on the fly. All this requires is a file with direction vectors and diameters (assuming you use the sourceprimitive), and a little knowledge on using awk. A basic example, assuming that dirs.lst is a text file with four columns xdir ydir zdir diameter:

cat dirs.lst |awk '{printf "void light source%03d 0 0 3 1 1 1\nsource%03d source obj%03d 0 0 4 %f %f %f %f\n\n",NR, NR, NR, $1, $2, $3, $4}'

Of coure, if your source geometries are more complicated, this may be less applicable.

Best, Lars.

2 Likes

Hi Lars,
Thank you! This is indeed a much easier solution!