Category Archives: Lighting
New GI Prototype Quick Start
As previously posted, a prototype of the new GI scheme for mental ray was included with Maya 2015.
To be clear what a prototype is, this section from Wikipedia best describes this phase of the feature:
Prototype software is often referred to as alpha grade, meaning it is the first version to run. Often only a few functions are implemented, the primary focus of the alpha is to have a functional base code on to which features may be added. Once alpha grade software has most of the required features integrated into it, it becomes beta software for testing of the entire software and to adjust the program to respond correctly during situations unforeseen during development.
Often the end users may not be able to provide a complete set of application objectives, detailed input, processing, or output requirements in the initial stage. After the user evaluation, another prototype will be built based on feedback from users, and again the cycle returns to customer evaluation. The cycle starts by listening to the user, followed by building or revising a mock-up, and letting the user test the mock-up, then back.
As such there are some limitations to know about in this prototype:
- Motion blur not supported
- Lens shaders not supported
- Hair is tessellated
- Visibility (cutout opacity) not supported
- Specular interaction currently handled by Final Gather
Since the completed feature is expected to become the replacement solution I suspect these limitations will be removed over time.
Below is an example image rendered with the new GI. The main interior is taken from the Architecture Classroom found at
IDST [site appears to be gone]. Other modern mental ray features being used are:
- Layering Library Shaders
- Object Lights (2015 Service Pack 2 or later) 8 in total
- Light Importance Sampling (improving the result of the lighting and simplifying tuning of the scene to a single slider/value)
Also, I am not using portal lights or the Environment Light (Native IBL). Instead I am allowing the new GI to sample the environment without casting more shadow rays and speeding up the render. This also means simplified setup for interiors where you can use the new technique (and a GPU) to power through a scene and render quickly. The brute force nature of the technique will provide you with crisp indirect shadows.
The image below renders in 18 minutes at 1080HD using a K6000. (All of the following renders and time were rendered at 1080HD before resizing to better fit the webpage at 720HD)
Provided by NVIDIA ARC is a simple mel script to enable the GI features in Maya 2015. After loading the script simply run:
The controls are pretty self-explanatory and only expose the main controls for quality. The controls may change in the future:
- Enable – override using the new GI instead of Final Gather (Be sure other features are off, like IP or Photons or they may run unnecessarily)
- Use GPU – this uses the GPU to accelerate the process. The result is identical regardless of mode but the CPU is much slower. Currently CPU usage is less than 100% Also note that CPU usage might be less than 100% using the GPU if using a slow card or high settings. This is because the CPU is waiting on the tile from the GPU. This requires recent graphics drivers and an NVIDIA graphics card (GTX or Quadro)
- Diffuse only – only calculate diffuse rays. In a lot of applications this is all you’re interested in. But scenes with glass walls and similar effects may need more. In the Prototype, Final Gather rays are used for this effect. This will change as the feature adds more abilities and takes over for old techniques
- Override FG (Final gather) Globals – The new GI can take its settings from legacy FG settings including ray depth (bounces) which is still set in Final Gather trace depth.
- Samples Per Pixel – this is the number of samples per pixel (Anti-aliasing) taken per pixel. This also acts as a multiplier of Rays. This number should be a square of another number: 1, 4, 9, 16, 25, 36, etc.
- Rays – Your primary control for quality. This is a brute force technique (at filter 0) where this number of rays is shot per pixel multiplied by samples per pixel above.
Below are some examples of altering the settings.
Increasing the samples per pixel, keeping everything else the same (filter set to 0):
Increasing the rays parameter, all else is the same (filter is set to 0):
The filter parameter is improved from previous ways of filtering/interpolating GI results. As a convenience the measurement is in pixels. You should find this easier to smooth more quickly and easily than other methods. It also has a negligible impact on render time unlike increasing interpolation with Final Gather. In fact, less variance should improve render times since Unified Sampling works less to solve the image. Keep in mind that increasing values will blur indirect shadowing details.
Open this in a new window to see the changes as they are subtle, blending away the noise. Please pardon the gif compression.
Another example of the improved smoothing filter:
Expect this feature to evolve dramatically over the next year as well as improve performance of both the GPU and CPU modes.
Render Tests, Combined Lighting
In looking at features in mental ray, there are a lot of combinations that can be had. Some are more helpful than others based on scene needs.
And some results might be counter intuitive.
In rendering you have two usual options for indirect lighting.
One involves brute force-like rendering (also known as “unbiased”) where every sample in the scene sends rays back into the scene to sample other objects and the environment. This is typically easy to tune (just crank it up until acceptable), requires less technical skill, and is pretty predictable frame to frame in variance without testing. However, it can increase render times by a large amount in complex scenes.
Option two involves interpolated (or “biased”) schemes where sparse samples are taken across the image and merged together through a interpolation algorithm. This is typically much faster to render but requires more artist tuning and may cause surprises in later frames. For Final Gather we have the option of using the fg_shooter to help mitigate this problem.
In the below examples I am combining brute force (non-caching to be specific) Final Gather with Irradiance Particles. This means Final Gather rays are used to collect detailed information in the primary bounce (typically the most important). Irradiance Particles are used to collect secondary (and higher) bounces. There are no portal lights being used. I might also call this “The Joys of Rendering On My Ancient Workstation” which can still get the job done.
Irradiance Particles have a few interesting features:
- Additional bounces each send fewer and fewer rays so each pass of collection is faster (Final Gather is only one ray each additional bounce)
- It only collects diffuse information (Final Gather collects specular as well as diffuse)
- The Importon optimization phase is sadly not multi-threaded. But this is less important here since we are using it as secondary bounces and emit fewer
- The importance based scheme means it’s smart about probing the brighter areas of your scene for information instead of wasting rays in dark spots. This effectively “aims” indirect illumination rays towards the more important areas of the scene.
Notice a few things here about how long this took to render in the image captions. . .
Unified Sampling takes less time with each increase in diffuse bounces (I do use a higher than normal setting in this case to force Unified to catch small illumination details). Adding bounces for a faster render might be counter intuitive in this case. There’s a reason for this, the decreased lighting contrast needs fewer samples per pixel. But there are things to think about in a more realistic scene.
In most scenes, texturing will create more contrast in the image. This may drive more samples through Unified Sampling. In this case you may be able to reduce the number of rays sent by brute force Final Gather since Unified is taking more samples anyway. This would be a balance you might need to tune. I would still recommend portal lights which means more direct lighting detail and a reduced need for indirect illumination rays. Also, using this type of combination might require less time to tune an image for the right lighting/detail balance that one or the other algorithm might need.
My settings for this scene are:
- Final Gather Force – 48 accuracy, filter 1 (the filter option means nothing if rays/accuracy are less than 8)
- Importon Density – 0.5 (this can be played with based on what you might need, but recommend it be as low as possible. Too few introduces artifacts in crevices and corners.), bounces 3
- Irradiance Particles – rays 64 (The Maya UI limits this to 512 rays. There is no actual limit. You can change this in the mel or use our UI)
Diffuse bounces are controlled through the Final Gather trace settings, not the Irradiance Particles.
A quick primer for Irradiance Particles:
This lighting technique is best suited for interiors and as a secondary bounce usually. For exteriors I highly recommend the Environment Lighting Mode. The main reason for this choice being: It only collects diffuse information. This means something like glass will block it from getting information. Also, the optimization phase for Importons is single threaded and cannot be cached for multiple frames.
In looking at the easiest way to increase the quality of Irradiance Particles the simple answer is: increase the number of Importons emitted. This means:
- Better detail in geometry and cracks
- More scene information from better sampling and more rays
- Slower renders from the emission and optimization phases
However, you can achieve better performance by balancing rays, interpolation, and Importon density if you have the time and/or desire.
Object Lights – mental ray 3.11 *small update*
**UPDATE** Maya 2016 makes these lights an integrated option using the create menu.
**Maya 2015 SP3 delivers the builtin_object_light shader and works correctly/stably with mental ray 3.12 Be sure and follow the other tips like turning off the shading engine until integration is done.**
One of the most requested features for mental ray has been an object, or mesh, light. This is a somewhat experimental feature since it’s not exposed it was not tested in the Maya Betas. *There has been some talk of crashes, but sporadic. The cause has been found and is up for a fix now in mental ray, thanks for the extra reports to find it. Also, be sure and select not to Export with the Shading Engine in the Shading Group node to avoid the naming emission irregularity.*
Lighting a space using Final Gather from self-illuminated objects can be tedious to tune and costly in render times. Typically you need large amounts of rays (accuracy) from Final Gather to achieve smooth lighting this way. You can see such an example below with accuracy set to 1024.
An object light is the ability to define a shape as a light source. This allows greater flexibility in lighting scenes where a physical object is better (like a neon tube sign) or more efficient for rendering than an emissive plane with Final Gather.
The ability to make an object into a light has been available in mental ray for a long time and in an .mi file it’s a simple line that tells the renderer that the object is a light.
mental ray also supports geometric area light sources for point lights, specified by the object keyword. Its first argument must be the instance of a single-group object that defines the geometry of the area light source. All points on the surface of the object will emit light uniformly. It is generally a good idea to keep the triangle count of the object as low as possible for maximum performance. The sampling rates usually have to be set much higher for object lights.
If you look at the .mel for the area light AEtemplates in Maya, you’ll see legacy code where this was accomplished at some point in the past but disabled. The usual reasoning is that object lights can generate a lot of noise in a render that is difficult to clean up.
However, since the inclusion of Unified Sampling, you’ll see that cleaning up area light noise is much easier with fewer samples than before. This makes for a faster render that’s easier to control.
mental ray 3.11 includes a new shader called the builtin_object_light that tells mental ray that the object is a light. This circumvents anything that might be required by integration to work.
There is no library file that is needed for this shader, e.g. .dll, .so etc. Since it is “builtin” you just need the .mi declaration saved in the include folder for the mental ray plug-in. You can copy the code below and save the file. Keep in mind you should save these scenes as .ma if you wish to maximize compatibility since there are no node IDs for this shader.
declare shader color "builtin_object_light" ( color "surface" default 1 1 1 1, light "light" ) version 1 apply material, photon end declare
I saved it in Windows here: C:\Program Files\Autodesk\mentalrayForMaya2014\shaders\include
Opening Maya (being sure it’s loaded under the Shader Manager).
You can now see the simple UI below.
The simple workflow is:
Assign builtin_object_light material to Object -> create area light -> attach area light .message to Light parameter of builtin_object_light shader. (This picture needs updated below, you should attach the transform, not the shape)
You will notice that the object light still follows the shape node rendering flags like cast and receive shadows. That’s why there is a ring shadow around the box. This is not particularly intuitive so you can turn off cast and receive shadows and render again.
For these examples I have the “visible” parameter of the Area Light On. This means the object light primary ‘look’ is controlled through the “shape intensity” of the Area Light and the light shader. If this option is off, the look is controlled through the builtin_object_light “surface” control.
I actually recommend you leave that parameter On when possible. Having the Area Light Visible set to “Off” causes direct reflection sampling of the light even if the object is still visible. Instead you should use the Shape Node Render Stats to control the visibility of the light like you would any object in the scene.
Below I have the walls of the box semi-reflective and moved the light so that it’s more obvious when it’s hidden.
Now I will turn off the primary visibility on the Shape Node as seen below.
Here is the resulting render:
So now you can control how the light is sampled and seen in your image.
Also notice that light shaders applied to the area light will work as well but may have unintuitive consequences. In some cases light quadratic falloff of the visible light and not just the light effect itself is noticed. This means as the light is scaled or moved into the distance, it will change primary intensity (its lighting effect remains the same).
Being creative with node networks will also allow you to do things like cutouts and transparency on a light as seen below. The light in the scene is a solid plane with a checkerboard attached as illumination as well as connected to a mib_continue to allow rays to pass through. The alpha of the light is also controlled in the same way. The box is left slightly reflective as above to show the reflection of the checkerboard on the back wall.
These options will also combine with the new Light Importance Sampling found in 3.11 for textured lights.
Light Importance Sampling (light IS)
Light Importance Sampling in mental ray 3.11 will allow mental ray to distribute samples more effectively on textured area lights.
Why would I use Light IS?
This means samples are more efficient when lighting a scene where you may have textured object lights or bounce cards using an HDRI as the light source. This is similar to the user_ibl shaders but is now a core feature, potentially applying to more light types in your scene through a global option. In this way, once it is integrated it will deprecate the user_ibl shaders.
You can find more about this in the release notes and enable them in Maya using String Options. Below is an example from the documentation of settings:
The String Option: “light importance sampling” has three settings.
"off", default. Importance sampling is not applied.
"on". Importance sampling is enabled for rectangular and disc area lights with high emission variance, and for all spherical, cylindrical and object lights. This mode is useful for rectangular and disk light with uniform intensity. In this case the core will check to see if the light emission has sufficient variance (between light and dark) to justify light importance sampling (Light IS). Non-planar lights (like an object light for example) always compute for light IS. This also applies to planes being used as Object Lights despite being similar to a rectangular light. This means it is sampled for Light IS but may not make a difference in render quality if not textured.
"always". In addition to “on”, importance sampling is enabled on all rectangle and disk lights. This mode means Light IS is used even if the variance of the light emission is low and might be ignored otherwise. (An additional variance option exists if you want to tweak what is considered to be enough variance to trigger light IS)
There is also “light importance sampling precomp” string option with values of on or off. This option presamples lights (there’s some overhead before rendering) for lights with HDRI attached to them. This can reduce the variance (noise) in a final image. Take note your image might look slightly different with this option on. This option is a compliment to the settings above as it changes how the lights are sampled during the render but not required. Recommended if a lot of your lights are using HDRI or high variance textures.
All of the modes will present log output telling you if the lights you have are being considered for Light IS. If there is more overhead for sampling but your log tells you the lights aren’t using Light IS (not textured or not enough variance) then you might switch it off and render normally.
Take care that since the mayastate shader has not been updated to be aware of this option it will generate a long warning log with “unexpected ray” readouts.
This is a feature that will have more explanation at a later time since it is more involved.
2013 Toyota Avalon: Electric
Recently completed at The Mill is a commercial for the Toyota Avalon called “Electric”. You may recognize this set from a previous piece called “Formula”.
This was rendered in mental ray with a complete CG car as before but added lightning as object area lights to get the right feel of light from the contact points.
Special thanks to Brenton for making this light shader for us to use.
You can see the commercial here: Toyota Avalon: Electric