A Designer's Tutorial in using Image Based Illumination and High Dynamic Range Imagery
Brock J. Stearn
Department of Industrial, Interior and Visual Communication Design
The Ohio State University
Introduction
This tutorial follows a pipeline using Image Based Illumination and High Dynamic Range Imagery to more effectively composite a CG mock-up into a live action photograph. For example the mock-up camera seen here is composited into a lobby. On the left is the typical way a designer will composite a mock-up into a photograph by lighting the model with basic lighting and then using Photoshop to place it into the scene. On the right is the same camera composited into the same photograph using this pipeline.
|
Figure 1
|
This pipeline is specific to Alias Maya 5.0 or higher, but could be adapted with some effort into other software packages. Also, there will be references to my MFA thesis paper on this pipeline and related work throughout this tutorial. The entire paper is available here in PDF format. The page references listed in this tutorial are to that document.
Software/Downloads
For this tutorial there are certain available pieces of software, plug-ins, and scripts that I will be referencing. Below are links to download them and directions as to where to install them.
"On Set" Capturing
The first step in this process is to find a location to take photographs. This location should ideally be where you could see your CG mock-up existing realistically. Once this location has been found you will need to take some photographic reference of this area. The best way to do this is with a digital camera and a reflective sphere, such as a gazing ball.
Camera Setup
Place the reflective sphere where the computer generated mock-up will later be composited in. Find the desired angle of the camera and mark this spot (pp 36). Now rotate from that spot in 45-50° each direction and these two spots will be where you will take the photographs of the reflective sphere (pp 37-39). The reason we are shooting two different angles is so that they can be composited together to make one whole image without any loss of environmental information, or any objects in the images, such as the camera and camera person (pp 42).
Framing the Sphere
It is important to get as much information from the reflective sphere as possible without allowing the camera, and you, to take up a large part of the sphere. The best way to do this is to fully zoom in on the reflective sphere and then manually walk the camera towards the sphere so that the sphere takes up 30-50% of the image (pp 37-38).
|
Figure 2
|
|
Photograph showing Sphere taking up between 30-50% of the image
|
|
The environment in which the reflective sphere is placed
|
Range of Images
In order to use High Dynamic Range Imagery (HDRI) we want to take a full exposure range of images of the sphere. So adjust the camera's shutter speed setting and take one photo at each setting from the fastest shutter speed, such as 1/2000, to the slowest, such as 4. All of these exposure images will be later compiled into one image that more accurately captures all of the lighting information of the environment (pp 20). Below is a cropped example of photographs of the reflective sphere taken through a range of exposures.
|
Figure 4
|
||||||||||||||||||||||||||||
|
Matching the Angles
As both angles' range of images are going to be compiled together it is very important that each angle's images were taken from the same distance from the sphere with the same settings. A very simple way to do this it to tie a string to the base of the sphere. Pull this string back to where your first angle is and when it reaches the base of the tripod either mark or cut the string there. When you are ready to shoot your second angle use the string to pivot around the base and set the tripod at the same point on the string at the other angle. Make sure you take a few photos at the center line which you can use later for compositing (pp 36).
|
Figure 5
|
|
Illustration of Shooting two angles while pivoting from a center line with a string tied to the base of the Gazing Ball
|
Assembling the images
Now that all the photographs are taken we need to assemble them so that we can use them in our 3D and Rendering software. To do this we need two pieces of software; Adobe Photoshop (or something similar such as Gimp) and HDRShop available free for noncommercial use.
Cropping and Masking the images
We only need the sphere for our information so we need to crop the rest out and mask everything but the sphere. To do this drag a circle marquee around the sphere in the photograph and select the inverse and fill that in with total black. All of the photographs should have the sphere in an identical position in the image. Given this, it is possible to simply copy the black filled area to each image file. Once the sphere is cropped out in every image, save the images in a name you will recognize, i.e. angle1_1_2000.jpg, in JPEG format.
|
Figure 6
|
|
Image after sphere isolated from background. Blue lines indicate area to be cropped
|
|
See a Video of this Step
|
||||||
|
Converting from Angular to Latitude-Longitude
A perfect sphere's image can be transformed into several other formats since we know the equations of a perfect sphere. The most convenient way to do this is in HDRShop. We are going to convert angle one's images to Latitude-Longitude, or planar, format directly. The other set we are going to do the same process for angle 2 but offset by 90° so that we can composite the two together (pp 41).
For Angle 2:
|
Figure 7
|
|
Figure 8
Your settings should look like those below: |
![]() |
|
Panoramic Transformation Settings for Angle 2
|
|
Figure 9
|
|
Arbitrary Rotation Settings for Angle 2
|
For Angle 1:
|
See a Video of this Step
|
||||||
|
Compositing the two sets of images together.
This next step is perhaps the longest process but it is necessary to create a very nice lightprobe. I used Adobe Photoshop for this process but any similar program that supports multiple layers and layer locking should work.
Bring each exposure of angle 1 into Photoshop and copy each image into a new Photoshop file, labeling the layers accordingly. Repeat the same process for Angle 2 but places those images in a seperate Photoshop file. Bring in your complete image range for Angle 1 into a Photoshop file with a layer for each step in the range. Repeat the same for Angle 2.
Now look at the areas of Angle 1 that need to be removed. This is usually the camera, cameraman, whatever is holding up the reflective sphere, and any black areas (which is where you didn't capture any information in the photographs) You need to find those areas in Angle 2 and copy them to Angle 1 and transform them into the right location and rotation (Figure 10). The reason for doing this in Photoshop with multiple layers is that you can lock your layers together after you paste in each part. This allows everything you do to one layer to affect all the other linked layers. Below are the angles shot from the steps above and the final image composited together. Since this image will be just used for illumination purposes the images do not have to look precisely accurate as long as the local area of colors is still intact. For these images below you will notice the indoor window's edge in the middle of the image doesn't match properly but it will be enough for a IBI file. Once all the angles have been combined to create a better image, save out each exposure into its own JPEG file and once again name it accordingly (pp 40).
|
Angle 1 (top) and Angle 2 (bottom) after being converted to Lat/Long. Boxes indicate areas used from Angle 2 to fix and complete Angle 1.
|
|
Figure 11
|
|
Lat/Long image after compositing. There are still some minor differences in the corrected areas but since this will get blurred at rendering it isn't critical.
|
|
See a Video of this Step
|
||||||
|
Creating a High Dynamic Range Image (HDRI)
The best application I have found for creating HDRI is HDRShop, but there are other utilities available such as MkHDR a command line utility, and HDRIE and Photogenics HDR which are both commercial applications with some minor image editing capabilities. For our purposes we will be continuing to use HDRShop (pp 41-42).
Creating an HDRI
|
Figure 12
|
||||||
|
How Image Based Illumination works
Principles
The basic principle behind Image Based Illumination is that a computer generated model is surrounded by another piece of geometry (i.e. sphere, cube), with an image mapped onto that geometry. To calculate the lighting of a particular point of the computer genereated model, IBI takes extends the rays, usually based on the vector of the normal (N), until it intersects with the surrounding surface. It then samples the color at that particular point on that surrounding surface's mapped image and uses that for the lighting color of the point where the vector started. Below is an example of this occuring with several rays.
|
Figure 13
|
|
Illustration of the principle behind Image Based Illumination
|
In Maya and Mental Ray
For Mental Ray, which comes bundled in with Maya 5.0, IBI is implemented through creating some surrounding geometry and using the Mental Ray Final Gathering technique. This is the most straight forward method and what will be used in this tutorial. There are some scripts I have written or modified for this tutorial which have been written for Maya 5.0 but should be useable in any later versions as long as Mental Ray is installed and the plug-in is loaded as shown below. The plug-in can be loaded by going through Windows -Settings - Plug-in Manager and checking load box for the Mayatomr.mll plugin.
|
Figure 14
|
|
Mental Ray Plug-in
|
Setting Up for IBI
More work in HDRShop
There are two more steps in HDRShop that we must complete before moving onto Maya. The first is to open your compiled HDR image and set the exposure to 0 by pressing 0. If the image appears dark this is probably due to a Gamma difference from the camera to the application. We will solve this through a script in Maya but it is important to note whether the image is bright or dark at 0 exposure. The second step is to use the Lightgen plug-in for HDRShop on our HDR image. Make sure the plug-in is in the HDRShop plug-in directory (pp 44-45).
Lightgen
|
Figure 15
|
|
Figure 16
|
|
Figure 17
|
|
Figure 18
|
|
Figure 19
|
|
Figure 20
|
|
Figure 21
|
Making a MAP image
Mental Ray's native image file format is MAP. We are going to convert our HDR image to MAP to speed up render times in Mental Ray and to eliminate the Range Clamping that Maya does with HDR images.
hdr2map
Working in Maya
Basic Workflow
There are four basic steps in this pipeline for using Image Based Illumination and High Dynamic Range Imagery. The first is using the HDR image to provide the basic low level lighting, such as ambience and incandescence. If the object is reflective it can also be mapped into the specular channels. The second step is to use the HDR image to derive actual lights in Maya and to set them up so that they are convincing. The third step is specific to any special effects or elements the model may have. This may include Caustics, Fog, Sub-Surface Scattering and so on. The final step is to "dirty up" the image so it doesn't look so real and can blend back in with the live action image. The two scripts available in this tutorial greatly speed up this process. It should be noted that throughout this process it will be neccessary to move back and forth between the different stages to produce a great result.
Installing Scripts
Both scripts should be downloaded to your Maya's script directory. I recommend making shelf buttons for both scripts so that they can be easily accessed. In Maya open the Script editor and inside the script editor Open the brock_lightgen.mel script. The contents of the script will be displayed in the Script Editor window. Highlight the all of the text and drag, using the middle mouse button, to the Shelf and release. A new icon will be created that will launch Brock's Lightgen Control script. For Brock's HDRSetup Control script type brock_hdrsetup.mel into the command line and drag that text to the Shelf to create a new icon.
|
Figure 22
|
|
Placing brock_lightgenconrol.mel into the Shelf
|
|
Figure 23
|
|
Command Line entering of brock_hdrsetup.mel
|
Step 1: Using just HDR through IBI for general lighting
|
Figure 24
|
|
Figure 25
|
|
Figure 26
|
|
See a Video of this Step
|
||||||
|
|
Figure 27
|
|
Figure 28
|
||
|
||
|
First step in Maya (left) and the resulting rendered image (right)
|
Step 2: Using the HDR image to generate lights to create lights
At this stage we will be deriving actual Maya lights from the HDRI image through the use of the exported Lightgen file that was created earlier (pp 56).
|
Figure 29
|
|
Figure 30
|
|
Figure 31
|
|
Figure 32
|
|
Figure 33
|
|
Figure 34
|
||
|
||
|
Second step in Maya (left) and the resulting rendered image (right)
|
Step 3: Creating scene specific elements
For some CG mock-ups there may be "special" lighting situations that need to be created. Examples include caustics and fog. If this step is not required for your CG mock-up, you may skip this step (pp 57).
|
Figure 35
|
|
Figure 36
|
||
|
||
|
Third step in Maya (left) and the resulting rendered image (right)
|
|
See a Video of this Step
|
||||||
|
Advanced Use: Matching a specific angle and creating shadows
In order to make the final result look as convincing as possible there are two additional advanced used stages that can help blend a CG mock-up into the live action photograph.
|
Figure 37
|
|
Figure 38
|
By using these advanced steps you are able to create an even more realistic looking composite. Keep in mind at this point the lights have not been manipulated in position or placement at all from the default.
|
Figure 39
|
Step 4: Dirtying up the image
|
Figure 40
|
As with any lighting setup there needs to be constant tweaking in order to produce the best results. It should be clear that using just IBI alone is not a very effective solution, but by stepping though this pipeline it is possible to generate an accurate rendered image from using the HDRI file as the base for all of the different lighting stages.
|
Figure 41
Below are some examples of the camera being lit through different lightprobes (left) that are HDR images in angular format. The lighting is just using the first stage of this pipeline to visualize the different lighting aspects possible |
||||||||
|
My Related Links:
MFA Thesis Writing - the down and dirty parts of this pipeline
Thesis Production - a HTML page that describes parts of my thesis work over the past year in more detail (incomplete)
Other Links:
Brent Watkins - the person responsible for helping me with my scripting difficulties
Paul Debevec's Homepage - The creator and probably the largest promoter of HDRI
HDRShop - Debevec's free HDR creation program
Debevec GDC 2002 - powerpoint presentation of Debevec's 2002 Game Developers Conference course
Debevec GDC 2003 - powerpoint presentation of Debevec's 2003 Game Developers Conference course
Debevec SIGGRAPH 2001 - Debevec's Image Based Lighting 2001 SIGGRAPH course
Debevec SIGGRAPH 1997 - Debevec's Recovering Range Radiance Maps from Photographs 1997 SIGGRAPH course
Debevec SIGGRAPH 1998 - Debevec's Reendering Synthetic Objects into Real Scenes 1998 SIGGRAPH course
Jonathan Cohen - Developer of Lightgen
Simon Bunker - a rendering guru with some excellent work and descriptions of HDRI
CGTechniques.com - A site with several tutorials regarding HDRI
OpenEXR - An open source format from ILM that supports HDR information
HDRIE - A free HDR image reader and editor from the University of Illinois
ATI - Rendering with Natural Light in Real Time - a real time example of Debevec's Rendering with Natural Light
rthdribl DX9 - Real Time High Dynamic Range Image-Based Lighting in Direct X 9