How to Render Glass in Maya and Mental Ray

Physically Accurate Glass With Mia_material_x

Hi folks, and welcome back to our shader recipe series, where we tackle materials and surfacing using Maya and Mental ray.

In this installment, we'll be building a glass material using Mental Ray's Mia_material_x shader. Let's get down to business!

01
of 04

So how do we go about creating glass?


If you're relatively new to Maya and don't have a lot of experience using the Mental Ray renderer, your first impulse might be to grab a standard Blinn material and bump up the transparency until it's relatively clear.

This works as a viewport stand-in when you're blocking out your image, but Maya's software shaders are typically unsuitable for physically accurate rendering.

To create our glass, we'll be using a versatile Mental Ray shader called mia_material_x.

02
of 04

The Mia Material


Mental Ray's MIA shader is an all purpose material network designed to be a physically accurate solution for just about any inorganic surface you can imagine (i.e. - chrome, stone, wood, glass, ceramic tile, etc., etc.).

The mia_material_x node should form the basis of virtually every material you build in Maya, aside from skin shaders where you'd be better served with one of the Mental Ray SSS (subsurface-scattering) templates.

To find mia_material_x, open the hypershade window → click on the Mental Ray tab → choose Materials → and select mia_material_x from the list.

The standard MIA shader is a neutral gray with a sharp specular highlight. Let's begin exploring how we can customize the shader to simulate glass.

03
of 04

Customizing the Mia Material:


Go ahead and set up a test scene with a basic piece of geometry (we're using a wine glass), and some simple studio lighting (a few area lights with soft shadows will do the trick).

The mia material has a huge array of options—some of them will be important to us, but a lot of them we can ignore. Arriving at a basic glass shader is actually relatively simple—things only begin to get tricky when we need to fill the glass with a liquid.

Here are the parameters that need to be dealt with in the creation of a glass material:

  1. Diffuse:

    We're creating a colorless, clear glass, so our job in the diffuse tab is incredibly straightforward. Diffuse light is what gives a form its surface color—because this type of glass is completely clear we have no need for any diffuse reflections in our shader.

    Under the diffuse tab, change the value of the weight slider to zero.
  2. Refraction:

    The refraction tab is where we'll deal with the glass material’s transparency value.

    The first thing we need to deal with is the index of refraction parameter, which actually corresponds to a relatively specific real-world index of refraction value that exists for all naturally transparent surfaces.

    If you hover over the index of refraction tab, a small list of approximate values for different materials will pop up. Water has an index of refraction around 1.3. Crown glass has a real-world index of refraction at approximately 1.52. Set the index of refraction to 1.52.

    The last thing we need to tweak in the refraction tab is the transparency value. We're creating a fully transparent glass shader, so let's set the transparency value to 1.
  3. Reflection:

    The reflection tab determines how much of your glass's environment will be reflected in the final render. Glass, despite being clear, should have a high amount of glossiness and reflectivity.

    Leave the glossiness value at 1.0, and change reflectivity to a value somewhere between .8 and 1. A little bit of subjectivity is okay here, depending on the look you want in your final image, but the reflectivity value shouldn't really drop below 0.8.
  4. Specularity:

    If you do a test render at this point, you'll see that we're getting fairly close to having some decent looking glass, but there are still two attributes we need to deal with.

    If you compare our current result with a real world wine-glass, you'll see that the surface is currently a bit too busy to be called realistic. Right now our mia_material is reflecting the environment (good), but it's also computing glossy reflections based on specularity (bad).

    Specular highlights are a bit of a holdover from earlier days of CG when glossy reflections needed to be “faked.” It's still an important attribute in CG surfacing, however in this case it's giving us a less realistic result than we'd like to see—we want to retain our reflected environment but lose the specular-related highlights that are currently showing up in our renders.

    Find the specular balance attribute under the advanced tab and set it to zero.
  5. Fresnel Effect:

    Right now the surface of our glass is displaying uniform reflectivity, when in reality we should be seeing weaker highlights where the glass faces the camera and stronger highlights toward the edges where the glass curves away. This is called the Fresnel effect.

    Because the Fresnel effect is a relatively common phenomenon, the mia_material has a Fresnel attribute built into it. All we have to do is turn it on.

    Open the BRDF tab in the material attributes window, and check the box labeled Use Fresnel Reflection.

    As you can see, the result changes quite a bit. The reflections on the front of the glass are toned down, we're getting a more defined edge around the silhouette of the model, and the section where the stem meets the glass itself appears a bit more coherent.
04
of 04

Conclusion


So that pretty much does it!

Before I leave you, I want to call your attention to one more thing.

The mia_material_x actually has a glass preset called solid glass, which is very, very close to the shader we just created. In fact, it's close enough that it's probably good enough for most of your needs.

The reason I waited until now to mention that there is a glass preset in Maya is that it's always good to know how something is made. By creating the shader yourself, you learn which attributes are contributing to different aspects of the shader itself, and you're therefore more able to tweak the shader to your liking in the future, or create variations on it for slightly different effects.

That said, if you do want to use the glass preset, simply open the material attribute window for an mia_material_x, hold down the preset button in the upper right corner of the window, go to solid glass → replace.