Nil Signifcat, nil oscilat. (It don't mean a thing...)


Tutorials

- Radiance -

About Radiance

RADIANCE is a very accurate physically-based raytracer. This is a long way to say that it uses a series of algorithms from physics to produce scientifically accurate pictures. You can check out some of the best pictures produced by this package at the Radiance gallery. It is often used in architectural and scientific conception, but also produces very precise and sometimes artistic pictures. Some of the best ''artsy'' work using Radiance is in Paul Debevec's Fiat Lux. Lucky for the dirt-poor CG artist, Radiance has been free for about the past ten years and is now open-source.

UNIX users (including OSX) can download Radiance binaries and source from http://radsite.lbl.gov/radiance/framed.html. Windows users can download Radiance from http://radsite.lbl.gov/deskrad/download.htm. UNIX users can download and install as usual. Windows users, unless your computer has AutoCAD software, need to run the installer. If you registered properly, you should receive the password. With that password, install only the executable files to your hard drive (and also the documentation and example files, if you like). Make sure that any necessary environment variables are set (e.g., RAYPATH=/usr/local/lib/ray). You also need to download the 2.33a export script(ZIP or BZIP2). Make sure that your Python path is set correctly and you are using Python version 2.3.x.

RVIEW
Rview, interactive rendering

Rview is Radiance's interactive rendering tool. Inside the GUI, it does a ''quick and dirty' rendering of the octree, so that adjusments can be made in real time to things like camera angle and other global settings.

WINIMAGE
Winimage for Radiance images

Ximage or Winimage is Radiance's program for viewing Radiance-format pictures. In winimage, we can do some automated functions on our picture. Most likely, the picture will look extremely bright and washed out. The great part about the Radiance file format, though, is that we can adjust the exposure without having to re-render the picture. We simply go to the Image menu, go to Exposure submenu, and click Image (or, in X11, hit the "A" key"). This automatically adjusts the exposure to a ''comfortable'' level. However, if you aren't satisifed with this change, we need to adjust it manually at the command promt.

When ximage/winimage adjusts the exposure, it calls another program called pfilt. This program is a post-processor which automatically resizes the picture, applies anti-aliasing by resampling the picture, adjusting exposure, and the like. I usually use the following options:

pfilt -r 1 -x 800 -y 600 -e 0.5 test1.pic > test1_1.pic

The -r option is the method which pfilt uses to resize the image (in this case, Gaussian filtering). If we set this number higher than 1, however, the image comes out of focus. It functions best when we change the -x and -y options to half or one-third of the original. The -e option halves the exposure amount. This results in a much more polished looking picture at a size that is easier to handle. Using ximage/winimage, you can explore the other options including applying human comfort calculations (i.e., glare) and making falsecolor pictures (Quick note if you want to make false color images: Render the picture in rpict with the -i option). Here's a few examples of some finished images (some of which have been postprocessed using winimage). Another fine program for tweaking your Radiance pictures (I think it's slightly better than ximage/winimage) is HDRShop. However, observe the license agreement carefully. And it's for Windows only.

RAD IMAGE
A simple image made using Blender and Radiance.
IRRAD IMAGE
A false-color image using an irradiance calculation.
FALSE COLOR IMAGE
This picture used a skylight (seen through the window), a human comfort calculation (glare), and ambient calculation.

Using the Radiance Export Script (2.33a)

Download ZIP Download TAR.BZ2

Setup

To use HDR light probes, you need to copy the angmap.cal file to your Radiance lib directory (for example, D:\Radiance\lib\angmap.cal). Now, it's time to start the script - press Alt-P. The first thing I usually do is set the export path and file name. Don't add a slash to the path and enter the filename without an extension (make sure you use the right slashes - back for Windows, forward for everyone else). This root filename will be used for naming rendered pictures, the view file, and the rad file. Next, set the X and Y resolution. Note that the picture will be rendered at twice this size, then resized because Radiance uses an external program (pfilt) to resize, antialias, and exposure-adjust pictures. If at any time you want to save the gui settings, press the ESC key. Whenever the script is exited in this manner, the GUI settings are saved to be loaded later (NB - The next version of Blender will save all these settings on exit, but this feature does not exist yet). Now, let's take a look at the material guide.

MATERIAL GUIDE
Material guide. Click to see full size.

Materials

To assign materials, certain four-letter suffixes need to be added to each material. With no extension, a plastic material is used. The color, specularity, and roughness (hardness) is determined by the equivalent Blender settings. Next, the glass pane material (append ''_PANE'' to material) is a glass material with a preset IOR of 1.52. This is a great material for windows. Color, spec, and roughness are set in Blender. The dielectric material (add ''_DIEL'') is Radiance's name for a glass material. Color, spec, and roughness are set in Blender, and a slider is provided in the shader editor to set IOR. The metal material (add ''_METL'') is a typical metal material where color, spec, and roughness are also set in Blender. The translucent material (add ''_TRAN'') is experimental because I haven't had time to test it yet. Adjust Blender's color, spec, hardness, and sptr to see its affect on the material. To use the shader window (which right now only actually changes the IOR of the dielectric material), click the shader window button, select an object, and press Get Selected.

Global Settings (Sky/HDRIBL)

Now, back in the export window, let's take a look at the global settings. For now, only the sky light and ambient light is used. The sky light generates a sky in your scene, and the color can be set straight in the GUI. Also, since Radiance calculates sky lighting using CIE standards, you can select between a sunny day (with or without sun), an intermediate dat (with or without sun), cloudy, uniform (global illumination), or HDR light probe for IBL. However, because Radiance considers the sky to be a secondary light source, it doesn't do much without the next setting - ambient.

Ambient Light

Radiance's ambient feature works much differently than popular radiosity methods. Mostly, if you want accurate and pleasing results, you will be rendering for several hours. It is often a good idea to combine secondary light sources (sky lights) with primary light sources (area lights and fixtures) with ambient calculations. To actually start ambient calculations, set ambient bounces to 2 or 3. If the picture looks splotchy or inaccurate, double the ambient divisions and set the supersamples to half of the divisions. Raising the resolution will also increase accuracy. The ambient accuracy setting is like a threshold setting - smaller takes longer, but 0 turns off ambient caching. Turn ambient value up if the scene is too dark.

About using light probes: Light probes need to be in angular map form, and the file angmap.cal needs to be in your Radiance lib directory. (This file is included with the zip/bzip2 file).

Lights

Only a little explanation is needed for lights (at least for now). The lamp color in Blender controls the lamp's exported color, and unless the lamp is an Area light, the lamp will be exported as a spherical fixture. Area lights are exported as planar fixtures.

Export

Once you are satisfied with all of your settings, go back to the export window and press the Export button. The console should list each object exported (note that meshes with a name starting with ''Sphere'' is not exported as a mesh, but a procedural sphere - if you don't want this to happen, change the object name). Once it says ''Finished!'', click ''Export RIF File.'' This creates a RIF script file that is read by Radiance's RAD program. RAD automatically runs all the commands necessary to process the image. This can be run as follows on the command line...

rad -o x11 test1.rif
(to render a preview in rview, only for UNIX systems with X)

or

rad test1.rif
(to render a full picture in rpict)

...or you can use the Preview and Render buttons in the GUI. Note that for the RIF files or the GUI render buttons to work, the Radiance binary and lib directories need to be set in the PATH and RAYPATH environment variables. This is part of a normal Radiance installation, so this should be done already.

- MetaFont -

Introduction

METAFONT is a font and logo production program complimentary to the TeX typesetting system. It neither reads raster fonts (such as .fnt or .bdm) or outline fonts (such as .ttf or .pfa/b), but reads a description file. This file can describe outlines, but can also describe fonts in terms of ``pens'' and ``strokes'' or draw outlines according to mathematical formulas. It is only when a document is actually typeset that a bitmap font is produced for printing.

By default, when METAFONT is run, a generic font (gf) file is produced. The extension is also numbered according to the resolution of the font (e.g., 600 dpi = *.600gf). However, TeX usually compresses these bitmap fonts into packed fonts (pk). These are prefixed the same way according to resolution (600 dpi = *.600pk).

The purpose of this tutorial is to present a method of designing a complete, useful METAFONT that can be used for actual typesetting. It will guide the reader through the whole process of character creation to encoding.

Using METAFONT

Invoking METAFONT

METAFONT is a command-line utility included with any TeX distribution. On Windows, the MikTeX distribution includes a command-line only utility, whereas teTeX on UNIX operating systems or the Cygwin emulator also include the MFW X11 version. For the sake of this tutorial, we will only be concerned with plain, command-line MF.

Let's begin by typing mf at the command prompt. You should receive a prompt like this:

This is METAFONT, Version 2.7182 (Web2C 7.4.5)
At this point, the program will either take an input file or the \relax command. All that relax does is tell METAFONT that you don't have an input file and will enter all commands at the command line. So, let's enter it.
This is METAFONT, Version 2.7182 (Web2C 7.4.5) 
**\relax
*
Now this single asterisk indicates that the program is ready to receive commands. For now, the command we will be most interested in is the draw command.

Drawing in METAFONT

METAFONT uses the familiar Cartesian coordinate system. The coordinate plane consists of two dimensions (x and y) that determine horizontal and vertical placement of points (respectively).

The draw command takes any number of points and connects them with either straight lines or interpolated curves. Draw is always followed by an ordered list of points. For example:

CURVED PATH

Your first path


STRAIGHT PATH

A straight path


CYCLED PATH

A cycled curved path

draw (0,0)..(0,100)..(50,50)..(200,5);
(Note how this line ends in a semicolon. In METAFONT, like in C++, each line must be delineated.)

This will produce a curved path that passes through all four of these points. If we replace the dots with dashes, however:

draw (0,0)--(0,100)--(50,50)--(200,5);
These four points will form a straight path. Another useful command when drawing cyclical objects is the cycle command. This is used as a pseudo-point, so other points can be connected to it.
draw (0,0)..(0,100)..(50,50)..(200,5)..cycle;

This forms a closed path. Enter this command at the asterisk prompt and press enter.

So great, now we've drawn something. We can't see it! Ah, now we must tell METAFONT to ship this figure out to a file. This command is shipit. Shipit sends the output from METAFONT to a generic font file. By default, METAFONT assumes that is running in proof mode, which basically means it outputs files that make it easy to check your font. Now, type in this command:

shipit;
And follow it with end (which should need no explanation):
end;
Now at this point METAFONT prints a few lines and then ends:
[0]
Output written on mfput.2602gf (1 character, 896 bytes).
Transcript written on mfput.log.

This indicates to us that character number 0 was produced and exported to mfput.2602gf. The log file merely prints what you typed at the command prompt. So now we have a file, but we still can't see anything. What is our next course of action?

Remember that METAFONT is by default in proofing mode. It has already produced a proof-ready generic font. Now, we convert this into a "dvi" or device-independent file. This is the same type of file produced by TeX, except it only contains the proofs of the characters of a font. We do this conversion using gftodvi. So type at your normal command prompt (i.e. NOT in mf):

gftodvi mfput.2602gf

The command will appear to do nothing and then end. Notice, though, that your folder now contains mfput.dvi. This file can now be opened using xdvi (in UNIX) or Yap (in Windows). Before opening, though, follow the instructions for making the gray fonts on Christophe Grandsire's METAFONT tutorial.

After you have compiled the gray font, open the dvi file. You should see a gray-ish colored blob shape. This is the product of the points you entered above! The gray font merely uses a pattern of dots to form your character.

Assigning Points

So far we have only entered points directly into the draw command. However, METAFONT has a shorthand method that allows you to make points much more flexible. Individual points are numbered can be prefixed by a "z". So, points can be z1, z2, z8, z90, z0 etc. However, you can also specify the x or y part of the point by prefixing the point with x or y (like x1, x2, x3, y4, y9, y0). Points are assigned simply with an equal sign:
z1=(0,100);
z2=(50,50);
x3=40;
y3=50;
It is also possible to add a vector to a point (a vector is just a distance according to Cartesian coordinates - the vector (50,50) means go up on the x and y axes 50 units or (-50,-50) means go down on both axes 50 units).
z4=z1+(20,0); % That is, (0,100) + (20,0) = (20,100)
So now we can feed these points into the draw command without having to retype each point:
draw z1..z2..z3..z4--cycle;
Note that we can also alternate the use of .. and -- during the draw command.

Variables

Two Classes of Variables

Even though, like all programming languages, there are many variable and number types, METAFONT makes an important distinction between two classes: sharped and unsharped.

Unsharped variables and numbers are absolute. All of our points so far simply are numbers that can be interpreted anyway your specific computer wishes. However, sharped variables are given in terms of an industry-wide standard. All of our sharped variables are given in terms of some presets: inches, points, picas, ciceros, and the like. Since all printing and display devices are different, these presets are standardized on all of METAFONT's driver files. Thus, one inch on a Hewlett Packard LaserJet will be the same size as an industrial plotter. Our sharped variables will look something like this:

em#:=0.75pt#;

Whoa, mally, I can't even read that! Well, okay, it's simpler than it looks. The reason that these variables are called "sharped" is that they are followed by sharp or hatch signs. So the variable we are creating is called em\#. Its value is equal to 0.75 times the device independent measure of one point (pt\#). Now in the middle we have a colon in front of the equal sign. This functions mostly the same as a lone equal sign. However, if you are redefining a variable, a lone equal sign will produce an error such as "Inconsistent equation (off by 2.66667).". Adding the colon says that this is the true value, and any previous value is completely replaced. It is standard practice when first assigning a variable to use the colon.

Now when we are creating a font, there are few times when we actually mention the sharped variable. We usually have to convert it into device-specific variables, or unsharp it. This command is define\_pixels.

define_pixels(em);

This creates a new variable called em (without sharp) that creates a device-specific measurement of 0.75 pt.

Creating Characters

In METAFONT, we have only created random characters. In an actual font, though, we have to give a brief description of a character before we actually draw it. (Note that this is generally not typed into METAFONT, but entered into a file with extension *.mf. This can be run through METAFONT by typing mf myfont.mf) This header is defined by the beginchar command. It is used as such:

beginchar("a",4enx#/5,eny#,0); "The letter a";
...from the Jekyll font

This command assumes that two sharped variables, enx\# and eny\# already exist. The first argument of this command is the name of the character we are going to describe. The second and third arguments tell METAFONT the size of the bounding box of the character. This is used to place the character at a proper spacing from others when the font is actually typeset. The final argument tells METAFONT how far down any descenders of the character go (perhaps for lack of a better term, this is usually abbreviated as "depth"). After the beginchar command, it is customary to give a string that describes the character. This string is displayed when the font is processed (which helps narrow down errors during processing) and is also printed on proof sheets.

After the beginchar line, we can begin to describe our font. It is best to use converted sharp variables when giving the coordinates of a character. Since when sharp variables are unsharped they receive their device-dependent values, the characters can be given in those terms without needing to be sharped.

Once you have described your font using points and draw commands, the character is terminated with endchar. Thus a complete character could look like this:

JEKYLL LETTER 'A'

...from the Jekyll font

beginchar("a",4enx#/5,eny#,0); "The letter a";
  z1=(0+offsetx,en); z2=(hen+offsetx,en); z3=(3en/4+offsetx,hen);
  z4=(en+offsetx,0); z5=(3en/4+offsetx,2en/5); z6=(0+offsetx,hen);
  z7=(0+offsetx,en/3); z8=(4en/5+offsetx,en/3);
  draw z1..z2..z3..z4; draw z5..z6..z7..z8;
  endchar;

Pens and Transformations

In this tutorial, we have been telling METAFONT where to plot points, and those points have been connected with what appears to be a really thick, childlike marker. But with the power of METAFONT, we can change this to create nearly infinite different appearances.

Just as a calligrapher would change his pen nibs to create a different appearance, we can change the type of virtual "pen" that METAFONT uses.

PENCIRCLE

pencircle

PENSQUARE

pensquare

PENRAZOR

penrazor (dragged out)

penspeck is too thin to show here

pencircle - Uses a circular nib (although for reasons you would have to look in the METAFONT book for, it's really a polygon)
pensquare - Uses a square pen
penrazor - Uses a thin line
penspeck - Uses a dot (think pencil)

Each one of these "pens" can be changed using transformation commands. Internally, METAFONT deals with a complex transformation matrix, but it still provides us with easy to remember commands.

scaled - Scales the pen in all dimensions
xscaled - Scales the x dimension of a pen
yscaled - Scales the y dimension of a pen
Neither xscaled nor yscaled work for penrazor since it only has one dimension.
rotated - Rotates the pen around its center

To actually use one of these pens, we use a rather whimsical command: pickup. Just follow this with the pen type:

pickup pencircle;
And if we want to transform the pen, that goes at the end:
pickup pencircle xscaled 20 yscaled 3 rotated 30;
This takes a circle, stretches it in the x dimension, squashes it in the y dimension, and rotates it 30 degrees. Note that all the transformation arguments can be replaced with unsharped variables.
pickup pencircle xscaled px yscaled py rotated pa;

Now, if we place this command at the beginning of a file, all strokes will be made with this pen. With the above pen, a calligraphic effect will be achieved.


There are a few more transformations that, while useless with pens, can be used for paths or the entire font as a whole.

shifted - Adds a vector to path slanted - Skews the font according to a number rotatedaround - Rotates path around a point - Invoked ((x,y),angle) reflectedabout - Reflects path across a line of symmetry ((x1,y1),(x2,y2))

Some of these commands can be placed directly in front of a path:

draw z1..z2..z3..z4..cycle shifted (0,-20);
However, many have to be applied to the whole font. This is achieved by assigning the currenttransform to a transformed constant called identity.
currenttransform:=identity slanted 1/4