DigitalTutors_office_bright

What is HDRI and How to Set One Up in Maya

‌‌
Have you ever had the need to get good realistic lighting in just a few minutes? It's not as hard as you think, but it does require a little bit of knowledge on how Maya works. We're going to look at ways to get quick results using HDR images to light a scene in Maya and how to maintain consistency with your textures and procedural shaders.

What is a HDR Image?

In simple terms, HDR images have very dark darks and very bright brights. The whites are whiter than what your 8-bit display monitor can actually display. HDR files are stored using 32-bit float. 8-bit gives you a range of 256 (2 to the 8th power) while 32-bit has a range of 4,294,967,296 (2 to the 32nd power). If we were to look at the range of blues that could be displayed at 8-bit you would have a total of 256 variations of the color blue from start to end that could be stored in the file. If you were to have that same blue scale in a 32-bit file, you would get a total of 4,294,967,296 different possibilities. This would give you overall, a greater range to represent color. [caption id="attachment_38932" align="aligncenter" width="800"]Display of 4 different exposures on and image This image shows you 4 different exposures that were used to create the HDRI.[/caption] For you to create an HDR image, typically, you would need to take a photo of the same scene at multiple different levels of exposure and then combine those photos to create an HDR image with great color depth.

If my monitor only displays 8-bit, how do I know the image I am using is 32-bit?

So you might be asking yourself how could you know if an image actually is 32-bit if you can only view what your monitor can display. And the easiest way to tell would be to open the HDR image in Photoshop. If you don't have an HDR image, then you can jump over to HDR Labs and grab one to test this out for yourself. Once you have an image open, double click on your foreground color swatch located in your tools panel. [caption id="attachment_38931" align="aligncenter" width="800"]HDRI-Foreground Swatch in Photoshop Double click the foreground swatch on the left tool bar in Photoshop.[/caption] This will pop-up the Color Picker info panel, and should look similar to the image below. You can use this tool can be used to determine if an image is 32-bit by picking a color around the hotspots of over exposed whites. Once you have done that, take a look at the 32-bit values. If those values exceed 1 then the image is 32-bit. [caption id="attachment_38930" align="aligncenter" width="800"]HDRI-32-Bit color picker in Photoshop The Color Picker with an over exposed area showing values greater than 1.[/caption]

Why does my HDRI look different than the one you showed?

That is because there are three different types. The image being used in this post is called LatLong or Latitude Longitude file. These resemble an unwrapped world map. LatLong There are also images know as Vertical Cross, Horizontal Cross and Cubic and these are an images every 90 degrees of the scene. VerticalCross The third type of image that you may encounters is called a Light Probe. These usually appear like they are a chrome ball. Lightprobe We recommend using LatLong images because almost all 3D applications support LatLong. Now that you have a general idea of what an HDRI is, lets jump into a quick way you can setup HDR Images inside of maya.

Setting up an HDRI using the Render Settings in Maya

To start off we need to make sure that mental ray is enabled. So, to do that go to Windows > Settings/Preferences > Plug-in Manager. Scroll through the list and look for Mayatomr.mll make sure the Loaded check box has been checked, if not then do so. This will allow you to render your scene using mental ray. [caption id="attachment_38929" align="aligncenter" width="800"]HDRI-Enable mental ray in Maya Enable Mayatomr.mll in the Plug-in Manager to access mental ray for rendering.[/caption] Once you have verified that mental ray is active, open up Render Settings for the scene. On the drop down box labeled Render Using mental ray. Once that is selected you will see some new tabs pop-up. [caption id="attachment_38928" align="aligncenter" width="800"]HDRI-mental ray tabs in Maya render settings Using mental ray will add more options to customize rendering settings.[/caption] Once we have mental ray selected, click the Indirect Lighting tab. You should see things listed such as Environment, Global Illumination, Caustics, Final Gathering, etc. We want to click the Create button next to Image Based Lighting. This will create an ibl shape and will be where you attach your HDR image. You can preview what was created in the Hypershade under lights. [caption id="attachment_38927" align="aligncenter" width="800"]HDRI-Hypershade showing ibl You should see similar nodes mapped for the ibl shape in Maya Hypershade.[/caption] Double click on the mentalrayIblShape1 node to view the attributes. Under Image Base Lighting Attributes, find the field titled Image Name. This will be the location of your HDRI, so click on the folder to the right of the field to navigate to your image. If you press 5 on the top row of your keyboard to see the shaded view, you should see a sphere with the HDR Image mapped. [caption id="attachment_38926" align="aligncenter" width="800"]HDRI-mapped HDRI This is what the ibl should look like after you map the HDRI.[/caption] This is the basis of setting up the HDR. But let's setup a quick test to preview what the indirect lighting will look like. To do that let's setup our scene so that it's close to real world measurements. Natively, Maya uses centimeters, so know that lets increase the grid size to emulate meters. To do this go to Display > Grid and click the options box. Set the length and width to 10000 units and set the grid lines every 100 units. This makes every square of the grid represent 1 meter. So every square is comparable to 3 feet. This will help you get you scene closer to real world scale. [caption id="attachment_38925" align="aligncenter" width="800"]HDRI-Maya Grid Settings Update the grid size to better represent real-world settings.[/caption] Next let's look at creating 2 spheres and a plane. We''ll apply two different shaders to these sphere so help tweak our lighting settings. It's good to note that because we are working in centimeters any primitive that you create will be really small, so you will need to scale them up after you create them. [caption id="attachment_38924" align="aligncenter" width="800"]HDRI-Spheres in Maya Create two spheres to be used in refining your HDRI settings.[/caption] Lets create two different shaders, a matte grey and a chrome to apply to these two spheres. Open up the Hypershade and search for mia_material create two seperate mia_material_x shaders. Double click the first material and look at the attribute editor. Go to Presets > Chrome > Replace. This will create your chrome shader. Do the same thing on the other mia_material_x except this time go to Presets > MatteFinish > Replace. Apply the Matte material to one sphere and the chrome material to the other. This can be used by you for a couple of different things. One would be to make sure you scene is being lit correctly. If the render looks over or under exposed then something is incorrect. You can also use the chrome sphere to make sure the HDRI is correctly mapped to the ibl or you could use it to place key lights corresponding with the position of the HDRI. If you would like to learn more about HDRI lighting be sure to check out the course by Jon Tojek Using HDR Images for 3D Lighting in Maya and the course by Kyle Green on Linear Workflow Rendering Strategies in Maya.