Lighting Simulation with Radiance

Go from a sketch to a rendered scene in a matter of hours.
Moving Stuff Around

Most of the generators put the object at the origin, which isn't likely to be the spot you wanted. The xform utility addresses this issue. Its syntax is:

xform -t transx transy transz -rx angle\
      -s scalefactor optional_scenefile

xform can transform everything in a file, or you can pipe the output of a generator utility to it. It can scale the objects (-s factor), rotate around an axis (-ry angle means rotate around y axis) and translate to new positions (-t x y z means translate by x y z). You can use the different options multiple times, in any order. The operations are done in the order that they appear on the command line. Also, be sure to pay attention to the exact default position used by a generator. Most of them put a corner at the origin.

Figure 1 shows the effects of xform on a set of cubes generated by genbox. In this image, the viewer is on the +z axis looking back toward the origin. The red axis is +x, and green is +y.

Figure 1. Behavior of xform. The axes are color-coded: +x = red, +y = green and +z = blue. The blue box was not transformed. The red box was rotated, then translated. The green box was translated, then rotated.

The blue box is the unmodified output of a call to genbox. The red box is the same genbox with an xform:

!genbox redplastic box1 .5 .5 .5 \
    | xform -rz 45 -t 2 0 0

The green box is:

!genbox greenplastic box2 .5 .5 .5 \
    | xform -t 2 0 0 -rz 45
The materials (like redplastic) were defined right before these calls but are not shown in the listings. You can see the way the order of parameters affects the operations and, thus, the output.

More Complex Scenes

I've written a number of generators in Perl that can be used to put together log cabins and log homes (available electronically). In this article I use genlogwall, genlog and genroof. All of these output in units of inches, even though they sometimes take arguments in feet as input for convenience. The materials I use also are included in the electronic distribution.

The genlog utility generates a capped cylinder, centered along the +x axis (Figure 2). It requires several parameters:

genlog material name length_ft diam_inches

Figure 2. Unmodified output from genlog. Axes are in RGB/xyz order (R = +x, G = +y and B = +z). The x-axis is inside of the log.

The material should be predefined in your scene, and name should be something you make up. The predefined materials file I supply has three wood materials, oriented for proper-looking logs: xpine, ypine and zpine. You should choose the material that matches your eventual alignment for the log.

If you wanted to make a ten-feet tall, eight-inch diameter pole pointed in +z, with its base at (15ft, 0ft, 0ft), you'd do this:

!genlog zpine mypole 10 8 | xform -ry 90 -t 180 0 0

Remember to use the correct units for xform: 180 inches is 15 feet.

The utility genlogwall takes the following form:

genlogwall material name length_ft height_ft \
           logdiam_inches [hole_data_file]

The optional parameter is a data file that indicates what holes should be in the wall and what should be in each hole, such as a window or door. At this point, it will help if we work from the floor plan in Figure 3.

Figure 3. A floor plan for a cabin. Measurements for the holes are taken from the endpoints of the wall in which they appear.

There are four walls, each 15 feet long. I chose the southwest corner of the cabin to be (0,0,0), increasing x to the east, increasing y to the north and increasing z up. This orientation faces the building south, according to the standard-generated sky from gensky. genlogwall always places the generated wall at (0,0,0) along the x axis, as shown in Figure 4.

Figure 4. Nontransformed wall output from genlogwall. The axes' colors are in RGB/xyz order.

The hole data file is simple. One hole description per line:

holebottom_ft holetop_ft holestart_ft

The first two numbers are measured from the floor and the latter two from the beginning edge of the wall (x = 0, x increasing). The optional tag on the end indicates that you want the wall generator to fill the hole with a window or door. Our floor plan calls for two such hole description files (see Listings 2 and 3). You can use the same data file for multiple walls, but only if you want them to have the same set of holes.

Listing 2. Hole Description File (holes/southwall.holes) for the South Wall

Listing 3. Hole Description File (holes/eastwall.holes) for the East Wall

The final touch to our cabin is the roof. Generic roof generation is tricky, so the genroof tool makes you do a bit more work than the others.

genroof generates planar pieces of roof; use it multiple times with xform to generate a whole roof.

A data file is required for genroof. In the data file, provide the x-y coordinates (in feet) of the vertexes of the piece of roof, as read from the floor plan in counterclockwise order around the edge. The vertexes all must be in the positive quadrant, and any edge of the peak must run parallel to the x axis.

To figure out the points from the plan, rotate it so the peak of the roof runs left to right. Now ignore the bottom half of the roof, and think of the lower-left corner of the top half as your new origin. Your points are then (0,0), (21,0), (21, 10.5) and back to (0,0). Not too bad.

The points should be entered one per line, separated with a space, ending with the letter b, mp or p to indicate whether the point is at the bottom, somewhere in the middle or the peak of the roof section. This is necessary because it is possible to generate odd-shaped roof sections for unusual roofs.

You also need coordinates for the end cap if you want the genroof utility to fill in the ends of the roof with logs. Looking at the floor plan in our roof orientation, you easily can see that the caps should be along the walls at (3,0)®(3,7.5) and (18,0)®(18,7.5). Add this information to the end of the roof data file prefixed with the marker c:. The completed roof data file for the cabin is shown in Listing 4.

Listing 4. The Data for Our Roof Generator (roofdata)

The command-line call for genroof is:

genroof -o overhang_ft typename name \
        roofdatafile height_ft thickness_in

The overhang parameter allows the utility to adjust the position of the piece so you can transform it to the height of the wall without worrying about meeting the slope of the roof. The completed cabin scene in Listing 5 shows the z transform for the roof pieces matches the height of the walls, even though the overhangs will droop below the top of the walls.

Our roof is symmetrical, so we use the same genroof with a different xform to make the other half. That's easy.

Listing 5. The Scene File for a Complete Cabin



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Any luck with Gentoo?

Anonymous's picture

No go at getting this to compile with gentoo.

Re: Lighting Simulation with Radiance

Anonymous's picture

I'm curious if you considered using POVRAY or other rendering programs and if so what criteria led you choose to use Radiance. -- paul

Re: Lighting Simulation with Radiance

Anonymous's picture

POVRAY doesn't do a physical simulation. If you want to take "light meter" readings from the image that would be the same as what you would get in the real world, then you've got to use something that simulates the the intro to the article again :)

Re: Lighting Simulation with Radiance

Anonymous's picture

I fail to understand how it can be physically accurate with out taking into consideration the material bounce etc. From the image it seems that we are dealling with super smooth and super clean it may be accurate for the scene data...with more info in the scene the physical simulation seems flawed.

Re: Lighting Simulation with Radiance

Anonymous's picture

Five hours - whoa! 3DSMax with mental ray or some other radiosity plugin would have done it in one

Re: Lighting Simulation with Radiance

Anonymous's picture

... and would be physically inaccurate.

Re: Lighting Simulation with Radiance

Anonymous's picture

Not if real world data were used. You can achieve highly accurate results with Radiosity which ships free with 3ds max 5. And 3rd party renderers can achieve even better results. I have a hard time believing that the author actually tried ACAD, max or numerous other off the shelf packages seriously.

Re: Lighting Simulation with Radiance

Anonymous's picture

Does 3DMax or any other renderer actually work with Lux, Lumens or other real world lighting units? Can you create a model, then actually build it and compare measured light levels of both? I've never seen any of those renderes produce such predictions. The packages are in different arenas. You'd never produce a film with 5 hour (minimum) render times. On the other hand, if you are designing an art gallery, you want to know the precise light levels before you spend millions to build it. Radiance will do this. I'm new to Radiance, and not a lighting designer, but these images show the measurable results that can be predicted.

Re: Lighting Simulation with Radiance

Anonymous's picture

If you read paragraph two of the article, the author clearly states that Radiance is LIKE several off-the-shelf programs that do physically accurate simulations (but I doubt any others are free). He never claimed that Radiance was the only capable package.

In para three he says that the animation packages like 3DS are not interested in doing lab quality simulations, they are interested in making pictures, which is true.

Re: Lighting Simulation with Radiance

Anonymous's picture

"The package produces great-looking images that are output in a special format that records both the texture and physical lighting of a scene, much like the professional products LightScape and VIZ 4 by Autodesk."

An improved version of the LightScape and Viz 4 Rendering enginge ships standard with 3DS max 5. True, animation programs sell mainly to people wanting to make pretty pictures, but lighting simulations are not difficult with max 5 and they are accurate.

"None of them provided the realistic output or easy support for dealing with the log walls I desired."

Also a questionable statement considering his logs are perfect cylanders... is the author suggesting that the above packages can't handle cylanders well?

Re: Lighting Simulation with Radiance

awkay's picture

Hey, author here.

Thought I'd take a minute and respond to some of the feedback. Thanks for the interest everyone!

I started doing my log home projects back in 1997/8, which is when I tried out 3DS, ACAD, and a few other modelling systems. Actually, I already knew that I wanted to use Radiance for the rendering, because I was wanting to do lighting design, and it was the only free package that would do it (and still is). It also has so many cool features for materials and lights that deal with light in a realistic fashion that it was fun to play with.

As far as commercial stuff goes, the plugins for ACAD made it pretty easy to export geometry to Radiance, but I did find that generating all the cylinders by hand was pretty time consuming. All of the modellers supported cylinders (well, 3DS didn't at the time, it used polygons to approximate, but that is neither here nor there). My comment on ease of use in the article had to do with going from a floor plan to a finished wall with proper holes for windows and doors. It was simply not easy to manually make each blessed log by hand, size it, and position it. With MAXScript, or Maya's MEL it would have been possible to make a script that would have done what my Perl scripts ended up doing, but in the end, it was just so fast and easy to be able to plop one text line in a file, with a few short hole descriptions and have a hole mess of properly sized and positioned cylinders in my scene. Try making a 50 foot log wall with three windows and two doors in any of your GUI packages in 45 seconds. Just can't be done without writing SOME kind of extra code. So, I'm not saying they CAN'T do it. I'm saying that a little Perl code happened to be the quickest and cheapest route for me. YMMV

In terms of accuracy. Many commercial packages do an excellent job now. How much do they cost? More than Radiance. Are they open source? No. Are they easier to use? Yes, for the most part (I like being able to write utilities to dump geometry in Perl, but I'm wierd). Are they faster? Most of the time. They are commercial products with large development budgets. They are aimed at industry users. I am not an industry user with big pockets. The commercial products that I tried for modelling (3DS Max, ACAD, Maya, Rhino), except for ACAD, were all evaluation copies that I had limited time with. Some of the other commercial products to which I was referring were "3D Home Design" and such $50 competition at all.

So, if you are a commercial developer, where time is more costly that software, by all means use the excellent commercial lighting packages. If you're a hobbiest like me, save the money and have some fun with Radiance.

- Tony

Re: Lighting Simulation with Radiance

Anonymous's picture

Mhmmm nice i never have heard of pov ray before

take a look to a plugin for 3

Tosh's picture

take a look to a plugin for 3dmax called lightstudio..i cecked it has a real structure radiance i mean bin..lib etc..
I cecked Rayfront too is good and work with bin file of Radiance..but those r not free, if u wont a free gui for Radiance on win u could find Conrad..i dont know if it still online!!!!it work with bin file of Radiance desktop other plugin for autocad 2000
There r lots other prog working with radiance...Dialux .......
Im looking for smart people interested on cecking lighting simulation sistems...
I worked an linux with Radiance...damn very hard time!!!!
Worked on shell compiling manually...rview..rpict..oconv...too slow!!
Some gui are interesting u can find it on Radiance mainsite..but those dont work so well...
Any of u know Blender???...yes it work on win but on Linux too it is free on i suppose opensource too...some Good people r working on a development of Radinance on Blender... a look....!!!!
If noone of those way is for u u can compile a your on pyton!!!

is this guy serious? his

Anonymous's picture

is this guy serious? his renderings looked like plastic dipped in pure RGB paint. if this is what physically accurate lighting will do to my renderings. . . i might as well use notepad to render them. AWK! ACK!

It's a simulation, not a pretty picture maker!

Anonymous's picture

Radiance allows you to do physical simulation. You can actually ask for the light levels from at every point in the picture (i.e., like using a camera light meter in the real world). Important for lighting design.

If you want really nice materials, spend a couple of extra days making pretty materials, then play with fake lights to stage it up...then go get a job at Pixar, where they make pretty pictures for entertainment.

If you want to do quick mock-ups of something you really want to build, and want to know how the lighting is going to be for, say, reading in that room, or hanging art work, then use a simulation.


Anonymous's picture

I work in lighting design, has anyone here considered Dialux?? free download, professional lighting tool, accurate output in a multitude of formats, plugin's downloadable from most major lighting manufacturers, accurate daylight calc's

I believe the phrase is 'a no-brainer'


ming's picture

Are there any tutorials to teach you how to use the more advanced features of dialux? Ive tried googling it but there are none.

Do you have a Dialux version

Anonymous's picture

Do you have a Dialux version that runs in Linux? Where can i download it?

Dialux on a Linux box

Anonymous's picture

If you run linux, the only way I've found to get Dialux rolling is with virtualbox ose running XP within linux. It runs faster than under a standard XP instal but I cannot make directx work in my virtual machine so i'm stuck with crappy looking opengl while modeling.

P.S. If you use Dialux, you can send renders straight to pov-ray from the dialux GUI to produce fantastic presentation quality images that are acurate - though I would only ever take figures from within dialux or relux - not apretty picture, no matter what kind of black magic created it!!

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState