Create your own HDR environment map in Maya/mental

Report this File

Render1

Views:

91,675

Updated:

Jan 30, 2010

Readership Level:

Basic

Tags:

Maya Versions:

5.x, 6.x, 7.x, 8.x, 2008, 2009

Platforms:

linux, mac, windows

Owner:

Language:

English


example_scene_pan.jpgrender1.jpg


Requirements and Downloads

You  need the latlong_lens mental ray lens shader (latlong_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_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 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:

example_scene_pan.jpg
original exposure

example_scene_pan_2down.jpg
-2.0 stops

example_scene_pan_4down.jpg
-4.0 stops

example_scene_pan_6down.jpg
-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:


render1.jpg

render2.jpg

render4.jpg


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

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.

_



Comments

Dashboard_avatar
Jan 31, 2010
Post id: 10013
Report this comment to moderators [SPAM]

mast hai

Dashboard_avatar
Feb 11, 2010
Post id: 10136
Report this comment to moderators [SPAM]

Hi!
I tried the latlong_lense_shader, but if i render the example_file via the batch_render i just get a "normal" view of the rendering.

I'm using maya2009/x64

Greets

Dashboard_avatar
Feb 15, 2010
Post id: 10164
Report this comment to moderators [SPAM]

Alternatively to the latlong_lens shader, one can use the spherical map shader in
this shader collection:

http://www.atomlabs.org/asdn/mentalray/mrsl/lens/lensl_index.htm

Dashboard_avatar
Feb 22, 2010
Post id: 10236
Report this comment to moderators [SPAM]

Can someone post an example of how my maya.rayrc should look. The instructions aren't great as to how to get this shader working in maya.

thanks

Will.

Dashboard_avatar
Mar 16, 2010
Post id: 10521
Report this comment to moderators [SPAM]

Another way you can make the spherical map is to use the Mental Ray transfer maps function. This makes it easier to remap one surface shape to another.

Dashboard_avatar
Jun 29, 2010
Post id: 11659
Report this comment to moderators [SPAM]

It didnt work for me with maya 2010

Dashboard_avatar
Mar 29, 2011
Post id: 14168
Report this comment to moderators [SPAM]

Hello.
How can I get longitude format=180°/180° instead of 360°/180°?
Is there a MR lenz shader of it?

Thanks.

Dashboard_avatar
Oct 13, 2012
Post id: 16961
Report this comment to moderators [SPAM]

Thanks Ralf,

This is awesome. So many uses. Having the source makes it usable.

Write a Comment

You must be logged in and have verified your email address to leave a comment. Login or create an account