Is there a way to create an HDR map from a rendered scene in blender? I'm asking because I'm working to optimize an indoor scene that will be used multiple times for rendering scenes in a comic, and it has open windows which look out to a cityscape. I would like to cut the cityscape out and replace it with an HDR version of it, so that it doesn't have to calculate as many bounces and (by extension) renders faster.
Yes, there is in cycles. To begin select your camera. You will need to make changes to its settings. In the camera tab under lens, set it to Panoramic, and the type to Equirectangular. Now, to make it more HDR friendly head into the color management section of the Scene tab. I would select raw, since it will save the most color data. depending on the amount of dynamic range you want, you can make more or less images at different exposures.
You image is HDR strait out of blender, as long as you choose a format that supports HDR images, like
.EXR, your image should be good.
The Short Answer
I'll post a new answer here because it seems that there is a good deal of confusion, and editing the existing accepted answer isn't the most optimal way to deal with this.
The answer is that Blender is already scene-referred enabled by default. In fact, the entire Blender architecture leans this way, it is just that many learning artists are unaware of the division between a scene referred and display referred working model.
TL; DR If you select Cycles as the default renderer, and save as an EXR, your saved file will already be high dynamic range.
The Longer Answer
So what is High Dynamic Range imaging?
If we explode what we think we know about imaging, we can probably get a good handle on what HDR is, it becomes clear why Cycles renders its data in accordance with scene referred models.
In the physical world, light is a strictly linear phenomenon. If you use a spot meter and measure a point in your frame at 100 units, something in the frame that is twice as illuminated will read 200 units. There is no white. There is no black. Just ratios of light from zero to infinity.
That's right... our values go from 0 all the way up to whatever our highest and brightest value is. This is a scene referred model.
Blender and Cycles and Scene Referred Models
The same holds true in Blender. If you take a default cube and render it in Cycles with 30 point lights in close, the rendered output window might look odd and show the cube as blown out white. But in the internal model, nothing is further from the truth.
If we use the swatch to measure the values on the cube, we can see that the values in the information bar that show up extend well off into the crazy zone. The values to the left of the CM information show the internal model, and the values to the right show the values after the CM transformation. On the left then, are the internal scene referred values, and on the right we see the display referred transformation. So when we flip the various output transforms listed in the color management panel, we are changing the display output transform, and not, in fact, changing the underlying scene referred data at all. Raw, sRGB, or otherwise.
By default, Blender uses a blind and ignorant clip cut that shaves off all of the excess values above the display referred value of 1.0. This means that if you save to an inappropriate file type such as JPEG, PNG, etc., the values on the right side of the CM information bar will be plopped into the file.
If however you save into a data-preserving file format such as EXR, the scene referred data values will be preserved in the file format.
So the short answer to how to get HDR values out of Blender is... don't do anything, it already is! No need for Luminance. No need for software magic. Just render via Cycles.
The slightly longer answer involves understanding the differences between a scene referred linear model and a low dynamic range display referred non-linear model, and why the two are vastly different. It also involves understanding why each model is different, and what important things each bring to the table regarding needs.
Phew... a longer explanation than likely wanted, but one that only barely does justice to the complexities of these two models and the science of pixels and light. If anyone reading this finds it at all interesting and want to further their craft, I would strongly suggest you go read the Visual Effects Society Handbook available at CinematicColor.com.
Hide everything except the parts of your scene you want to put in the environment hdr (or put them on separate layers).
(this step isn't necessary, but it makes things easier)
Add a new your camera at the same location as your current camera, but with the rotation aligned to the axes. Then make it the active camera (CtrlNumpad 0)
With the new camera selected, set the lens of the camera to Panoramic and the type to Equirectangular in Properties > Object data:
Set the output format to OpenEXR in Render settings > Output:
OpenEXR is a hdr format which can store values as 32bit floats the amount of light (brightness) per pixel as floating point values.
Render and save (F3) the panorama.
Load the hdr into the world node setup in an Environment texture node, and rotate it 180° around the Z (for some reason it always seems to come out reversed):
Now you can hide/remove your environment objects (including the extra camera), and unhide the rest of your scene.
Rendered with hdr image background:
Time: 2:41 (12:08 to render the background at 1920x1080)
Rendered with actual geometry for the outside environment
Note that replacing a 3D environment with a 2D image will not work with animations where there is parallax motion (translation of the camera).