Infusion Studios

April 30, 2015 Intro to Photo-real Rendering with 3DS Max and Mental Ray Posted In: Blog, Tutorials

DELOREAN_GRADE_C

After years of promising a Mental Ray tutorial I’m finally getting around to it! Ironically I am doing most of my work with Vray now, but Mental Ray is still a great engine! I think it’s important to learn to push the limits of the tools built into 3DS Max before jumping to 3rd party render engines and plug-ins. Also, though I call this an “Intro” this doesn’t mean this tutorial is specifically for beginners. It can be, but this info is equally useful to seasoned artists. I go step by step so you should be able to produce very similar results, though you can also download my final 4K render and After Effects comp if you just want to skip the scene setup in Max. Anyway it’s a long one, but should be a good time!

We’ll be rendering this cool exterior shot of the always classy ‘81 Delorean. The goal here is to get you creating reasonably “Photo-Real” renders as quickly and simply as possible using only a Plate image (background photo) along with a Spherical HDRI for an IBL (Image Based Lighting) setup. In my opinion this is the first kind of rendering exercise new CG artists should take on. It allows you to focus on the photographic aspects of rendering before worrying about complex light placement, color etc. Also working a CG render into a photographic plate will reveal anything that looks off with your model, exposure and materials. The idea is to make the CG sit nicely into the plate with proper lighting, reflections and shadows. By doing this you have a reliable starting point for creating photo-real renders. So let’s get started!

Resources you’ll need:

HDRIs & Plates, #3 is the one you want. (SMCARS.NET)
Delorean Model (VizPeople.com)
Download My Final Render + Passes and After Effects File
Material Library File for my Delorean Materials

Acquiring the Plate, Spherical HDRI Images and Car

First task is to find a decent plate image and Spherical HDRI to work with. The Plate is your background image and the Spherical HDRI will be used for lighting and reflections. There are numerous places to grab some free Spherical HDRIs, the trick is finding a resource that also provides plate images shot at the same location so there is complete continuity between plate and IBL. For this Tutorial we’ll be using HDRI Pack #3 from the folks at SMCARS.NET I’m not posting files directly here so you will want to go over to their site and download the pack. The plate I’ve chosen is IMG_7375 and we’ll use the full 15K Spherical HDRI seen below.

Plate
IMG_7375Spherical HDRI
HDRI_003

The Delorean model can be downloaded from the kind folks at Vizpeople.com

Before getting into Max and setting up our scene we’ll also want to throw the HDRI into Photoshop, hit ALT-I and change the resolution to 5000 Pixels wide. Be sure to Save As rather than overwrite the 15K file. We will use the 5K HDRI for our lighting and the 15K file for Reflections. The reason we make a reduced version for lighting is that more detail in the lighting can create more noise which is undesirable. We likely could reduce it down to even 512×512 and still get decent detail in the lighting.

PS_HDRI_Reduction

3DS Max Scene Setup

We’ll be working in Max 2015 here, but the Mental Ray settings will be valid for Max 2014 as well. For pre-2014 you would need to have revealed hidden functionality such as IBL which I won’t be covering here.

Render Settings

RenderSettings2

Ground Plane

vp_GroundPlane

HDRI Light

vp_HDRI_Lightslate_HDRI_Light

Background Plate and Environment Reflection Setup

slate_Environment&light

Enviro_EnvironmentMap

vp_Perspective_Background

Camera Setup

Obviously our point of view is all wrong for this plate, so we’ll need to setup a camera to reasonably match the angle of the original photo. No magic here. I’d normally use the Perspective Match tool in the Utilities Panel, but it relies on there being numerous parallel and perpendicular elements in your image for matching XYZ Vanishing Points so it’s no good here. Even our road parallels aren’t straight as we are on a curve. So I recommend just doing it by eye.

vp_camera_match

 Initial Test Render

Before bringing the car in I think it’s a good idea to do a little testing and finish setting up the Camera Exposure and Shadow Matte.

vp_Teapot

Slate_ClayMaterial

RS_Override

render_Clay1

Pretty amazing right!? Well maybe not, but it does tell us a few things right off the bat.

  1. Our exposure isn’t quite right, so we will need to do some work there.
  2. We are getting soft shadows from our HDRI Light which seem consistent with what we’d expect this late in the day so that’s working for us.
  3. The color temperature of the render is perhaps a little too cool. Well fix that along with exposure in a moment.

Exposure

Ok, I have to preface the next section by saying exposure is sort of a pet peeve of mine. I really don’t like being forced into using nonsensical exposure values. All the major render engines have the ability to use proper camera exposure and when using physically based lighting and shading why wouldn’t you?? Well when it comes to HDRIs there is no standard for pixel intensities so you have to either accept crazy exposure values to make it work or boost the skylight (though that does nothing to correct the reflection intensities), or use some other method to get the pixel values high enough for reasonable exposure values to work. I’ll show you what I mean. Lets go ahead and turn on the mr Photographic Exposure Controls found in the Environment and Effects Dialog (8 key).

Enviro_Exposure_1

These are all default values, but you know, defaults can be good right? Let’s hit Render!

render_Clay2

Oh crap, we broke it!! Sort of, we really just have a mismatch in pixel intensities in our HDRI and the exposure values. Our default exposure values are more appropriate for high noon sun on a crystal clear day and our pixel intensities are mostly under 1.0 which makes them very dim for any kind of light source. Now how to correct for this or whether to use exposure at all varies artist to artist and everyone has their reasons for their individual approach. You could boost the exposure of the HDRIs in Photoshop, you could drop the exposure values way down, you could use non-physical exposure and so on. My personal approach involves boosting the pixel values of the HDRIs from within Max combined with adjusting our exposure values to something more like what you would use to capture this image out in the real world. Here’s how we do it.

Let’s go ahead and set our exposure values to something more reasonable. If you’re not familiar with manual camera exposure spend a little time with this great exposure education tool by Canon. Here’s the settings I’m going with.

Enviro_Exposure_2

So Exposure is setup, but that’s only half the battle. If I were to hit render now, things wouldn’t look much better than our previous test. So now we need to boost those pixel values for the HDRIs and the Plate.

slate_Boost

Now let’s hit render (F9) again and see if things have improved.

render_Clay3

Yay! It’s fixed! But wait, aren’t we just back sorta where we started before all that exposure stuff? Yeah, sort of, but now can adjust exposures with real world values and get predictable results. Also you can see that our 3D objects are a bit brighter than the initial test and are a bit more accurate to the lighting in the scene. Remember, because we boosted both HDRI maps and Plate our reflections will be naturally balanced as well. You’ll see in a minute. First let’s deal with out big gray ground. We really want that ground plane to only catch shadows, but otherwise be invisible. Here’s how we do that.

Shadow Matte Setup

Slate_GroundPlane

Now hit Render!

render_Clay4

It works! I know that was a lot of node wrangling in Slate, but it was worth it. Now a couple observations:

  1. Our 30′ x 30′ ground plane may not be big enough to catch the entire shadow.
  2. Our shadow, though subtle, does have a direction to it and appears to be cast from a strange position considering the remaining sliver of sun is not actually behind the teapot. If we look at the Spherical HDRI it appears to be to the right of camera. We’ll need to rotate our HDRIs for that.
  3. Our Clay material has been helpful to this point, but we may want to try out a mirror ball type material next to see how reflections are working.

Here’s my analysis of the Plate relative to the HDRI in regards to sun direction etc.

PlateLocation

So based on this we need to rotate our HDRI’s to better match the actual position of the camera which shot this plate.

Slate_Chrome

renderChrome

Ok, now we’re getting somewhere! HDRI Rotation seems to match up pretty well now in terms of both the reflection and the direction of the shadow cast. I think we’re ready to drop in the Delorean!

Working in the Delorean

VP_Delorean_ImportNow I can see that my camera is a little too close as the car measures just over 16 feet long and the typical road lane is somewhere between 8 and 11 feet in Europe (this plate wasn’t shot in Kansas).

Here’s how my new camera and car position look now.

VP_Delorean_FinalPosition

LAYERS

Before we get into materials let’s turn on our Materials Override under the Processing tab and see how our lighting looks on this classic machine! (Ignore any bitmap warnings at this point)

render_Clay5

Ok, looks like all that teapot work paid off. We’re getting some really nice warm Key lighting from the setting sun and cool Fill light from the sky along with decent contact, ambient and subtle key shadowing. Now to tackle the all important automotive materials!

Materials

A few things about materials in Mental Ray. First, I tell anyone who will listen, never ever use the Autodesk Material Library. Not if you’re serious about understanding how to create efficient, high quality materials. The AML materials are just watered down and inconsistent compared to the Arch & Design material. If it’s the provided textures you’re after you can access them directly in the \Program Files\Common Files\Autodesk Shared\Materials\Textures\ folder. There are a ton of useful textures in there, but you are always better off feeding them into an Arch Design Material. Trust me on this. Second, avoid Standard materials entirely! Just because they work with Mental Ray doesn’t mean they are good for use with Mental Ray. Same goes for Vray actually. Get to know the Arch & Design material and you will very rarely need anything else short of SSS and Car Paint materials.

Also, considering the depth of the subject I won’t go into great detail on each material for the Delorean. I’m actually going to do you a solid and simply give you a material library you can load up in Slate and slap on the car. Though this is mostly to save you the hassle of going element by element through the collapsed mesh to figure out what each material is supposed to be. You see, the materials aren’t named so it’s a bit tedious cleaning that up. Good time to say this, ALWAYS NAME YOUR MATERIALS!!! Always! That said, this is a gorgeous FREE model so I only have love for the folks at VizPeople despite their lack of material naming.

Here’s the Material Tree after I’ve renamed and reworked all the materials into Arch & Design mats.

Material_Tree

So go ahead and download my Delorean Material Library here.  

Slate_Matlib

Render_Delorean_1

Looking good! Now that’s a big cheat jumping right to finished materials, but this tutorial is already a mile long so I’ve gotta cut corners somewhere! Don’t worry, I’ll touch on the Stainless, Glass, Chrome and Black plastic materials. What jumping ahead like this does allow is for us to quickly address a BIG issue specific to the Stainless and our particular HDRI setup. Notice all the noise in the stainless material around our very pretty highlight on the driver side of the car? This is caused by the extreme contrast found in the HDRI, which is after all why we use HDRIs to begin with. Basically the setting sun’s pixel value is so high it’s causing noise issues on materials with low glossies, but very high ref;lectance such as our stainless steal.  This is the thing of render nightmares as it is not so easily fixed as you might imagine and can result in lots of cursing and hair pulling. How to fix it? Up the glossiness samples you say (we’re at 64 already)? Sure you could go to 256 and still see almost as much noise. Up the Quality of the Unified Sampler? Yep, you could do that too, but that is overkill via crazy high sampling for the entire image. Now, there is a method by which we can completely fix this noise and actually render just a little faster! It does mean contradicting some of our previous work though. That’s ok, that’s what optimization is all about!

We’re going to utilize Mental Ray’s Environment Blur map. This essentially reduces the input resolution of the HDRI while also doing a pre-blur which is driven by the glossiness value in the Arch & Design material. This will smooth out our noise problem while also optimizing render-time slightly. Now it appears contradictory to take a 15K HDRI and feed it through what is essentially a 2K blur node. To save on ram we could just us the 5K HDRI or create a dedicated 2K HDRI, but I believe keeping the highest level of pixel data right up until the moment of sampling is best whenever possible. Just my opinion though. So here’s how we do this.

Slate_Envblur

Now hit Render and behold.

Render_Delorean_2

Like magic the highlight on our stainless is wonderfully smooth! Now let’s get into some of these materials!

Stainless

Here’s our most important material in the scene. I have highlighted the important bits below. Note there is a subtle brushing texture controlling both the Diffuse and Reflection Color. At .5 Glossiness this created pretty blurry reflections which is why we have boosted the samples to 64. Typically I try to stick to 32 and under to avoid longer render-times, but very soft reflections demand high sampling. I also opted for a Custom Reflectivity Function as apposed to going By IOR and boosting the value to say 24 or so. Just a matter of preference. The IOR is likely more accurate, but this looks pretty good too. Metal Material is of course checked and lastly Anisotropy is turned up a bit to .15. I have also set a Material ID of 1 so I can isolate this material in post. In fact many of the materials have IDs on them already so when you render out the Material ID pass you should see a variety of mattes there.

Material_Stainless

Glass

This is the Glass for both the windshields. The headlamps use a similar glass, but have a bump map for the modeled plastic of the headlamp. Just basic clear and refractive glass which requires a modeled thickness to work correctly. Black Diffuse, Full Reflectivity, IOR of 1.6, Fully Transparent and a slightly blueish Transparency color. Also, though not seen in the image below you will want to go in the Advanced

Material_Glass

Black Plastic

This is a basic Semigloss Plastic. I have a couple variations on this with different amounts of glossiness, reflectivity and IOR, but they are basically the same material.

Material_BlackPlastic

Chrome

A simple chrome. Mostly you see this in the headlamps reflector. Full reflectivity. White Diffuse because Metal is checked. You could have a black diffuse and uncheck Metal, your choice. Using a Custom Reflectivity Function again at .9. For true mirror you could go to .99.

Material_Chrome

Ok, so you can see the Arch & Design material is very diverse and relatively simple to use, though we’ve only touched on some pretty simple materials. Also notice that aside from the Stainless, Glossy Samples are kept way down around 8. Only boost it higher if you really need to. Go through all the materials in the tree and take a look at what makes them tick. Also the help in 3DS Max has a great section on what each setting does with rendered examples. Now onto creating the composite!!!

Compositing

Wow, almost done! This is a marathon of a tutorial! Sorry about that. I just like to try and explain why I’m doing what I’m doing. That’s the most important part really. Now we get ready to bring our ’81 Delorean into After Effects and do some comp and grade type stuff! But… First… More messing around in slate. Ok, first lets decide something. Are we going to render the car and plate together and treat it as one image or are we going to keep the background and foreground separate? Together is simpler, but I’m going to show you of course the more complex option. We’ll render the car on black to retain a properly multiplied alpha yet still have all our reflections etc along with our Render Elements. After that we head over to After Effects to put it all together.

Render_AlphaOuch, not what we want. Then entire ground plane has a solid Alpha. We want just the shadows so that the car will comp nicely ontop of the plate in After Effects. What to do? There are actually no options in the Matte/Shadow/Reflection material to do this unlike Vrays negative alpha setting, so we have to be a little creative. Do the following.

Slate_Plateless

Render_RGB&Alpha

You can see that now only the car remains. I have split the RGB / Alpha display so you can see that only the car and shadows appear in the alpha channel. This is what we need if we’re going to simply drop it on top of the plate in After Effects.

Final Render!

At this point we’re ready to do our final render. So let’s bump the resolution up to 3840 x 2560 (4K at 1.5 aspect ratio). Turn on your desired render elements, select where to save your files being sure to use the OpenEXR format for output. Hit render one last time and go take a walk or get a coffee or something!

You should end up with something like this. Note I’m only using a Reflection, Material ID and Object ID pass. I ditched the Zdepth as I’m not going to be using it in our comp today though it’s usually a good idea to have one.

DELOREAN_FINAL_RENDER_4k

DELOREAN_FINAL_RENDER

Now that we have a 4K render you can zoom in and see the fine details of the brushing on the stainless, normal maps on the tires, bump maps on the headlights etc that just weren’t easily seen at the lower resolution. We also have our bunch of passes. Onward!

Compositing in After Effects

This part will be short, I promise!! I’m not going to get into all the subtle effects and grading as I’d rather focus on just a few key points. For the rest I’m providing my AE file and final renders so you can play with it and pick the comp apart yourself. You can also check out my two After Effects grading video tutorials here Part I Part II.Now you might wonder why not do this comp in Photoshop? You could, but as Photoshop is pretty horrible at dealing with 32-Bit files and After Effects is great at it our choice is clear. So let’s go ahead and launch After Effects CC.

AE_ProjectSettings

This setup will allow for any pixel math to be correct where as working in 8-bit creates incorrect pixel values. BTW, this is what they call a Linear Workflow which I suggest making your standard workflow.

This is where you should be at.

AE_Comp1

So the only thing to do now really is drop in our Plate image and adjust it’s scale to match the render output size.

Boom! Just like it looked in Max!

AE_Comp2

Now it’s time to bring the noise. Yes, we need to add some noise and a hint of blur to our CG stuff as that’s what you find in ALL photos and videos. So we’ll zoom way in on the bumper to take a look at with and without noise. Clearly the CG stuff sticks out as too perfect compared to the plate. The noise / blur help add some imperfection back in. Subtle but important. The settings can be taken from the GIF below. The 2.3% setting is a bit stronger than what we ultimately want, but I wanted the difference to be clear here.

AE_Noise

Where one goes from here is completely subjective and I won’t go much further into it here, but let’s just get our feet wet with the Material ID pass and make some tweaks to just the stainless material. In the AE file I provide you can explore a few different comps with different grades setup.

Using Matte Passes (Material ID)

AE_Comp3

Stainless_Curves

From here I leave it to you to play around and see how you might change the look of the render. Remember, most any professional car photograph you’ve ever seen went through some sort of post process / grading. Even the reality the camera captures is often only the beginning of the process. Below are 3 examples of different grades one might create side by side with the original render. It’s all a matter of taste. These 3 are pretty tame compared to where you could take it if you wanted a very moody look, or perhaps imply aged film etc or even do a day for night look. These 4 comps are all setup in the AE file you can download here.

DELOREAN_GRADES

This concludes this rather lengthy tutorial introducing photo-realistic rendering with 3DS Max and Mental Ray. Hope it was helpful and know that ultimately all the major render engines today use basically the same techniques so anything learned here is mostly transferable to other engines / 3D Packages. Thanks for hanging in there and go play!