Conference Room: How to Create Radiance Patterns for Other Renderers
25 Jun 2014
The Conference Room is a very famous scene, originally
created for and rendered by Radiance. The room does (or at
least did) exist in reality and was painstakingly measured and
re-created in a text editor (vi). See README file and
credits in the repository, where I keep my test scenes in
various formats:
What’s missing in the current state of my
multi-exporter is the ability to re-create the 3D
textures or patterns being used in the scene. If you compare
with the Luxrender rendering below, you will notice that
the ceiling, the red chairs, the table, the podium, and other objects
in the scene use patterns to modify the color of a material based on
the position of the geometry in space.
So, let’s have a look at one of those patterns by using the
reference manual of Radiance and trying to understand
how those patterns modify existing materials.
First of all we have to patch the checked in versions of *.rad
files to end up with something Radiance can render, we provide a
Makefile for that:
After that we can open the file table.rad and see how the materials
and patterns are applied:
The call to genprism (see list of all Radiance
programs) generates the geometry for the table. The next
string (table_mat) defines the material name, and the table
string names the geometry itself. In the reference
manual we find the description of the plastic
materials being used:
Plastic is a material with uncolored highlights. It is given by its
RGB reflectance, its fraction of specularity, and its
roughness value. The basic format of the scene description starts
with a modifier (in this case xwood_pat), the type (of
e.g. a material), and an identifier. Basically the plastic
material color gets modified by another element, called
brightfunc, which is a pre-defined pattern:
All the magic happens in the funcfile called woodpat.cal:
This is like writing a shader for other renderers. There are
predefined names for the position a ray has hit on the geometry we try
to shade, like Px, Py, and Pz, and functions which are
implemented in C, like hermite, tri, sqrt, sq, and
fnoise3. A1 is a shader parameter handed in by the scene
description, in this case the value is 0.6. Ring and woodgrain
are entirely defined within the woodpat.cal file, and xgrain,
ygrain, and zgrain are variations, which can be chosen from
via the scene description format, in our case we use xgrain.
For fun I implemented an Arnold shader which creates the
same pattern, the C functions mentioned above were directly taken from
the Radiance source code and are omitted here, but some code fragmets
for Arnold are shown (to see how it translates from the
woodpat.cal file to Arnold’s C/C++ API):
Here is the table top rendered in Radiance’s interactive viewer
rvu on the left and the Arnold shader on the right:
After compiling the shader you can use kick (the Arnold
executable) to get infos about the shader parameters and types, or
which strings an ENUM parameters accepts:
But how does that pattern (or the Arnold shader) get applied in an
.ass (Arnold’s scene description) file? Here is a snippet of an
example file:
Basically, instead of specifying three RGB values for the standard
shader parameter Kd_color, we link to the new shader called
rad_woodpat which uses the original Kd_color values as one of
the input parameters and modifies the color based on the calculated
(monochromatic) pattern.
Here is another example of a Radiance pattern, based on
upholstery.cal, parts of a chair rendered in Radiance’s
interactive viewer rvu on the left and the Arnold shader on
the right: