Blog Archives

The Layering Library (MILA) UI: BETA SHADERS

*These materials have been released for Maya 2015. The below post applies to the Beta shaders. There have been changes to the materials and SIGNIFICANT changes to how they are presented/integrated inside Maya 2015. Please see the newer posts on these.*

Shaders were previously announced for future beta here and have been released today.

Below are the UIs and brief descriptions of the various parts of the Layering Library known as MILA. More complex examples and Phenomenon© will become later posts. But this should get you started on the basics. The next post will show how to create framebuffers in Maya using the legacy user framebuffer mechanism. Since framebuffers are simply named and built-in, it makes for easy rendering without making connections in Maya.

This library is currently designed as a flexible replacement for (at a minimum) the fast_sss, metalllic paint, car paint, and mia_material shaders. (You should have hopefully abandoned Lambert, Blinn, Phong, etc quite some time ago in mental ray. . .)

This begins the bridge to more modern flexible rendering by following the nVidia Material Definition Language. You may find this a little familiar if you have used the iray layered material.

The image below is rendered from the Unified Sampling post with MILA: glossy reflection, scattering, and diffuse reflection. The lighting is Environment Lighting Mode and final gathering. Depth of Field and image rendered brute force with Unified Sampling.

MILA multi-threaded scattering at work

MILA multi-threaded scattering at work

The shaders introduce several important things:

  • Built-in framebuffers handled by the root node.
  • Better importance sampling
  • Improved glossy reflection with a default linear curve
  • Scattering node that no longer uses a pre-process or lightmapping phase and is multi-threaded
  • Default physical correctness and energy conservation (without the emission node) regardless of layering/mixing
  • Shared light loops that improve performance when layering shaders
  • Framebuffers that provide a mathematically correct workflow in compositing by outputting additive passes
  • Framebuffers that introduce you to the Light Path Expression grammar and concepts
  • Correct lighting scale without need for 1/pi multiplication with modern lighting like the user_ibl_env and the Native IBL
  • etc.

Why use MILA? Beyond their forward looking design there are some more logical reasons to use these shaders.

These shaders free the developer and artist in a few different ways.

For developers using the MILA API, you can create your own components to share in the framework. This means you can create and update a component at a time. By building phenomenon from the networks, your updates and additions can be made immediately available without coding and compiling multiple monolithic shaders. Debugging individual pieces can also be easier and faster before creating a phenomenon.

For artists it introduces better performance, more flexibility, and a workflow designed for future shading and lighting. While all the components may seem tedious to begin setting up in Maya, these can be Phenomenized easily. This means shaders can be used and shared as Phenomenon over and over again with a simplified UI. For example: opaque objects do not require shaders with controls like “refraction” or “translucency”. You can greatly reduce the control set and expose what you need, even setting your own defaults for specific materials to re-use later. (Some useful Phenomenon come with the package)

Caveats in Maya for the Beta:

  • These are not integrated shaders by Autodesk as yet, these are as-is
  • Maya does not automatically connect Shadow and Photon shaders to the mila_material node
  • Components make their own unnecessary Shading Group at creation. They are easily removed by using “Delete Unused Shaders” from the Hypershade menu
  • Some convenient global features like per-component samples rely on String Options (found in the miDefaultOptions and explained here)
  • The automatic creation of the UI from the node factory (.mi files) may have errors, these need to be discovered during the Beta
  • Shader updates may break previous scenes saved with MILA shaders
  • Use area lights for lighting!

Some of the above problems can be solved through UI creation with mel. As part of the Beta, you can collaborate on useful AEtemplate and presets for the nodes.

The main components of the node follow a familiar pattern for those of you used to either the DGS material or iray.

From the docs. © nVidia

From the docs. © nVidia

Diffuse Reflection and Transmission

Glossy Reflection and Transmission

Specular Reflection and Transmission

(Scattering is handled separately as well as emission)

Below is an example from the documents on a possible layering scenario at two levels. Keep in mind that layering and mix nodes can also be plugged into one another. This makes layering easier when you need to combine effects or re-use networks you have already built as part of another network.

A one-level layered network from the docs. © nVidia

A two-level layered network from the docs. © nVidia

As I explain some components I assume a familiarity with the mia_material as some of those settings and concepts are repeated here. So instead I will touch on things that have changed or are new.

The mila_material node: This is the root node of the network.

mila_material root without added buffers

mila_material root without added buffers

  • Visibility: this is like the “cutout opacity” of the mia_material

The top shader connection is meant for a layer or mix node explained below.

This contains the built-in framebuffers and a way to expose them at render time by showing them in the primary buffer using the “Show Framebuffer” integer. In Maya this can be enumerated in the .mi file to make the UI more intuitive.

The additional “Extra” framebuffers can be specified here to run other shaders and utilities when the shader is executed. An example would be an Extra Color for a label or ID pass used in compositing.

The mila_layer node: Used to layer components, other layer nodes, and mix nodes together.

Fresnel weighting of diffuse colors

Fresnel weighting of diffuse colors

Below is the default empty node with the familiar “Thin Walled” parameter from the mia_material

The default Layering Node

The default Layering Node

The below example has a single top layer added. Each new layer added is beneath the previous layer when it is rendered. (Top – down design)

Multiple layers with different weights and selective bump mapping applied.

Multiple layers with different weights and selective bump mapping applied.

Adding unbumped reflection makes the components below appear encased.

Adding unbumped reflection makes the components below appear encased.

The Layering node with a layer added to the top.

The Layering node with a layer added to the top.

  • Shader: for adding a component such as mila_glossy_reflection, layer, or mix node
  • On/Off: turn this layer on or off (participate in rendering)
  • Weight: simple scalar value to decide how much weight or energy absorption this layer has
  • Weight Tint: as above but using a color value, this can tint the result returned by the shader component
  • Use Directional Weight: with the feature off, the resulting component has no fresnel or directional falloff curve. The effect is applied evenly over the surface.
  • Fresnel Mode: this mode uses Ior to control the curve used for the component effect, this is familiar from the mia_material “use fresnel” switch
  • Custom Mode:  this is used to apply a Schlick curve that can be manually changed on the shader, this is familair from the mia_material (opportunity to hide/expose the control based on a mel selection of Directional Weight Mode)
  • Bump: per component bump applications, for now in Maya you need to use the Connection Editor since drag and drop or regular connection from the menu fails to work. Maya expects a shader for a bump node and not a vector so it gets confused.

The mila_mix node: Used to simply mix components together. Rather than think of a top -> down approach as in layering, think of simply mixing two paints together. Red and Blue make Purple for example.

Below is the default empty node with the same “Thin Walled” option as well as a way to change the energy conservation to a clamp mode.

The default Mix node

The default Mix node

The below mila_mix example has two components added to the node.

The Mix node with 2 added components to mix

The Mix node with 2 added components to mix

  • Shader: accepts a component, other mix, or layer node
  • On/Off: turn this layer on or off (participate in rendering)
  • Weight: simple scalar value to decide how much weight or energy absorption this layer has
  • Weight Tint: as above but using a color value, this can tint the result returned by the shader component
  • Bump: per component bump applications, for now in Maya you need to use the Connection Editor since drag and drop or regular connection from the menu fails to work. Maya expects a shader for a bump node and not a vector so it gets confused.

The mila_diffuse_reflection node: this is the Lambertian (or Oren-Nayer using roughness) node that is very similar to the mia_material.

There is an added feature, the Rgb Bump vector. This is used to quickly simulate a sub-surface scattering effect when a bump is applied to a diffuse surface. This is not useful without a bump effect applied to the shader in the layer or mix node. This allows colors to be applied to a bump in varying degrees and therefor simulating an inexpensive and shallow scattering effect.

Diffuse reflection, Lambert and Oren-Nayer style diffuse scattering

Diffuse reflection, Lambert and Oren-Nayer style diffuse scattering

The mila_diffuse_transmission node: this is a simple node used for translucency effects.

Diffuse transmission, different shades of grey utilizing 'thin walled'

Diffuse transmission, different shades of grey utilizing ‘thin walled’

There is an indirect multiplier node for controlling indirect interactions such as final gathering

Diffuse Transmission is Translucency

Diffuse Transmission is Translucency

The mila_glossy_reflection node: this is the glossy (blurry or rough) reflection node. This node has received quite a bit of attention and should get a lot of testing to further improve it through feedback.

Glossy reflection with varying roughness.

Glossy reflection with varying roughness.

Glossy Reflection, blurry or rough reflection. Default curve is linear.

Glossy Reflection, blurry or rough reflection. Default curve is linear.

Things to notice that are different than the mia_material:

  • Roughness: this is the amount of blur for the reflection. 0.0 is a mirror-like reflection while 1.0 is diffuse reflection. This is a visually linear curve and the direct reflections now match the indirect reflections, unlike the reflection and specular (direct reflection) response of the mia_material that was originally preferred by artists. Lower ray counts for brute force no longer result in a darker reflection like mia_material. Energy is conserved correctly.
  • Samples: this parameter means the same things as the mia_material but you’ll notice that now 0 samples means ‘take the samples amount from the global string option’ “mila glossy samples” instead of mirror. This is a convenient setting that exists across the shaders so you have one location for setting samples. This is important to simplify rendering and using Unified Sampling. Individual shaders can still be tuned individually if necessary.
  • Visible Area Highlight: an inexpensive application of multiple importance sampling. -1 is the recommended default and allows the shader to choose whether to sample lights indirectly (reflection ray) or a light directly (light sampling). 0.0 is indirect reflection only. 1.0 is direct reflection only. Amounts in-between are mixtures of the schemes. As the roughness increases, so does the possible contribution of direct light sampling. If your area light has insufficient samples or Unified Quality isn’t high enough, these areas will exhibit grain. Using the framebuffers will help you decide where the noise is coming from (indirect or direct glossy reflection).
  • Roughness Exponent: allows the user to change the curve of the glossy parameter from visually linear to something else that might be useful. You may find the amount of 1.5 to be most useful but some testing will help determine the best default for final release.

Important to note: this shader actually performs best with an area light. Spot, point, and directional lights all have zero area to sample and are less intuitive to use when mimicking traditional lighting from the real world. Take a look at the Area Lights 101 post for more ways to simplify and speed up your renders. In the examples here I am using a disc area light with no decay. From the point of interest I aligned it with the sun in the HDR which is also a Native IBL that is emitting light on “automatic” mode.

The mila_glossy_transmission node: this is the glossy (blurry or rough) refraction node. The parameters are similar to above but include ior to refract (bend) rays passing through the object.

Glossy refraction using the same ior of 1.55

Glossy refraction using the same ior of 1.55

Glossy Transmission is blurry or rough refraction

Glossy Transmission is blurry or rough refraction

The mila_specular_reflection node: This node is simply a mirror reflection. It shoots a single ray and can be colored.

Important to note here: this shader is indirect reflection only. This will not generate a highlight for invisible or infinitely small (point) lights. If the light itself must be visible, you must use something that is visible to reflection with an actual size or area such as the user_ibl_rectangle or an area light.

Specular reflection node with various shades of grey tint.

Specular reflection node with various shades of grey tint.

Specular reflection: mirrored, non-glossy surfaces

Specular reflection: mirrored, non-glossy surfaces

The mila_specular_transmission node: Same as above but refracts rays through the object. There is no option to blur the result.

Specular transmission attenuated by grey color to black.

Specular transmission attenuated by grey color to black.

Specular Transmission is for non-glossy refraction

Specular Transmission is for non-glossy refraction

The mila_scatter node: this is the multi-threaded (no lightmap) sub-surface shader. These parameters mean essentially the same thing as the SSS2 shader found in the current documents and Maya 2013. If you are familiar with the new SSS2, then this shader should be simple to control

Subsurface scattering with the front weight attenuated through grey tint

Subsurface scattering with the front weight attenuated through grey tint

The Scattering or SSS node with tinted orange scatter. White is also acceptable/preferred tint to start with.

The Scattering or SSS node with tinted orange scatter. White is also acceptable/preferred tint to start with.

  • Resolution: this is a control that sets the amount of detail the shader will capture in screen space. 2 is the default and means half resolution. 1 is same resolution as render and 0 is double the resolution. Higher numbers decrease the resolution accordingly.

The mila_transparency node: this is simple colored transparency.

This can be layered to create cutout-like effects and transparency in simple cases where ior is not required. But you may find the “thin walled” option in the layering node to be more appropriate.

Simple transparency

Simple transparency

The mila_emission node: this is similar to the “additional color” of the mia_material or incandescence in other materials. It’s simple to use but does not emit light as an object light. Final gather will sample the object as an emitter.

Emission shades of grey multiplied by 2.0 in the shader

Emission shades of grey multiplied by 2.0 in the shader

Emission is for glowing objects (not specifically light emitting, but a fake)

Emission is for glowing objects (not specifically light emitting, but a fake)

The mila_get_roughness node: This utility is so you can use maps painted for the mia_material glossiness inside the mila_glossy nodes without major modification.

A helper to use older maps painted for mia_material glossiness inside MILA

A helper to use older maps painted for mia_material glossiness inside MILA

The mila_get_normal node: this is used to get and alter the normal for bump maps.

This is not needed in Maya. You can manually connect a Maya bump node to the layer or mix node with the connection editor. This node is needed in 3ds Max.

An adapter for bump mapping, not required in Maya, the native bump node works with the help of the connection editor

An adapter for bump mapping, not required in Maya, the native bump node works with the help of the connection editor

NEXT: How to create framebuffers for MILA inside Maya.

The Native (Builtin) IBL

Inside mental ray there is a Native or Builtin image based lighting scheme called environment lighting mode. This was integrated into mental ray some time ago in version 3.7. So it’s been around for about 4 years or more.

It’s unexposed in OEM packages but using our new UI for rendering, we have exposed it for use in Maya 2013. mentalCore also makes use of the Environment Light. We refer to the feature in the UI by its String Option name: Environment Lighting.

Edit: This is properly exposed in Maya 2015 in the Environment Lighting as “Light Emission”

Keep in mind you should be using the UI provided or at the least add the “light relative scale” string option to correctly light non-BSDF or legacy materials. Otherwise they will blow out. This is also true of the user_ibl_env shader. The MEL script below will add it otherwise. (This is unnecessary in Maya 2015 as it is already added from Autodesk.)

select miDefaultOptions; 
int $idx = `getAttr -size miDefaultOptions.stringOptions`; 
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "light relative scale"; 
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "0.318"; 
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "scalar";

Why do I want to use this?

Simply put: It’s fast and automatic direct lighting of scenes where your primary light source is a high dynamic range image (HDRI).

You have heard of this method in other packages as a Dome Light and in Maya 2013, the user_ibl_env was introduced with similar functionality.

Why would I use this instead of the user_ibl_env?

  • The Environment Light re-bakes data by point sampling an environment attached to your camera. This means it also accepts procedurals unlike the user_ibl_env shader.
  • In the baking process you can re-bake to a lower resolution that automatically blurs the texture detail, meaning typically faster glossiness and less variance
  • The Environment Light combines with BSDF shaders to use Multiple Importance Sampling automatically for quick renders
  • The Environment Light will allow you to continue to use the Maya IBL mechanism that is visible and manipulable from the viewport.
  • It uses a simple “Quality” scheme that is familiar from Unified Sampling and they work together accordingly.

Can’t I just light with Final Gather?

Sure. But Final Gathering (FG) samples in a way that distributes rays somewhat randomly. This means you have a few obvious problems illustrated below:

Rendering the scene with only Final Gathering as lighting

Rendering the scene with only Final Gathering as lighting

  • Splotches. Being an interpolated scheme means you need great accuracy to resolve fine lighting details.
  • Soft shadows and sort-of occlusion-like shadowing. You need a LOT of accuracy to get the shadows looking correct.
  • Complex or high contrast HDRIs need a lot of FG tuning.

An easy way to illustrate this is to look at the indirect diffuse lighting pass.

Indirect Diffuse pass without Builtin IBL

Indirect Diffuse pass without Environment Lighting IBL

Now try the Environment Light alone!

Environment Lighting Only

Environment Lighting Only

MUCH better with pretty much default settings.

Was it longer to render? Yes. It’s a brute force-like technique. But in order to get the same quality from FG would take much MUCH longer to render. So in that comparison, Environment Light is actually much faster.

What does FG + Environment Light look like?

Final Gathering with the Builtin IBL on

Final Gathering with the Environment Light on

In this situation I was able to capture direct and indirect lighting. But now, indirect lighting is only captured for object to object light reflection. Take a look at the indirect diffuse pass now (it’s very hard to see in this case, open in a new window):

Indirect diffuse lighting with Builtin IBL on

Indirect diffuse lighting with Builtin IBL on

This means you can greatly reduce your FG “accuracy” setting. In some cases as low as 8 or 16 rays. Keep in mind you might still need an FG filter setting of 1 if highlights on nearby objects are especially hot and generate speckles like the first indirect diffuse picture.

Another important thing when using the mia_material: by default it does not generate a specular (direct reflection) from a visible area light. This means your specular pass may be empty for the mia_material because it is using indirect reflection (reflection rays) to sample the environment. Other shaders that directly sample the Environment Light (like the car paint shader) may show noise or grain because it’s less efficient. To reduce this grain you have to increase the “Quality” of the Environment Light (or more Unified Sampling Quality at less efficiency)

Direct Reflection (specualr) is not generated for visible area lights like the Builtin IBL

Direct Reflection (specular) is not generated for visible area lights like the Builtin IBL

How can I set this up?

You can use the regular Maya procedure for adding an HDRI or a Texture to light the scene including the flags. You can also attach any environment to the camera such as an environment shader, environment switch or Sun & Sky.

Relevant controls built into Maya

Relevant controls built into Maya

What are the controls?

First: I want you to realize this is NOT the Maya IBL “emit light” option.

Do not use "Emit Light"

Do not use “Emit Light”

Here are the important exposed controls: (please excuse their existence in the Indirect Lighting Tab. It is a form of direct lighting as illustrated above.)

Environment Lighting Controls

Environment Lighting Controls

  • On: This means “Automatic” mode. Until the correct Progressive API is used in Maya, there is little point in using Approximate lighting mode. (Approximate generates probe rays and then fills in ambient lighting from the HDR for fast but inaccurate lighting. The other modes sample the light as a light source.)
  • Quality: Scalar slider for quality/grain control. Many scenes with sufficient texturing/complexity can get away with as little as 0.3. Increasing this value decreases grain/noise at the cost of speed, more shadow rays are traced. (Too much noise is insufficient Quality)
  • Scale: Multiplier for the light. Used to control tint/shade and brightness (value) The visible environment is not changed, only the light contribution. Environments are typically assumed to be comped later.
  • Shadow: Optimization, solid shadows are faster but treats all objects as opaque. Off is no shadows cast.

[Additional]

  • Cache: on/off, this creates an acceleration structure for faster lookup on complex lighting. This means the lighting lookup is done through a non-texture mechanism. Reflections may show artifacts at insufficient baking resolution (described below) but should light faster. Off = baked to texture with the usual implications/mechanisms for texture lookups.
  • Resolution: The lower the resolution, the faster the baking, less memory usage, and quicker rendering at the cost of details in reflection and lighting. (Works with iray as well) Below is an example where the resolution is so low the shadows are muddy and the lighting is very dim because the baking process missed some of the light sources. Below that is a correct version with higher resolution.
Rendered with low resolution samples (6 minutes a frame)

Rendered with low resolution samples creating muddy shadows and dark lighting (6 minutes)

Low resolution using Cache "on" (3.5 minutes)

Low resolution using Cache “on” (3.5 minutes)

More resolution to the lighting cache (4 minutes)

More resolution to the lighting cache (4 minutes)

Rendered with higher resolution to capture more lighting and details like multiple shadows

Rendered with higher resolution to capture more lighting and details like multiple shadows (5 minutes)

Resolution involving Cache “On”. Notice how the same resolution for the cache “on” mode did a better job by default for the lighting and shadows.

  • Shader Samples: When baking the IBL, this will take more samples before baking to avoid missing details or little hotspots. Useful with complex HDRI or small resolution settings like the above examples(Works with iray) This isn’t typically important with low contrast or low detail maps/procedurals. A ramp for example, will not benefit from more samples. Use this if you find that you are missing some small light sources or shadow details suffer. You can find a happy medium of lower resolution and some extra shader samples typically easily.
Cache "on" same resolution as above but more "shader samples". (Just over 4 minutes)

Cache “on” same resolution as the low settings above but more “shader samples”. Notice it resembles the high resolution version. (Just over 4 minutes)

Things to note:

  • HDRIs with low range or values will not produce crisp or deep shadows. You might want a happy medium range in a tonemapped HDR so you don’t have hot spikes in reflections and poor shadowing.
  • HDRIs with multiple light sources will automatically cast multiple shadows.
Automatic Multiple Shadows (Grace Cathedral EXR gain factor of 2)

Automatic Multiple Shadows (Grace Cathedral EXR gain factor of 2)

  • Don’t forget to use “light relative scale”!! (MEL at the top of the post)
  • Concave objects or interior scenes not lit directly by the Builtin IBL will need the usual higher quality FG and Portal Lights.
  • Set-acquired HDRIs work well for this with some additional bounce lights to “sweeten” the look.
  • The mip_matteshadow shader can be used to capture shadows for compositing onto live action plates.
  • Remember to use HDRI data. JPEGS and other common formats do not have enough range to produce good lighting.
  • Remember to reduce your Final Gather accuracy to speed up renders considerably. You do not need high settings since the Environment Light handles the bulk of the work.

2013 Toyota Avalon: Formula

Here’s another spot rendered with mental ray.

The environment and car were rendered and composited with live action ink and effects from Houdini.

Originally envisioned as a filmed piece, it was decided later that the car and environment would be replaced with a purely rendered version. The artists matched the shot car so closely it was impossible to tell the difference. This allowed the freedom to change how the commercial was shot while maintaining the original look and feel the director desired.

Take a look here: 2013 Toyota Avalon: Formula

Toyota Avalon: Formula

Toyota Avalon: Formula

The Layering Library (MILA shaders)

If you head over to the NVIDIA-ARC forum, you’ll see a beginning explanation developer thread to testing the Layering Library. This thread will continue to expand. (You must be a registered forum user. Also, the forum does not recognize users automatically for spam reasons, you need to participate by making a post at some point. This also prevents Bots from swarming the board. Once the shader package is linked you may be able to make a post and download it.)

You can participate there and come back to the blog time to time to see other examples and explanations on the shader library.

These shaders begin the transition to other modern techniques with a flexible selection of components. The features include (but not a complete list):

  • Built-in framebuffer outputs
  • Better importance sampling for faster renders
  • Components as separate building blocks for arbitrary layering. A single library can make shaders for many different things from car paint to skin and more.
  • Non-lightmapping scattering shaders (multi-threaded)
  • Light Path Expression options for specifying framebuffer passes
  • Layers maintain energy conservation without user interaction
  • and more. . .

You’ll also notice a re-branding continuing on the site. The main website address is now: http://www.nvidia-arc.com

They are looking for images to use on the main banner, you can even try your hand at some images with the new shaders!