Ocean 2014 Cornell Box tutorial
The Cornell box is a test aimed at determining the accuracy of rendering software by comparing the rendered scene with an actual photograph of the same scene, and has become a commonly used 3D test model. It was created by Cindy M. Goral, Kenneth E. Torrance, Donald P. Greenberg, and Bennett Battaile at the Cornell University Program of Computer Graphics for their paper Modeling the Interaction of Light Between Diffuse Surfaces published and presented at SIGGRAPH'84.
The cornell box data, including geometry and material properties, is available on the project web site
In this tutorial, we propose to model the Cornell Box using SketchUp, define the materials and simulate pictures with Ocean 2014.
Modeling the scene with SketchUp
Open a new scene in SketchUp. Delete the default character model if necessary.
The 3D position from the Cornell Box description will be mapped to the following SketchUp axis:
- X : Red axis (left-right)
- Y : Blue axis (down-up)
- Z : Green axis (near-far)
Create the floor rectangle, 550mm wide along red axis and 560mm along green axis. We will not reproduce the exact Cornell Box which has non perfectly orthogonal walls, but make an ideal box instead.
Use the Push/Pull tool for turning the floor into a 550mm high box.
Then select the front face and delete it to open the box.
The original cube had the main face sides oriented outwards, but are interested by the inside of the shape. So the front side of the faces must be oriented inwards. Orienting properly the geometry front faces is mostly important for volumic materials, which will not be used in this tutorial, and for light source, as an emitting surface emits light on his front side only. Select all faces and reverse faces using the right-click "Reverse Faces" action.
Now draw the base of the two blocks on the floor. You may draw them exactly from the figures by placing each corner with the "Tape Measure Tool" and join them with the "Line" tool, or draw simple rectangles at an approximate position.
Use the Push/Pull tool to raise the blocks. The short one is 165mm high and the tall one is 330mm high.
Create the light source rectangle on the ceiling, as we did for the blocks base.
Open the Bucket tool, go to "In Model" folder, and create three materials:
- red : RGB values of 180,0,0
- green : RGB values of 0,180,0
- white : RGB values of 180,180,180
- light : RGB values of 0,0,0
These values are only rough estimates of the real material color spectrum. We will enter the exact figures from the Cornell Box paper in Ocean later in this tutorial, as SketchUp cannot handle spectral data. The light source material is also a simple black material for now : the emission properties will be defined in Ocean.
You may remove the other unnecessary materials that were added by SketchUp in the blank scene, if you wish. You can also do this later in Ocean.
Select all faces and apply the "white" material to them. Then apply the "green" material on the left wall, the "red" material on the right wall, and the "light" material to the ceiling light rectangle.
As you may have noticed, the Cornell box we have modeled is flipped left-right compared to the original. This is because the basis of the Cornell Box data uses Y as up axis, while SketchUp uses Z(blue) as up axis, resulting in mirrored basis. Scale the whole model by a -1 factor along red axis, and translate it by 550mm along red axis to correct this.
Save the file in skp format.
You can see the final result in SketchUp here. The corresponding file may be downloaded here.
Working with Ocean 2014
Importing the SketchUp scene and first render
Start Ocean 2014, and load the scene. Launch the render using the "Start" toolbar button. You should see the result appearing:
Currently, the scene is lit by a uniform environment source, coming from an infinite distance. That kind of lighting is handled by "Environments" in Ocean, and is automatically added by default when loading a SketchUp file. We will now replace it by making the previously defined "light" material emissive.
Changing the light source
Stop the render using the "Stop" button. In the "Objects" tool box, right click on "Environment" object and delete it. This will remove environment light.
Then double click on the "Light" material object to edit it. The materials open as a tree of properties. Right-click on the grayed "Emitter" element, and choose "Add". This enables light emission for this material.
You can now select the "base" spectrum element of the emitter, which controls the emission spectrum. Change its type to "tabulated".
You can edit below the spectrum tabulated values. Just change the number of rows or spectrum points, then set the values : first column is wavelength in meters, second column is source irradiance in W.m-3, or watts per surface unit per wavelength unit.
It is actually more simple to copy the following data, and paste it with the paste tool button, just above the table. It corresponds to the actual Cornell Box data, with the wavelength values converted to meters
400E-9 0.0 500E-9 8.0 600E-9 15.6 700E-9 18.4
Click on the "Apply" button for saving light material changes, then go back to the "Render" tab. Start the render, you should see the following image:
The light is now working as expected, but the materials are definitely too saturated, as we used pure red and green RGB colors. We will use the spectral reflectance from the original Cornell Box data.
Stop the render and double click on the "red" material in the "Objects" toolbox. Click on the "rgb spectrum" element in the tree, and change its type to "tabulated". Copy the text data from the text file below, and paste it using the "Paste" tool button above the table. Click on "Apply", and do the same for "white" and "green" materials.
Start the render. The result is now calculated from actual measured material spectra:
As you can see, the white parts of the box are looking orange-brown. This is due to the default white balance used by Ocean for generating images. It is set to a white point of x=0.3127 and y=0.3290, which corresponds to the D65 illuminant. On a digital camera, this is equivalent to setting the white balance to "Daylight" or "6500K".
The light source spectrum of the Cornell Box looks like a tungsten source. In the real world, it would be necessary to change the white balance of the camera to a warmer setting, in order to match the eye adaptation to the illuminant. Or better, some cameras have a "Measure" mode for the white balance, in order to precisely match the illuminant.
We can do both in Ocean. You may find values in wikipedia's standard illuminants page. For instance, tungsten has a white point of x=0.44757, y=0.40745. During the render, go to the "Postpro" tool box. Look for the "xyztorgb" filter, and set these values in the xwhite and ywhite fields. You can see the result below:
The white balance is much better, but we could also measure the white point directly on the image. Open the "Colorimetry" tool box (if it is hidden, you may find it in the "Tools" menu. Then click on the white point pipet, and draw a rectangle on the image inside the light source, as below. The values "xn" and "yn" in the Colorimetry tool box are then updated to the average value in the rectangle.
Type these two values in the "xyztorgb" filter settings of the "Postpro" tool box. You now have a perfect white balance for your image:
You can save the scene for the next tutorial.
In the next tutorial, you will see how to:
- Improve your workflow by editing geometry while keeping your material and light settings in Ocean
- Define a metallic material and use Ocean libraries
- Choose the best rendering algorithm
This is it! You may try the many materials and light options, and read the Ocean Manual Contents.
There are other material examples in the "examples" folder of the Ocean installation directory. Don't hesitate to contact us for more help in testing the software.