Create
your own HDR environment map in Maya/mental ray for image based lighting
Requirements and Downloads
You need the latlong_lens
mental
ray lens shader (latlong_lens.zip)
.
As an alternative, you can render cubic environment maps with the cubemap_lens shader where the same
principles apply (cubemap_lens.zip).
Example scene on how to use the shader, including the rendered HDR
image (example_scene.zip).
In order to view and edit HDR images HDRShop
comes in
handy .
Introduction
This tutorial shows how to create a HDR environment map for image based
lighting from a Maya scene. This is a software only
approach so no equipment is needed. Additionally, the
latlong_lens shader can also be used to create environment maps for
games,
panoramic views etc.
Camera and Render Settings
Shader Installation
Follow the install instructions of the latlong_lens shader and it
should show up in the Hypershade:Create->mental
ray Lenses tab.
This lens shader enables one to render out a full
360°/180°
view of a scene in latitude/longitude format.
Camera
First, we need our own camera with a latlong_shader attached to it:
Goto Create->Cameras->Camera
to
create one (latlong_camera would be a good name).
Open the Attribute Editor of that camera and add a
latlong_lens
node in Attribute
Editor:latlong_camera-> mental ray->Lens Shader.
(The required shader is in the Create
Render Node:mental ray->Lenses
tab).
Because we want to use the output for image based lighting, we need to
flip the output. We can do that in HDRShop or simply check Flip
Horizontal
in the latlong_lens node. (The reason for this is because the image
gets
projected on a sphere that is viewed from the inside.) If you want to
use the output for a panoramic view, leave this option unchecked.
Render Settings
In Order to get a HDR image, switch in the Render
Global Settings to mental
ray, set Common->Image
Format
to HDR(hdr) and Common->Camera
to the
latlong_camera. Latitude/longitude images usually have a width/height
ratio of 2:1, so set Common->Resolution->Width/Height
to something like 512/256 or 1024/512.
In the mental
ray->Frame Buffer
Attributes, switch
Data Type
to RGB
(Float) 3x32bit to get
the frame buffer attributes right.
Building a HDR Scene
This part is a bit tricky since we need to create a scene that
represents the high dynamic range of the real world. Another problem is
that lights will not show up directly since they are not rendered
geometry.
But one can "model" light by creating geometry with a material on it
that has a very high value of incandescence. Of course, the size of the
modeled light sources has an impact on the overall intensity.
I wont describe how to build a scene in detail, simply create a floor,
sky, objects and objects intended as lights.
For a primary light for example, create a rectangle and assign a
lambert shader with a Incandescence
color of (rgb
15,15,15) to it.
If you turn final gather on, this rectangle will also illuminate the
scene. It is not necessary to use final gather/GI in a scene, only the
shaders need to
be aware how they illuminate. If the scene is too dark, normal lights
can be used to light the scene as well..
If you already have a well lit finished scene, my little bit of try and
error showed that it is sufficient to model the primary lights with
simple geometry and assign high values of incandescence. Other light
influences such as bright walls can be simulated by pulling up the Color
attribute of the assigned
shader to values like (rgb 2,2,2).
A good idea is to look up color values in real life HDR environment
maps you can get from http://www.debevec.org/Probes/
Load them into HDRShop, move the mouse over the image and look for the
color values of the current pixel in the status bar.
To give you an idea of what kind of colors and intensity values are
applicable, here is a small list as rgb colors I pulled from some HDR
images:
Primary Lights
- Window with direct sun :
130.0 125.0 126.0
- Bright sky: 4.6 6.8 9.7
- Indoor lamp : 6.4 4.1 2.4
Secondary Illumination
- Bright wall: 1.5 1.5 1.3
- Wood table: 0.54 0.34 0.25
- Grass: 0.12 0.2 0.1
As you can see, secondary illuminations from ground, floor etc. are
usually in the range of normally used colors.
An example scene (example_scene.zip)
is
provided to show how it works.
Rendering
Move the latlong_lens camera to the position your want to take the
environment from. This should not be too close to objects in the scene,
otherwise the perspective error is too high. The camera can be moved
and rotated freely, but if you leave the rotation untouched, the
rendered HDR image will be in the correct rotation if you use it in the
Image
Based Rendering option of
Maya/mental ray.
To render the image, set a name in
Render Global Settings:Common->File Name Prefix and
render it via Render->
Batch Render.
It is important to render in batch since the Render
Preview can not
output
.hdr images.
Here is what you get from the example scene at different exposures:

original exposure

-2.0 stops

-4.0 stops

-6.0 stops
Image based lighting
Now you can use the rendered HDR environment map as any other. Here are
some test renderings with the map from the example scene using the Render
Global Settings:mental
ray->Image Based Lighting
option.
Only the environment map illuminates the scene, the setting is PreviewFinalGather:
Conclusion
Ok, thats it. It is quite tricky to find the right shader values to get
pleasing images, but a little fumbling around can probably get some
nice results.
If you have comments, found errors or rendered some nice HDR
environment maps you want to share, please do not hesitate to contact
me.
Ralf
Habel
email:
ralf.habel@@@vi-motion.de
(remove two @)