When lighting a scene, you will sometimes need to selectively control whether a piece of geometry is illuminated by a particular light, both for artistic purposes and to cut down on rendering time. The relationships that determine whether a light applies to an object are collectively known as light linking, and are controlled by the object’s linkedLights attribute.
The only supported renderer that currently implements light linking is Arnold.
Maya users will be familiar with the concept of light-centric (light-to-object) and object-centric (object-to-light) light linking. The procedure for linking lights in Gaffer is similar to object-centric linking.
From the light side of things, by default, each light is a member of a set named “defaultLights”, and will cast light on every object in the scene. Each light’s node has a Default Light plug, which is checked by default. If unchecked, the light is removed from “defaultLights”, and, from then on, will only illuminate objects that are expressly linked to it.
From the object side of things, by default, an object is lit by all lights belonging to the “defaultLights” set. To bring about any other behaviour, such as having the object only lit by one light, a linkedLights attribute must be added to the object’s location in the hierarchy, and the attribute must specify one or more lights, or sets of lights. The linkedLights attribute follows standard inheritance rules for attributes in the hierarchy, so if the object doesn’t have the linkedLights attribute, but one of its ancestors does, it will inherit the attribute.
In a graph, in order to actually link a light to an object, you must connect a StandardAttributes node downstream of the object, filter for the object’s location, and then add a set expression to the Linked Lights plug.
Once the Linked Lights plug is toggled on, the linkedLights attribute is added to the object’s location. The value of the Linked Lights plug is a set expression, which can consist of individual light locations, set names, or both. We will cover how to filter for both types below.
The Linked Lights plug is an exclusive list. If you toggle the plug and leave the list blank, the object will not be illuminated by any lights at all.
In order to link a particular light in addition to all default lights to an object, you must include defaultLights in the set expression, for example defaultLights/group/light.
To link a light by location, simply add the light’s full location to the set expression. No additional node is needed.
When linking a light by its location, the path you provide must be the final location of the light within the hierarchy as delivered to the render node. For example, if you link to a light at /group/light, but later in the graph you shuffle the hierarchy and the light exists at /building/lights/light, the renderer will look for the light at the original location, find nothing there, and then the link will fail. Therefore, you would unintuitively need to target a downstream location in an upstream part of the graph.
In setups with more than a few lights, managing a set expression with multiple light locations is prone to user error, and tedious to maintain. That’s why it’s usually better to link objects to one or more sets containing lights, as the term set expression suggests. Put another way, you can perform set-centric light linking. The end result would still be the same, in that specific objects are linked to specific lights.
A light can be added to any number of custom sets using the Sets plug on the light’s node, or a separate Set node. Custom sets are separate and do not affect the “defaultLights” set.
To link one or more lights by a set, simply add it to the set expression.
Be aware that if an object belongs to multiple sets with light linking, the object will only inherit the linkedLights attribute from the last set that was linked in the graph, as shown in the illustration below.
Picture a scene where a giant robot attacks a highly detailed metropolitan city at night. For dramatic effect, let’s say we want the robot’s eyes to shine with some menacing red highlights. What’s more, on the robot’s chest is affixed the logo of its evil creator, and we want to make sure the audience can just make out the logo, regardless of the ambient illumination. With a photorealism mindset, both of these lights would be conceits, as they would have no plausible light source. Even so, with their inclusion, the scene becomes more evocative.
To achieve both of these highlights, we could add special lights in front of the robot’s eyes and chest. But, by default, these lights would also illuminate the rest of the robot, and everything else in the scene. This may not achieve our artistic intent, and could also affect render time and memory usage.
The above set expressions link the special lights and sets. The eyes are linked to all lights plus the eye light’s set; the logo is linked to all lights plus the logo light’s set. The result is that the special lights only illuminate the subjects we want them to: the eye light hits the eyes, and the logo light hits the logo.
Help > Examples > Lighting > Light Linking City Attack (Arnold)
In this example, a supersized version of our mascot, Gaffy, is throwing a tantrum, and attacking a city. Two special and unrealistic light sources are added to the scene, in order to add highlights to Gaffy’s eyes and chest logo. This graph contains the light-link setup described in the above example scenario.