Sunday, 23 January 2011

TUTORIAL HDRI & CAUSTICS BY. RICK TIMMONS


This tutorial was designed with the 3D novice in mind, and for that matter, anyone above that level. We'll be creating and adjusting everything from scratch, this tutorial will hardly yield any graphics you're going to win any awards or other accolades for but it will will show you a cool technique. I will be using Max 6, the first release of the software to feature the Splutterfish HDRI I/O plugin. For those using version 4 or 5 of Max you'll need to download the free plugin (HDRI version 1.0.1) from the Splutterfish website: http://www.splutterfish.com/


You will also need a .hdr file, which is available to download from Paul Debevec's website: www.debevec.org/Probes/
The probe I'll be using for this tutorial will be the grace_probe.hdr


For those interested in furthering their knowledge of the subject of HDRI, you may want to spend some extra time at Paul's website, he's a pure genius in this area. Also Splutterfish has invaluable information on this subject and is well worth delving deeper into. But for now, let's get busy... there's a lot of work ahead of us.
Step 1 : Setting Up - With everything you need downloaded and setup, create a new directory in the Max Scenes directory and label it HDRI. Into this directory, you'll want to copy your downloaded .hdr file. The materials used for our objects will be created by us as we move through each step.
Step 2 : Creation of the Geometry - Let's first reset Max: File-Reset-click OK. Next, let's setup our units to Generic if not already set: Customize-Units Setup-Click the Generic Units option button-Click OK. See image to the right.
The first object will be our ground plane. From the top viewport, Geometry-Plane and scroll out a plane near the center, set its size to 200 units square and stay with the default values for the other parameters. The second, third and fourth objects will be simple spheres, each with a diameter of 4. Click Create-Geometry-Sphere and scroll three of them onto Plane01.


Set Sphere01 to the NW of the grid center, Sphere02 to the NE and Sphere03 to the SE. Set the diameter of each to 4 and leave all the other parametric values to their defaults. Our fifth and final object will be a GeoSphere, Geometry-GeoSphere with a diameter of 4 placed to the SW of the grid center. Uncheck Smooth in the Parameters list. We uncheck Smooth for the GeoSphere because we want sharp edges on it. From the top viewport, your scene should look similar to the image to the right.

Don't worry if it looks sloppy at this point, we'll be repositioning the objects in a few moments to their proper places, the important thing is that the objects be set to the parametric values described above.


Step 3: Camera and Light - Our scene will have a single target camera and a single MentalRay area spot.We want to place our light and camera to give a good view of the four shadow fields and those areas immediately around the objects where reflected/refracted photons will illuminate. Let's set our camera first. Still in the top viewport, click Create-Cameras-Target, then click south of the four objects and drag the target to just north of them. Under the Parameters rollout of the Modify panel, set the camera lens to 40mm. Then our light, click Create-Lights-MR Area Spot, then click to the east of the four objects and drag the target to the west of them. Under the Spotlight parameters rollout of the Modify panel, adjust the hotspot/Beam to 42 and the Falloff/Field to 55. See image to the right:

Step 4: Positioning of our Objects, Camera and Light - Max provides a means of precisely positioning objects called the Coordinate Display, see below.


It's on this display we'll set he positions of everything we've created. Now, position each of the objects, camera and light using the chart below. Don't forget, you have to use the Move tool to both select and reposition objects:

Plane01
Sphere01
Sphere02
Sphere03
GeoSphere01
Camera01
Camera01 Target
mr Area Spot01
mr Area Spot01 Target 0, 0, 0
-12, 12, 4
12, 12, 4
12, -12, 4
-12, -12, 4
-38, -48, 48
9, 22, -21
50, -36, 40
-6, 11, -15

Step 5: First Render - Hit your C key to go to the Camera View. Then F9 to do a quick render. If you've followed every step carefully, you should now be looking at a rendered scene similar to what's below:


If not, back check your positions and/or object parameters. Now would be a good time to save your file as HDRI.max. File>Save, OR Ctrl+S and name the file HDRI.

Step 6: Material for Plane01 - The material for the ground plane is a compromise of what would best illustrate both caustics and HDRI highlights. For this, we'll create and apply to the ground plane a fairly neutral color and value --- white. The reason? We will best see caustics bouncing off of a white surface. The HDRI reflections/highlights are not affected by the white plane, only by the surface material of the reflective objects. Select Plane01, then hit M to call up your Material Editor. In the Blinn Basic Parameters rollout, double click the Diffuse color block to call up the Color Selector: Diffuse Color panel. Slide the Whiteness slider all the way down to pure white (RGB= 255, 255, 255) and close. See image below:


Name this material Plane01. Assign the material to Plane01, leave all the other settings to their defaults and close the material editor. A render now will show you that our plane isn't quite so white. See image below:

Save your file.


Step 7: Materials for Sphere01 and Sphere03 - We will be doing both of these spheres in the same step as both materials will be taken from the Material Library. Select Sphere01 which will have a raytrace glass material applied to it. Hit M to call up the Material Editor, then select the second material slot. Click the Get Material button which will bring up the Material/Map Browser. Click the Mtl Library radio button under Browse From, and under the File area click the Open button. From the Open Material Library List double click RayTrace_01.mat to call up the Material/Map Browser for this file. Double click GlassClear (Raytrace) to place it in the chosen material slot. See images below:




We will be staying with the default values of this material, so go ahead and assign it to Sphere01, and don't forget to name the material Sphere01. At this time our screen has two large windows blocking our view of our geometry. Hit the H key to call up the Select Objects list, then double click Sphere03. Select the third material slot. The material for Sphere03 will be ChromeWhite (Raytrace), and since our Material/Map browser containing this material is already open, double click the material to place it in the slot for Sphere03. Close the Material/Map Browser, assign the material to Sphere03, then name the material Sphere03. Before closing the Material Editor, click the Background (checkerboard) button for material slots 2 and 3 to see the reflective and refractive traits of both materials. Close the material Editor. Hit F9 to render your scene for a comparison to my render.

If followed accurately the two images should appear similar to each other. Save your file.

Step 8: Materials for Sphere02 and GeoSphere01 - Select Sphere02, then hit M to call up your Material Editor. Select the fourth material slot and click the Background button to set a checkerboard pattern behind the sample sphere.. The default diffuse color, a medium grey, is fine for what we'll need, but we also want this object to be able to reflect only. Slide down to the bottom of the Material Editor where you'll see a rollout called Maps, then open it. We're going to assign a simple reflection map to our material. Click the checkbox left of Reflection, and before assigning a raytrace map, set the Amount value to 50, then click the None button to the right. In the Material Map Browser, double click Raytrace. Note how our sphere in the fourth material slot has now taken on reflective traits. Leave all the values in the Raytrace Parameters rollout to their defaults, click the Go to Parent button, name the material Sphere02 and assign it to the Sphere02. See image below:


Select the fifth material slot which will be for our geosphere. The material we'll be assigning to GeoSphere01 will be a special material from mental ray called Glass (physics_phen). However, before any mental ray material can be worked with, mental ray must be activated first. Hit F10 to call up the Render Scene, click the Common tab and slide down to the very bottom. Open the Assign Renderer rollout, and to the far right of Production, click the button with the three dots, in the Choose Renderer list, double click mental ray Renderer and close the Render Scene. Now, we can access mental ray's materials. Click the Standard button on the Material Editor, and note the three new materials available to us. Simply, double click Glass (physics_phen). Click the Background button to place a checkerboard pattern behind the new material. Different, isn't it? And it seems rather ironic that such an advanced material should have so few parameters. The only parameter we need adjust is the Phong Coefficient, which we'll set to 260. Again, note the changes to this material as highlights appear. Name the material GeoSphere01, assign it to GeoSphere01 and close the Material Editor. On a special note, you may be wondering why we assign names to all our materials. As you advance into 3D art more you'll find that you'll have to deal with an increasing number of objects and materials. Naming these materials will help you keep track of their assignments to the scene objects. Now, return to the camera view by hitting C if not already there, then F9 to do a quick render of our scene thus far. With materials assigned your rendered scene should look like this:


Step 9: Setting up Caustics in mental ray - Return to the top viewport and make sure you have a good view of all of your spherical objects and light. First, we're going to tell mental ray which of our objects will be producing caustics. Using your Select Tool, select mr Area Spot01, right click on it to call up the Quad Menu, scroll down the lower right Transform panel to Properties and click. This will call up the Object Properties panel. Click the mental ray tab, and in the mental ray Rendering Control area enable the Generate Caustics checkbox, see images below:



Now, repeat this step with the four remaining objects, Sphere01, Sphere02, Sphere03 and GeoSphere01 (Plane01 and the camera are not a part of the caustics setup, so ignore these objects). You can also do this in a group by hitting H and selecting these objects all together, then right clicking anyone of them in the top view to set them to generate caustics as outlined above. The last part of setting up mental ray for our project is to instruct mental ray to render caustics. Hit C to return to your camera view. Hit F10 to call up Render Scene: mental ray Renderer dialogue. Open the Indirect Illumination tab, and in the Caustics area of the Indirect Illumination rollout, click the checkbox to Enable caustics. Leave all other settings to their defaults for now. Click the Render button. If followed carefully, your scene should look like the image below:

Save your file.


Step 10: Realism in Caustics - Before getting into this step, it's important to know what caustics truly are. Caustics is what happens to light/photons after being subjected to either refraction through an object or reflection off of an object. Case in point, note the refraction AND reflection of light of and through GeoSphere01. Shouldn't this object also be
reflecting tiny shards of light onto the plane surface? And what about the refraction of light through it? Shouldn't tendrils of light be in the shadow field? Actually, it IS there, but with our default settings these are not going to be so readily visible. Let's correct that now. Our default settings are good enough to give us a fairly good render without having to wait an unusual length of time for the render process to complete itself. To pull that lost information into the visible world, we will need to increase the number of photons being used. Increasing caustic photons improves the definition of the caustics. Hit F10, open the Indirect Illumination tab and slide down to the very bottom. In the Global Light Properties area, increase the number of Caustic Photons to 50000 and Render. See below:


With this increase in photons (and rendering time), we find that our missing tendrils of light are more visible now. We could take the value up even higher, but this should be something for you to experiment with at another time. For now, see below my two renderings done with the caustic photons set to 150,000 and 500,000 respectively:

As seen, increasing caustic photons improves the definition of the light we see reflected/refracted from our objects.

Step 11: HDRI in mental ray - Finally, what this tutorial is all about, HDRI. The beauty of HDRI is that it brings to 3D art an element of reality that was sorely missing beforehand, but we never realized it until we had it. With Splutterfish it's almost criminally easy to use HDRI, so, here we go. HDRI isn't applied to any object like a material or as a map to any light, instead it's applied to the environment. Still in the camera position, hit 8 to call up the Environment and Effects panel. Under Common Parameters in the Background area, click the None button for Environment Map, in the Material/Map Browser double click Bitmap to bring up the Select Bitmap Image File window. If necessary, maneuver to the directory HDRI where you placed your *.hdr file (you may need to access the drop down menu for Files of type, selecting either All Files or Radiance Image File). Once found, double click the file to call up the HDRI Load Settings panel. It's on this panel that you make any adjustments to the *.hdr image before applying it to the environment. The adjustments of HDRI files are beyond the scope of this tutorial, but as a rule of thumb, the white point and black points are usually adjusted to values where both white and black clamping (indicated by magenta and cyan respectively) just disappear from the thumbnail. It's also a matter of artistic taste and what your needs are for the particular project you're working on. For now, stay with all default values, but DO make a note of the White Level Linear
value,
see below:


Click OK, and the map is assigned. Now, it's necessary to copy this map to the Material Editor for us to use it in our scene. Hit M to call the Material Editor up and make sure the Environment and Effects panel is clearly visible. At this time, click and hold the left mouse button down on the Environment Map button and slide this over to the next available material slot (should be number 6) and release the mouse button. Choose Instance and click OK. See image below


You can can now close the Environment and Effects panel. In the Material Editor, you'll notice that our environment map is unusually dark. Scroll down toward the bottom and open the Output rollout. Place the value you noted for the White Level Linear value into the RGB Level, and you can close Output at this time. Now the Environment map is much brighter and all that's left to do before we render is to go into Coordinates rollout and set our environmental mapping to Spherical in the drop down list. Close your Material Editor. If not already in the Camera viewport, hit C, then hit F9. This is what I achieved using the Grace Probe from Paul's site (caustic photons = 50000):


And here's a second render using 500,000 caustic photons:


It's very rare you ever see speed and quality go hand in hand, yet I wanted to show you what such a render would look like. It's well worth the wait. In closing, keep in mind, that learning Max, or any other 3D package is also a matter of having the initiative to experiment with various settings and noting their effects on the rendered graphic. No tutorial could begin to cover every aspect of a 3D subject, e.g. HDRI, modeling, mapping, etc. Good luck to all, and I hope this tutorial has helped you in learning this fascinating element of 3D artwork.

Rick Timmons
DigitalPrizm

1 comment:

  1. Thanks for sharing the blog,I wanted to learn HDRI Library as it create great effects for website and as I love webdesigning I want to improve my skills.

    ReplyDelete