Update: I’ve written a new HDRI tutorial that covers some more advanced stuff here:
It’s aimed a bit more to professional HDRI creators and assumes you already know the basics, so if you’re completely new to HDRIs you should read this post first :)
There is no easier or quicker way to light a CG scene than to use an HDRI. They are essentially snapshots of the real world that contain exquisitely detailed lighting information, which can transport your bland CG objects into realistic virtual environments.
Not only do they provide accurate lighting, but they can be seen in the background and in reflections, which makes them all the more immersive.
Creating a high quality HDRI from scratch is quite a complicated task that requires very specific equipment and a meticulous workflow. One mistake like using the wrong focal length or choosing a slow shutter speed can mean all your time has been wasted and you’ll have to start all over again.
I’ve been making HDRIs for a couple of years now, so I hope I can save you some time and experimentation. This is by no means the only way to make an HDRI, but it is a good introduction to the process.
By the end of this tutorial, you’ll have made your very own 360º HDR environment map that can be used to light a 3D scene.
Buckle your seat belts boys and girls, because this is gonna be a long one!
What is an HDRI?
Before we actually get into making anything, it’s important to thoroughly understand what it is that we’re doing, and demystify some of the confusion around the subject.
If you’re already confident that you know what an HDRI actually is, scroll down to the “Creating an HDRI” section.
An HDRI is a panoramic photograph that covers the entire field of vision and contains a large amount of data (typically 32 bits per pixel per channel) which can be used to emit light into a CG scene.
“HDRI” stands for High Dynamic Range Image. “Dynamic range” is the measurement of how much brightness information is contained in an image, so a “high dynamic range” image is an image that has a very large range of brightness, more than you can see on your screen in one go actually.
Most photos and images in general are what I call “LDR” images, or Low Dynamic Range images. They store 8 bits of data for each of the red, green and blue channels for every pixel. An example of an LDR image is a JPG file.
The problem with LDR images is that they are limited to a relatively small range of brightness, from 0 to 255, which is not actually all that much.
If you want to light a 3D scene using an image, what you really need is a format that can store more than just 8 bits of data per channel so that you can have a much larger range of brightness. Luckily, there are several formats that can do this, the most common of which has the extension “.hdr”.
To illustrate the difference between a JPG and an HDR file, all we need to do is play with the brightness:
As you can see, the JPG on the left has absolutely no detail in the brighter parts, the entire rectangle is a single solid colour. This is because the maximum brightness of any pixel in a JPG image is 255. In an HDRI however, the maximum brightness is practically infinite, which allows the actual fluorescent light bulbs to become visible when you darken the image.
This is a neat trick, but what’s important to realize is that the HDR file stores the brightness of the light bulb correctly. It knows that the light bulb is much brighter than the rectangular area around it, which in the JPG version is just one solid colour. This means that when you use the image to light a 3D scene, the light bulb will emit more light.
Here’s a simple scene lit using the JPG and the HDRI:
As you can see, the JPG produces flat and unrealistic lighting. The HDRI, however, makes nice sharp shadows and plenty of juicy contrast as we expect from those bright fluorescent light bulbs.
The difference is even more obvious when we use an example that has an even brighter light source, like the sun:
This time the JPG isn’t brightened, all the settings are exactly the same except for the format of the environment image. You can see in the chrome ball at the back that the JPG and HDR seem identical, but the lighting that they create is completely different due to the fact that the HDR file stores the correct brightness of the sun and the JPG is clipped at 255 which is far too low.
If you want to, you can download that HDRI and try it out yourself :)
Finally, I need to address one last confusing point, and that is what some people refer to as HDR Photography.
Although many cameras and tutorials refer to this as an “HDR” image, this type of image can be better described as a tonemapped image. The idea is to take several photos with different exposures, and put them together so that all parts of the image are properly exposed (not too bright or too dark) – for example the sky is usually much brighter than the rest of an image, so the tonemapping software will choose a darker exposure to use for the sky and a brighter exposure for the rest of the scene to balance it out. The end result is an 8-bit image where you should be able to see lots of details that might otherwise be lost in a regular photo.
The reason there is some confusion about this is because the process is quite similar to how you would make an HDRI (the kind we’re making in this article) – you shoot a bunch of photos with different exposures and put them together into one image later. The difference is that with a tonemapped image the goal is to make a regular JPG image that looks nice, while with an HDRI the goal is to make a 32-bit image that stores lots of data about how bright different parts of the image are (which might not necessarily be a very pretty photo) and can therefore be used to emit light realistically into a 3D scene.
A true HDRI will be in a format that can contain lots of data (HDR/EXR/TIFF). It will look just like any other image until you adjust the exposure and discover that it’s secretly storing much brighter colours than you could see before.
Ok, so now that we know what we’re talking about, let’s actually make one of these bad boys…
Creating an HDRI
There are various ways to make an HDRI, but it’d be impossible to cover every detail in a single article. So I’ll show you a method that gives you decent results with a reasonable amount of effort.
Firstly, you’ll need some gear:
- DSLR camera (anything really, but you’ll see why I recommend Canon below)
- Wide angle lens (less than 20mm)
- Tripod (preferably something sturdy and heavy, but anything will do)
- Panoramic head (optional, but highly recommended)
You’ll also need to download some software:
- Magic Lantern (free) – firmware for Canon cameras, skip if you have a different brand of course
- PTGui Pro (€149) – to stitch the HDRI together
There is a sort of free alternative to PTGui called Hugin, but in my experience it really isn’t usable for this sort of panorama. While you may be able to spend a few days hacking at Hugin to get it to work for you, remember that you’ve already spent a few hundred bucks on camera equipment so a little extra on software that will save you time is a good investment.
Step 1: Shooting
In short, all you have to do is shoot lots and lots of photos at all angles, and for each angle you shoot a bunch of different exposures to capture all the different brightnesses in the scene.
But before we get to that, let me explain some of your equipment choices…
Choosing a Camera
You really don’t need to fork out the big bucks for a fancy camera if all you want to do is shoot HDRIs. If you’ve already got a camera that gives you manual control over everything, just try using that. You may find that you’re a bit limited, so if you want to get a new camera I’d recommend any Canon DSLR.
I currently use a Canon 600D, which was the cheapest DSLR I could find a few years ago. They don’t even sell it any more, but you can get one second-hand for as little as $270 on amazon. Or if you definitely want a brand new camera, the 750D is the new replacement to the 600D and is similarly affordable.
The reason why I recommend Canon is mainly because of the Magic Lantern firmware, which allows you to set up extremely customized exposure brackets, thus allowing you to capture the full range of brightness in almost any scene.
Choosing a Lens
Anything wide (<20mm) will do. The wider it is, the quicker you can shoot an HDRI, but the lower the final resolution will be. It’s a frustrating trade-off: if you want to shoot them really quickly you have to sacrifice some resolution, but if you want lots of resolution you can expect to be standing there for half an hour hoping the clouds don’t move too much while you wear down the shutter mechanism on your camera doing rotation after rotation.
I currently use a 10-18mm EF-S lens (fairly affordable) with my 600D, which means the highest resolution HDRI I can create is about 17000×8500 or so. I previously used the 18-55mm lens that came with my camera, and it worked just fine and gave me even higher resolutions (25k+), but because it’s not as wide I needed to shoot more angles and was thus a bit too slow for regular use. I would start shooting as the sun came up casting beautiful light everywhere, but by the time I’d finished the sun had gone behind a big cloud and made one half of my image look overcast.
I think the sweet spot for a 20 megapixel camera is 10mm (for a 1.6 crop-sensor camera like mine, same as 16mm on a full-frame sensor), as the resolution is plenty high enough for most uses and it doesn’t take too long to shoot.
If you want to work out exactly what the highest resolution HDRI you can create with your lens-camera combo, here’s a formula:
(1/(<vertical field of view in degrees>/360))*<vertical resolution of camera>
You can find the vertical field of view by googling the exact name of the lens.
So for me that would be:
(1/(74/360))*3456 = 16812
In practice this is just an estimate, as the stitching software is never perfectly accurate.
Tripod and Panoramic Head
Literally any tripod will do. If your camera can sit on it, it’s fine. If you’ll be shooting HDRIs regularly you might want to invest in something sturdy, you’ll be rotating the camera around a lot and you don’t want to bump it too much.
A panoramic head is not completely necessary for most outdoor situations, but for indoor shots it is highly recommended. You can try without one for now, but you’ll soon find that you get a lot of seams and stitching errors in your HDRI.
Without a pano head, the perspective shifts slightly between each shot, which makes it difficult for the stitching software to line everything up properly.
Here’s a direct comparison between using a regular tripod (left), and using a tripod with a pano head attached (right):
As you can see in the right image, everything stays perfectly still relative to each other. In the left image however, look at how different parts of the vase (especially the neck) become visible behind the kudu sculpture as the camera rotates. This effect is called parallax, and is what confuses the stitching software.
The closer something is to the camera, the more apparent the parallax effect. This is why it’s usually OK not to use a panoramic head when shooting outdoors.
I use a Panosaurus – it’s nice and sturdy without being too heavy.
With the equipment out the way, let’s finally start shooting something…
Depending on your lens and camera, you’ll want to shoot a different number of angles in order to capture the full 360º view of your scene. My rule of thumb is to have at least 30% of overlap between each angle, so you’ll have to play around a bit to see how many different angles you need. If you don’t have a panoramic head, I would suggest figuring this out once and then drawing marks on your tripod to help you rotate accurately without having to look through the viewfinder every time.
If you do have a panoramic head, it probably has the degrees marked out for you and you’ll just have to remember how much to rotate each time.
Since I have a 10mm lens and a 600D (1.6x crop sensor), I need to shoot every 40º horizontally (9 angles) to capture everything with a decent overlap, and do this for 3 different vertical angles (+45º, 0º, -45º), totalling 27 different angles.
But that’s just to make a 360º panorama, we also need to shoot different exposures in order to make it a high dynamic range image (HDRI). So for each of the 27 different angles, I typically shoot 5 different exposures separated by 3 EVs (starting from 1/4000th going up to 1 second).
Magic Lantern makes this very easy:
Notice the Sequence option is set to “0 + ++”, which means I just have to choose the fastest shutter speed (1/4000) and it’ll shoot progressively slower until the final image, calculating all the shutter speeds in between automatically.
Make sure your camera is fully manual now – that includes manual shutter speed, exposure, white balance, focusing, ISO… everything. You do not want any of the camera settings to be adjusted at any time while you’re shooting all the different angles. Also make sure that you’re shooting in RAW, if your camera is capable, to capture as much data as you can. Then set the shutter speed to the quickest one you want (in my case 1/4000th) so that bright light sources are not over-exposed, and the aperture to something nice and sharp like f/8.0. You’ll obviously need to play around with these settings, but I find that’s a good starting point.
Now you just rotate the camera to the correct position, click the shutter and it’ll shoot the 5 different exposures automatically. Then rotate to the next angle and repeat.
With my setup, I’m left with a total of 135 images. A real memory card gobbler.
Different situations require different exposure settings, for example a night shot typically has very bright light sources and very dark shadows: You may need to do 7 exposures instead of 5 to capture the full range, use an ND filter to make sure the highlights aren’t clipped, and use ISO bracketing as well as exposure bracketing in order to avoid having exposure times of several minutes (for each of the 27 angles).
Step 2: Cleaning
This step is optional, but I always do it to get the best possible quality from my HDRIs.
All we need to do is remove some of the lens artifacts in the photos, such as chromatic aberration, noise and vignetting. There’s a two-fold reason for doing this:
- Removing imperfections means prettier HDRIs
- It makes stitching easier – chromatic aberration and noise can sometimes confuse the stitching software
I recommend you use Lightroom for this, because it allows you to export 16-bit TIFFs that retain the EXIF data (a record of all the camera settings), which is absolutely required for stitching. There may be some other free software that can do this, but I don’t know of any. If there is no EXIF data, you’ll have to enter the exact shutter speed for each of your 135 images, which would be a real pain in the ass.
If you don’t have Lightroom, you can safely skip this step.
So once you’ve finished shooting, plug in your memory card or camera, fire up lightroom and import all the images.
Pick one of the well-exposed images (just so you can see what you’re doing, and head on over to the develop tab.
If you want to adjust the white balance at all, now is the time to do it. This image is a little too warm, so I’ll adjust it slightly.
It’s important not to do anything too drastic here, like adjusting contrast or exposure to make it look pretty. Our number one priority is to maintain realism, all we want to do is fix things that are artifacts, like chromatic aberration.
So if you zoom into one of the corners, you’ll probably see some subtle purple/green or red/blue colour fringes:
This is easily fixed, just turning on the “Enable Profile Corrections” and “Remove Chromatic Aberration” in the lens corrections panel usually does a pretty good job:
You may need to look at the Profile tab and select your exact camera and lens combo if it’s not detected automatically.
Then all we have to do is copy these settings across to the rest of the images, so select them all at the bottom (Ctrl-A) and click the “Sync” button at the bottom right.
A window will pop up with all sorts of checkboxes. Just click the “Check All” button at the bottom left of that window, and then hit “Synchronize”. This will update all the selected images with the lens corrections and white balance adjustment.
Finally, hit Ctrl-Shift-E to export the images (also accessible from the file menu). You can put them wherever you like, but the most important thing is to set the output format to 16 bit TIFFs:
Step 3: Stitching
Now the fun part!
When you fire up PTGui you’ll see a simple screen like this:
The first thing to do is to bring in all our images. So hit the “Load images…” button, select all the files that your exported from Lightroom (or if you did not use Lightroom, just use the files you copied from your camera).
You’ll then see a long list of thumbnails. You may need to wait a little bit for these to finish loading before you continue.
The first thing we need to do is tell PTGui that this is an HDR panorama and link all the exposure brackets together so that it’ll understand that every 5 images is actually one photo (just with different exposures).
To do this, just go to Images > Link HDR Bracketed Exposures.
A confirmation dialog should pop up and tell you how many sets of how many brackets there are (in my case, 28 sets of 5 brackets). Just hit OK.
Now before we align the images, it’s a good idea to do some masking. We basically want to tell PTGui not to use certain portions of certain images that might confuse it.
An example of such an area would be the tripod that is visible at the bottom of some of the images – since some of the tripod (or pano head) is rotating with the camera, PTGui might get confused if it matches that area in each image.
Another thing we want to mask out is lens flares – when you add a mask in one image, PTGui will replace that portion of the panorama with content from a different photo, which will magically remove the lens flare.
So head on over to the Mask tab and slowly go through each image, and paint over anything you don’t want to see, like lens flares, the tripod, your own shadow, etc using the red mask. You’ll notice that since our exposure brackets are linked, you don’t have to paint on every photo, just one from each bracketed set. Since your tripod mask will look identical on every image, it’s a good idea to paint it once and then use the Copy/Paste buttons at the bottom left to speed things up. You can hold Shift to draw straight lines, or Ctrl to fill in an enclosed space.
When you’re done with that, go back to the Project Assistant tab and click Align images.
Another window will pop up asking about bracketed exposures. Make sure you choose the first option (linking the images again), and also choose “True HDR” at the bottom since we don’t want to tonemap the image.
PTGui will now go through all the images and try to find similar points between each of them (called “control points”). Usually it’s pretty good at this, but sometimes it will struggle a bit and may ask you to add control points manually (which is a time consuming process).
Lucky for me, it did a pretty good job on the first try!
If the Panorama Editor window isn’t already open, you can open it by hitting Ctrl-E. This window shows you (roughly) what the final panorama will look like, and lets you drag it around with the left and right mouse buttons to adjust the rotation.
If everything looks too dark or too bright, adjust the Exposure slider in the Exposure/HDR tab.
Just before we click the magic button, lets save our project in case anything goes wrong. As you can expect, you can just hit Ctrl-S or use the file menu.
And that’s it!
All that’s left is to choose what resolution we want in the Create Panorama tab (click “Set optimum size” to use the highest resolution possible), disable the JPG output option and finally click “Create Panorama”!
Depending on how powerful your computer is and what resolution you chose, this might take anywhere between a few seconds and several hours.
Once it’s done, there should be a .hdr file in the location that you saved the project!
Step 4: Try it out!
Now that we have a real HDRI that we made all by ourselves, let’s see what sort of lighting it creates!
To do this in Blender+Cycles is stupidly simple. In fact it only takes 15 seconds:
So there you have it! Feel free to pat yourself on the back for a job well done!
Now go find some interesting places to shoot HDRIs and share with the rest of us :)
PS: The final HDRI created in this tutorial can be downloaded from the top of this page.