|On this page|
Instancing involves creating copies of a source object only as needed during rendering. It it much faster and uses less memory than creating a large number of “real” copies of an object.
You can instancing to create a easily create large number of lights in the scene at render time based on the positions of points in a geometry object.
Basic setup ¶
Create a “template” light to instance onto the points.
Create an Instance subnetwork
On the Instance object’s parameters:
Set the Instance Object parameter to the path to the light (drag the light node from the network editor onto the parameter).
Set Point instancing to “Full point instancing”.
Inside the Instance subnetwork, generate the points you want to instance lights onto.
You can use an Object Merge node inside the Instance object to grab the points from elsewhere if they already exist or it’s inconvenient to keep them in the subnet.
Instanced objects apply the source object’s transforms relative to the point position. If the source object isn’t at the origin, this might give unexpected results.
To prevent the template light from casting light, remove it from the Candidate lights parameter on the render node:
In the main menus, choose Render ▸ Edit Render Node ▸ your render node.
Varying light parameters across instances ¶
You can vary light parameters based on attributes on the points. For example, you can color the points, and have the instanced lights use the point color as their light color.
On the “template” light object, use a point expression to grab attribute values off the point being instanced. Use the path of the instanced points geometry as the node argument and use instancepoint as the point_number argument.
The point() expression function fetches an attribute value from some other geometry
point(surface_node, point_number, attribute, index)
surface_node is a path to a surface node, for example
point_number is the point number to read the attribute from. When instancing, you can use instancepoint to get the number of the point currently being instanced.
attribute is the name of the attribute (for example,
Cd for diffuse
color). Two special attributes exist:
Pw which represent the
position of the point in space (
Pw allows you to access the W
component of the position).
Components of dictionary attributes can be resolved using
"param.key" will return the value of
key in the dictionary
index specifies the component position in multi-component attributes such as vectors, colors, and arrays. For example, if the attribute is a color, an
index value of
0 returns the red component,
1 returns the green component, and
2 returns the blue component.
For example, to use the instanced point’s color as the light color, set the template light’s Color parameter to: