Using an Equirectangular HDRI Panorama to Light a 3D Scene

A few days ago I shared my workflow for creating an equirectangular HDRI panorama, within the post I said that I would share my workflow for using the HDRI as a light source in the 3D environment at a later time. So…

With the panoramic HDR image created, the first thing that needs to be done is to prepare the image for use in 3D. Firstly, the image needs to be flipped horizontally, otherwise it will appear inside-out in the 3D environment.

I then save the HDRI with the name background.hdr. This image will be used as a high resolution background to my scene.

I then resize the image to about 2048 pixels wide and save it under the name reflection.hdr. This image will be seen in the reflections in the scene. As the reflections won’t need to be as sharp as the background, this smaller file size helps to improve render times.

I then resize the image again to about 600 pixels wide and save it under the name diffuse.hdr. This is the image that will be used to light the scene. This much smaller file size will help to significantly improve render times. To improve render quality, I also add a very strong Gaussian blur to the image. This helps to reduce any blotchiness in the shadows of the resulting 3D render.

Reflection

reflection.hdr

Diffuse

diffuse.hdr

With the images prepared I then use a free student version of Cinema 4D to create my 3D scene. Firstly, I create two materials named diffuse and reflection and assign my HDR images to the respective colour channels.

I then create two sky objects. The sky object is a sphere of infinite size that encompasses the 3D scene. I rename one sky object to reflection, and the other two diffuse. I add to the two sky objects a compositing tag each.

In the diffuse sky object’s compositing tag, I disable everything but the GI (global illumination) option. This forces the software to use the diffuse sky for nothing other than global illumination (light).

In the reflection sky object’s compositing tag I enable only the ‘Seen by reflection’ parameters.

I then create a material named background and assign my background image to the colour channel.

Background Image

Background Image

I apply this material to a background object.

I then change the resolution of my output render to match the dimensions of the background image. This is important to make sure everything lines up in the next step.

Next, I create a camera object and adjust the size of the lens and image sensor to match the camera that was used to capture the background image. A quick Google search tells me that the size of the image sensor on my Nikon D60 is 23.6mm. To find out what focal length I used, I right click on my photograph in Windows Explorer and go to the details tab. Here I can see that I used a 20mm lens when photographing the background.

Focal length

Focal length

It is important to match up the image sensor size and focal length in order to make sure that the perspectives of any 3D objects you place into the scene match that of the background.

In this particular scene I measured the filing cabinet and created a cube to match these dimensions. This was cube was needed to provide a surface for catching shadows below any 3D objects I placed into the scene, in this case, the three spheres. The three spheres were created next and finally, I look through my virtual camera and take some time to line everything up.

Overview of 3D Scene

3D Scene

Camera View

Camera View

That concludes the creation of the 3D scene. To get the lighting to work correctly all that’s left to be done is to go into the render settings, turn on the global illumination effect, turn off the default light, hit the render button, and see what happens.

First Render

First Render

I found that in this particular image I had to add an extra light source because the HDRI alone wasn’t bright enough to create sufficient shadows on the filing cabinet’s surface.

Whilst writing this article I also found that adding a compositing tag to the filing cabinet with the ‘Compositing Background’ parameter enabled, forced the cabinet to be self-illuminating. This corrected the problem I was having in previous renders where the saturation in the filing cabinet was being lost.

I also found that this allowed me more freedom to adjust the exposure of the HDR Image which in turn meant that I could remove the artificial sun light I’d created and rely solely on the HDRI sky object. The result of this is a more natural shadow.

Whilst I was at it, following what I’d learnt from my previous observations relating to Fresnel reflection falloff, I also adjusted the reflection on the balls.

Even Better Render

Even Better Render

With an improved render, I think it’s time to make a comparison and talk about the qualities and imperfections that are steering the image closer to, and further from, photorealism.

Advertisements

2 thoughts on “Using an Equirectangular HDRI Panorama to Light a 3D Scene

  1. Pingback: Fresnel Reflection Falloff | Photorealism in 3D CGI Imagery

  2. Pingback: Is Fresnel Reflectivity the Best? | Photorealism in 3D CGI Imagery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s