Free 3ds Models | 3ds Max Plugins | Free Video Tutorials | Texture Links | 3d Studio Max | Free 3ds Max Tutorials | 3d Links | Game Ready Models & Files
Login
Username or e-mail:

Password:



Lost Password?

Register now!
Main Menu
Advertisements
Indie Games
Visit IndieGameDev.Net!

HDRI Lighting in 3ds Max
HDRI Lighting in 3ds Max
 
Nick Bertke's Website: HL2 Short Film Discussion
 

NOTE:

Please be aware that I will not be giving instructions for use with 3DSMax throughout this document. I expect you to have a basic knowledge on how it works, how to assign a renderer and set up its parameters, how to create primitives, how the material editor works, and so on. If you have never used 3DSMax before, you’re in over your head attempting this tutorial.

What this is all about

This all started when I made the following post in the Ideas & Suggestions section of a forum for GMod, a Half-Life 2 modification:

http://forums.facepunchstudios.com/showthread.php?t=21286

Up to the time I made this PDF, the thread has received over 600,000 views, which isn’t what I expected at all. I simply intended to have Garry (the creator of GMod) consider putting HDRI technology into GMod. Real-time HDR lighting, however, has already been achieved using this program created by someone whose name I can’t find:

http://www.daionet.gr.jp/~masa/rthdribl/

Since I started the thread, I have received hundreds of emails requesting tutorials and help with setting up HDR lighting in Max. Now, instead of helping every single soul sitting on the GMod thread, I have decided to make this PDF explaining how to do everything.

HDR Lighting explained

Firstly, a HDRI is a High Dynamic Range Image. It is a single .HDR file composed of one photograph at different exposures. A few years ago, the special effects industry discovered that photographing a shot at multiple exposures is a way of capturing multiple levels of light and that they can be used to realistically illuminate a synthetic scene. Soon they realized that by doing this, they could illuminate a synthetic scene using the exact same lighting conditions as a real-life one, resulting in a very realistic computer-generated image when rendered. This means that the photographer not only has to capture all levels of light in the area, but also all the possible angles which it’s coming from. The way they do this is through using a 100% reflective sphere. With this sphere, we can photograph absolutely everything in the scene, and then photograph it at multiple exposures to capture all levels of light as well. Since we can only ever see half a sphere, the photographer must photograph the sphere from one angle, and then from another angle (ideally 90 degrees around from the first angle.) S/he then uses a software program to merge these exposures together. The exposures are not lost; they are simply "packaged" into one .HDR file. That software is then used to "warp" both sides of the sphere into one, which is then called a Light Probe. This light probe is warped into a complete panorama, which is then wrapped around the synthetic scene as a sphere again and used to globally illuminate the synthetic scene. This is what’s called ‘Image-Based Lighting’, but not only is the photographer using those images as a light source, but he’s using all the levels of light which he captured from the multiple exposures.

In conclusion, a High Dynamic Range Image is one which contains multiple levels of light (more than one exposure), while a Low Dynamic Range Image is simply one image (which is of course at one exposure.) An LDRI can be used to illuminate a synthetic scene just as much as a HDRI can, but because a HDRI contains multiple levels of light, the HDRI will result in a more realistic render, particularly when a synthetic object is reflecting it.

The orb explained

The reflective sphere is the number one thing I’m always asked about. What I use is a Garden Ornament I bought at a Nursery for $15 Australian dollars. It’s a hollow stainless steel sphere, about 14cm from one side to the other; a perfect size. You want nothing smaller than a Christmas Decoration and nothing bigger than a basketball. If it’s too big, it will dominate the image. If it’s too small, the reflections will not be spherically accurate. Since I bought my sphere, I’ve done many things to it. I’ve cut a hole through the bottom and cut a thread through the hole, so now I can screw the sphere onto a tripod. Because the width of the stainless steel is fragile and very thin, I’ve screwed a tripod fitting into it instead, so now I’m screwing the tripod fitting into the tripod instead of wearing out the stainless steel of the sphere. The next thing I did to this poor orb was paint half of it a perfect grey. Now I photograph that side too, and then create a synthetic sphere of the exact same shade and match it up with the real one by altering the HDR image’s colours, brightness and contrast. Once the synthetic grey sphere looks exactly the same as the grey side of the real sphere, you know for 100% sure that synthetic lighting, colours, brightness and contrast are perfectly matched with the real-life lighting conditions of your photograph.

Since I wanted the grey half of the sphere to be an absolute grey (50% black and 50% white) I went down to Peel Paint Supplies and had them custom-mix the paint for me. I also got them to put it into a spray can format, because painting it with a brush would leave streaks along the ball’s surface. You need to make sure that the paint you ask for is a Matte paint (non-shiny.)

HDRI Lighting in 3ds Max

What you will need:

 

If you only have one tripod (for your camera) you’ll have to hold your sphere up by hand while you photograph it. This of course means that the sphere won’t be aligned in each of your exposures, so you’ll need an image-editing program with layer support to line the sphere up in each exposure. It’s critical that the sphere is in exactly the same position in each exposure.

 

  1. The Photography

First thing’s first! You must photograph your ball at multiple exposures. If you’re photographing outdoors, a good range is from 1/4 of a second to 1/1000th of a second with 1.5 F-Stop incriminations. If one of your exposures is completely black or completely white, don’t bother photographing it. It won’t contain any information about the lighting in the area. With this in mind, what you really want to do is take exposures from almost completely black to almost completely white. The most exposures you should ever need are about 5 or 6. I’ve managed to get away with 3 before, but with 5 or 6 exposures, you’re sure to get all possible levels of light (going from 1/4 of a second to 1/1000th of a second.) When photographing the orb, try not to photograph it from a short distance. The closer something is to the lens, the bigger it gets, which means the middle of your ball will be bigger than the rest if you photograph it from close-up. Get back about half a meter to a meter and zoom in. Like I’ve said before, it’s critical that the orb is in the exact same position for each exposure. Nothing should change but the exposure settings (so you might even want to manually focus on the sphere to prevent the auto-focus from thinking otherwise.)

Once you have photographed all the exposures, you should then switch your camera onto Automatic mode and let it decide what exposure your background (final render) will be at. Point your camera at the ball and write down/remember the Shutter Speed and Aperture your camera gives you. Switch back to Manual mode and apply the exposure settings which your camera gave you. What I do now is photograph what I call a "Probe Reference Shot." Using a manual focus on the ball and a manual exposure (which Automatic mode gave me), I photograph the ball so that it’s only consuming one half of the photo (left or right.) This way, I can create a synthetic sphere next to the real sphere, make it reflect the HDR image, and use it to align the synthetic camera angle until the synthetic sphere’s reflections are exactly the same as the real one’s. This is not to match colour and contrast, but simply to get the synthetic camera angle the same as the real one, and to align the HDR image with the lighting in the real-life scene.

After photographing the "Probe Reference Shot", I turn the ball around so the grey side is facing the camera, and then photograph that (again with the ball only consuming one half of the frame.) This is what I call the "Colour Reference Shot". I’ve explained what this is for in "The Orb Explained", but we’ll come to the reason for this later in the tutorial.

Now that you have your exposures, your Reference Shot and Colour Reference Shot, you may want to photograph a background image for your synthetic objects/characters to be rendered into. Make sure you photograph your background shot at the same angle, focus and exposure as your two reference shots. Once you have all this stuff, the photography side is complete!

Notes on the photography

  • If you don’t have a grey side on your ball, try using a ping-pong ball. Be careful though, white can be easily exposed, especially with outdoor scenes.
  • For your reference shots and background shot, make sure the focus, exposure and camera angle is the same.
  • Photograph the ball from a distance, about a meter or so. The closer something is to the lens, the bigger it is in the photo, and you don’t want a ball with a fat centre.
  • When you photograph the exposures of your ball, the camera must be at the same hight (in other words, it should be looking at the ball straight on and not be looking up or down at it.)
  • You should photograph your reference shots at the same camera-angle as your background shot.
  • If you’re photographing two sides of your sphere, make sure the second angle is 90 degrees around from the first angle. Try to keep the same distance from the sphere as the first angle. Also, the exposure values should be the same as they were for the first angle, and you should end up with the same amount of exposures, too.
  • 2. HDRI Assembly: Single sided

    Now that you have all the photographs you need, it’s time to get them onto the computer and assemble your HDRI. Once you’ve uploaded your pictures, the first thing you need to do is load up HDRShop. Go to Create > Assemble HDR Image Sequence and you’re presented with the "Assemble HDR image from LDR Sequence" window. Click Load Images and select all of your exposures either from darkest to brightest or vice versa. Once the exposures are loaded, the common thing to do next is to click Calculate under ‘Calculate Scale Increments’. What this does is calculate the amount of F-Stop increments between each exposure. If you already know this value, select or type it in under the ‘Use Preset Scale Increments’. Once that’s done, click the ‘Generate Image’ button. You now have your HDR image. Use your numpad’s plus and minus keys to browse up and down through the exposures. Once you find the one which is reasonably close to the exposure used in your background and reference shots, click Image > Pixels > Scale to current exposure. This sets the currently displayed exposure as the default one for the HDR image, and prevents you from having to increase the brightness when you load it in 3DSMax. Without doing this, the darkest exposure of the HDRI will be the default exposure.

    Now we have to warp our HDR sphere into a HDR panorama. Click Draw > Options > Circle, and select the sphere in your image so that the circle contains the sphere perfectly. Now go to Image > Crop, and the image is cropped to the sphere. Go to Image > Panorama > Panoramic Transformations. Make sure your Source Image (on the left) is set to Mirrored Ball, and the destination image is set to Latitude/Longitude. Hit OK and you’re left with your mirrored sphere warped into a panorama. Notice how the default exposure you set has been maintained through the warping process. Lastly, save you HDR panorama in Radiance Format (.HDR).

     

    HDRI Assembly: Double-sided

    Photographing both sides of the sphere is ultimately a way of removing all distortion in your final panorama (which appears on the left and right side due to the very edges of the sphere), and you can also use this method to remove yourself and your camera from the shot.

    Once you’ve combined your exposures into one HDRI for each angle, you must now set up points which show HDRShop how the camera has rotated around the sphere for the second angle. From hereon I’ll be referring to the angles as Probe 1 and Probe 2. Load up both probes and open the Point Editor (Window > Point Editor). Go to Points > New Point, and select a feature in Probe 1 which you can also see in Probe 2. Once you’ve selected it in Probe 1, you must also select it in Probe 2. Create a second point in the Point Editor and do the same only with a different feature visible in both probes. Once you have both points assigned in both probes, open up Notepad and type the X and Y co-ordinates for the points for each probe. In Probe 1, go to Image > Panorama > Panoramic Transformations, and set it up so that your destination image will be a Light Probe. Click Match Points and then Settings, and type in the co-ordinates you stored in Notepad into the appropriate fields. Once you have the co-ordinates typed in, make sure the first image is set to Probe 1 and the second image (on the right) is set to Probe 2. Hit OK and generate the Light Probe of Probe 1. You now have an actual HDR Light Probe composed of both HDR angles. Save it as Probe1_warped.hdr.

    The next part is optional; getting rid of the distortion and the photographer in the shot. Go to Probe 2 and transform it from a Mirrored Ball into a Light Probe. Save that as Probe2_warped.hdr. Re-open both Probe1_warped and Probe2_warped so that the file names get registered into HDRShop. What we have to do now is open up an image-editing program with layer support. For this tutorial I’ll use Photoshop. In Photoshop, open up Probe2_warped and put Probe1_warped as a layer on top. What you have to do now is create a mask. Right click on the top layer (Probe1_warped) and select Create Layer Mask. Using the Paintbrush, paint with black to ‘erase’ the parts of Probe1_warped (of which Probe2_warped will show through) and use white to restore any parts you may have accidentally painted. Once you’re happy with the way everything looks, hide all the colour channels of the document apart from the Mask layer, so that only the mask is showing. You should have an image that looks something like this:

    This is your mask. Invert the image (Image > Adjustments > Invert) and save it as a BMP file called Mask.

    In HDRShop, make sure you have Probe1_warped and Probe2_warped loaded, and then load the third element: the mask. Go to Image > Calculate, and select A * C + B * (1-C). Set Image A to Probe2_warped, B to Probe1_Warped, C to the mask, and D to Probe2_warped too. Hit OK. HDRShop merges Probe1_warped and Probe2_warped into one using your Mask.

    This concludes the assembly of your double-sided light probe, and what you’re left with now is the one and only HDRI which you will use to light your scene.

    Notes on HDRI assembly

  • Image quality is not an issue with HDR images. Poor quality is something you’ll get naturally when warping your sphere into a panorama, and is not avoidable. If you could see the light coming at the sphere as an image, you can imagine that it wouldn’t be a very sharp image at all. In fact, the whole image would be one big blur. You’ll be blurring your HDR image in 3DSMax anyway, because this speeds up the rendering process while also improving the image quality of your render.
  • I usually increase the exposure by 4 increments each time and select ‘1F/Stop’ in HDRShop as my exposure increment value. This always gives me perfect results.
  • 3. Setting up in 3D Studio MAX

    Now that you have your HDRI all ready to go, it’s time to set things up in 3DS. Once you have 3DS open, the first thing to do is set up the environment and Viewport background.

    1. Go to Render > Environment, and load a Bitmap into the environment channel. The bitmap you want here is your Probe Reference Shot (the reflective side of your sphere), because you’re first going to line up your HDRI and adjust its brightness and contrast to match the sphere in your Probe Reference Shot.
    2. Go to Viewport > Background and tick ‘Use Environment’. Close that, right click on the Perspective viewport’s title and tick ‘Show Background’.
    3. Create a sphere from the middle of the grid, about the same size as the sphere in the Probe Reference. Rotate the view so that you’re looking at the sphere from front on (like your camera was looking at the sphere.) The grid should now be appearing as a horizontal line. Adjust the view so that your CG sphere is next to the real sphere in the viewport’s background.
    4. Once your renderer is set up, drag the HDRI to a free material slot in the material editor. Make sure it’s set up as a Spherical Environment. What you have to do now is create a new material for your CG sphere. Since you’re matching up the reflective side of your real sphere, create a new material which is completely black and reflects your HDRI 100%. Simply drag and drop the HDRI as an instance to the Reflection channel of the material. It is very important you drag it as an instance. This ensures that whatever changes you make to it in the material editor, they’ll be linked and updated in real-time to where you dragged the HDRI from. Your material should now be reflecting your HDRI and should be looking something like your real sphere.
    5. Drag and drop the material to your sphere in the viewport. You’re now ready to give your scene a test render and see how close your CG sphere comes to the real thing. If it looks like the reflections are the wrong way around, rotate the view in the viewport to correct it. It’s better to rotate to correct the angle than shift the HDRI in the material editor.

      What you want to do is adjust the RGB Level and RGB Offset of your HDRI (under the Output rollout) to get your CG sphere’s reflections as close as possible to the reflections of the real sphere. The RGB level is the intensity level; think of it as the Brightness & Contrast levels in Photoshop rolled into one. The RGB Offset is your brightness level. To increase the contrast of your HDRI, for example, you would raise the RGB Level and lower the RGB Offset. This means having to give your RGB offset a negative number, because it starts off at 0. If you increase the RGB Offset and leave the RGB level as it is, the HDRI’s brightness will increase but the contrast will stay the same, resulting in a "hazier" image.

      You may also want to use the individual colour options for your HDRI. To do this, tick ‘Enable RGB Controls’, click R, G or B, and adjust the corresponding the line. For best control, use the highest point on the right. The shadows are obviously on the left of the graph, while the highlights are on the right, but by having just one point on the left and one on the right, you can adjust one while adequately adjusting the rest of the line at the same time.

    1. Once the colours and contrast of your sphere’s reflections are looking the same as the real ones in the Probe Reference, you now want to further match the colours and contrast using the grey side of your sphere. In the environment window, change the Environment to the Shade Reference Shot (the one of the grey side of your sphere). Assuming it is of 50% black and 50% white, create a new material in the editor which is of the same colour (adjust the grey slider to the middle, around 130 or so.) Apply this new grey material to your CG sphere and render it out. Now, if your CG sphere is darker/brighter than the real one, try not to change the RGB Level and RGB Offset of your HDRI. Instead, change the intensity value of the GI/Skylight/Direct Light which is using your HDRI. This is because you’ve just matched up your reflections perfectly, and what you’re doing now is adjusting the lighting, not the reflections.
    2. Finally, once your CG reflective sphere and CG grey sphere are close to the real ones, you should now have a good lighting set up and should end up with a realistic composite when you render something into the background shot. Change the Environment to your background shot, and rotate/zoom the camera to match the angle of the real one. You now have a HDRI-lit scene ready to go. What you do hereon is up to you!

     

    Notes on Setting up in 3DSMax

    • It is often a good idea to have two copies of your HDRI sitting in your material editor; one which illuminates your scene and the other which objects in your scene reflect. This is because a sharp un-blurred HDRI used for lighting can often cause your render to look dirty and poorly sampled, while a blurry one can improve this greatly without changing the lighting of your scene at all. Not only that, but a blurry HDRI can actually speed up the rendering process, because there are less fine-details in the HDRI to be processed which make no difference to the lighting of your scene anyway. Only create a duplicate of your HDRI once you have your lighting, colours and contrast set up and matched to your liking. Otherwise you’ll be changing settings for two HDRIs instead of one should you decide to change them in the future. To blur your HDRI, increase the value of the Blur Offset. 0.02 is often a good value; it blurs things nicely while retaining details in the HDRI. Rename that material as ‘Lighting’ or something similar. The duplicate HDRI (which you should rename ‘Reflections’) should remain sharp to have nice sharp reflections in your scene. The Reflections HDRI is of course the one to use for your object’s Reflections channel.

     

    4. Creating Matte Objects

    Whilst compositing CG elements into a real-life photograph, you will most likely come across the problem of casting CG shadows onto real-life objects. The way to do this is to create Matte objects. A Matte material (called ‘Matte/Shadow’ in 3DSMax) is one which is invisible to the camera but shows only shadows cast upon its surface. In other words, we can’t see the object with that material applied, but we can see shadows/GI cast upon it. Here’s how to set up a Matte surface for Mental Ray, Brazil and VRay.

    For VRay: VRay comes equipped with its own Matte feature, so you don’t have to use MAX’s at all. Right-click on the object you want to be a Matte, and select VRay Properties from the menu. Tick ‘Matte Object’ and ‘Shadows’, and you’re all set!

    For Brazil: Brazil’s method is a little more complicated. For Brazil you have to use MAX’s Matte/Shadow material, but this doesn’t cut the butter just yet. If you left it like this, your background image would be the material which the Matte object would take on, so when it bounces/generates light onto other objects in the scene, those objects will appear translucent. To resolve this matter, we’re going to set up a Brazil Utility material. Assign a Matte/Shadow material as the Utility’s primary material, and assign a material (with the same colour as the real-surface in your background photo) to the Utility’s ‘Generate UI’ material. This will ensure that the Brazil Utility will generate/bounce light of that colour and not of the background photo. Now just drag and drop the Brazil Utility to the object you want to be a Matte.

    For Mental Ray: With MR things are pretty straight forward. Simply drag and drop a Matte/Shadow material to an object. Mental Ray isn’t capable of rendering GI shadows onto a Matte (areas which light can’t get to,) it can only render actual shadows cast by a light source (such as an Omni or Spotlight.) This is one limitation of MR which tends to steer people away from it.

    Conclusion

    So where to from here? It’s up to you. People often want to get everything exactly the same as I do, but this is a form of art, so you must experiment and develop your own ways of doing things. There is no right or wrong way of doing what you want to achieve. Search the net for more tutorials and try things out. That’s how I started and it didn’t hurt, look where it’s got me today.

    HDRI Lighting in 3ds Max

    Used with permission by Max-Realms.Com

    Recent 3d Renders
    1970 Mustang - High Poly - 004.jpg
    2008/9/2 17:57
    BJS3D
    1970 Mustang - High Poly - 003.jpg
    2008/9/2 1:37
    BJS3D
    Stages 001.jpg
    2008/8/29 1:20
    BJS3D
    justhere4now_03.jpg
    2008/8/25 23:31
    BJS3D
    it__s time2! copy.jpg
    2008/8/21 7:31
    Jacinto

    Advertisements


    Sponsor
    Visit Novedge for 3ds Max!
    New Video Tutorials
    New 3d Models
    Donations
    Support Our Site!
    Make donations with PayPal!
    Donat-o-Meter Stats
    September's Goal: $15.00
    Due Date: Sep 30
    Gross Amount: $5.00
    Net Balance: $4.50
    Left to go: $10.50

    Donations
    Anonymous ($5)
    Who's Online
    12 user(s) are online (1 user(s) are browsing Tutorials (Folder))

    Members: 0
    Guests: 12

    more...
    New Members
    tcraiford 2008/9/5
    sebadi 2008/9/5
    ardian 2008/9/5
    ThaFort 2008/9/5
    scottbillings 2008/9/5
    Ferenczy 2008/9/5
    kovacevd 2008/9/5
    jmcawley 2008/9/5
    PizzaFreak5 2008/9/5
    atwomik 2008/9/5
     ©2003-2008 by David N. Goodman. MaxRealms, Max-Realms, Max-Realms.Com and any variation including the pronunciation of "Max Realms" are legal trademarks. All Rights Reserved.