Table of Contents
Radiance Tech Tips
Sundry notes and tech tips on Radiance – old and new.
Scenario: Creation of images showing the distribution of illuminance across a workplane from a high viewpoint and using the fore clipping plane to remove foreground objects.
Problem: With arbitrary shaped/orientated workplanes it is generally not possible to avoid including adjacent spaces and wall voids etc. in the final image. I usually create a stencil rendering for the same view parameters showing just the workplane (now set to “glow”) and use those pixels to pick-out the pixels I want in the illuminance rendering (say, to profile the illuminance distribution across the workplane). See the top two images here:
This method works fine most of the time provided that you can crank-up the ambient parameters to avoid light leaks. These can be fairly nasty when they do occur – the pixels affected by a leak can have an illuminance much higher than nearby unaffected pixels. In the example shown, the leaky pixels have a value >1000x that of their non-leaky neighbours. Needless to say, these affected pixels play havoc with any numerical measure of illuminance that you might want to get from your image. The computational cost of leak prevention can be expensive.
I've long had this hunch that the propensity for leaks might be reduced if we could prevent rpict from doing any initial sampling off the workplane, and so avoid populating the ambient file with outside and wall-void values at the zero level. It turns out that it can't be done directly with rpict. However there is a way using rtrace and potpourri of other Radiance programs. I couldn't figure out how to do it. Fortunately, Greg Ward could – he came up with this suggestion:
Greg: “Rpict isn't very good about working on subimages, unless they're perfectly rectangular. However, you can use rtrace to accomplish this, with a little effort. Basically, you need to zero out the ray directions on all pixels you don't want computed. Something like1):
vwrays -ff -x 512 -y 512 -vf best.vf \ | rlam -if6 - -if1 '\!pvalue -h -H -df -b stencil.pic' \ | rcalc -if7 -of -e '$1=$1;$2=$2;$3=$3' -e 'out(v)=if($7-.5,v,0)' \ -e '$4=out($4);$5=out($5);$6=out($6)' \ | rtrace -ffc `vwrays -d -x 512 -y 512 -vf best.vf` -i scene.oct \ > stencilled_ill.pic
Irradiances should be calculated wherever the stencil pixels are greater than 0.5, and zeros will be written to the output picture everywhere else. You can tweak the definition of the out(v) function to get a range of values, instead. The necessity of the '\' (backslash) character to escape the '!' depends on which shell you use. The C-shell requires it, whereas most other shells don't.”
Which worked first time. The lower two images in the PDF show the “usual rpict method” and the “stencil method” renderings set to the same falsecolor scale (in Photosphere). In addition to preventing leaks, the stencil method was four times faster. Both renderings were, of course, generated using the same ambient parameters – in this case:
-ab 2 -ad 2048 -ar 128 -aa 0.2 -as 512
These need to be included in the rtrace command for the stencil method. The effectiveness in terms of leak prevention and increased speed will be highly dependent on the scene, the view and the ambient settings. As ever, some testing is advised.
Original radiance-online posting here.
See Thomas Bleicher's variant on the stencil method here.