**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.
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.
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.
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