Using lights in rendering

Use the Gather Lights Render Pass to collect from a list of nodes the light nodes for lighting 3D nodes in a scene.

../../_images/gather-lights-render-pass1.svg

Collecting lights

The Gather Lights Render Pass collects light nodes for lighting 3D nodes in a scene.

By default a Gather Lights Render Pass collects either all the light nodes in a scene or the light nodes provided by its nearest ancestor Node List Render Pass.

For example, in this render pass prefab the Gather Lights Render Pass collects the light nodes provided by its parent Node List Render Pass:

../../_images/node-list-gather-lights-draw-objects.png

You can use any Node List Render Pass in the same Render Pass Prefab to provide light nodes to a Gather Lights Render Pass. To learn how to use filters to pass nodes to render passes, see Filters.

To set the Node List Render Pass that you want to use to collect lights:

  1. In the Library > Rendering > Render Pass Prefabs select the Gather Lights Render Pass that you want to use to collect light nodes.

    ../../_images/gather-lights-render-pass-in-library1.png
  2. In the Properties click + Add Binding, and in the Binding Editor set:

    • Property to Node List

    • Expression to the Output Node List property of the Node List Render Pass

      For example, to collect the light nodes provided by a sibling Node List Render Pass of the Gather Lights Render Pass, set the Expression to:

      {@../Node List Render Pass/NodeListRenderPass.OutputNodeList}
      

    Click Save.

    ../../_images/gather-lights-render-pass-node-list-binding.png
  3. Render 3D content using the light nodes that you collected. See Lighting 3D nodes.

Lighting 3D nodes

Use the Draw Objects Render Pass and Draw Objects With Material Render Pass render passes to draw 3D nodes. Kanzi by default lights the 3D nodes drawn by a Draw Objects Render Pass or Draw Objects With Material Render Pass using the light nodes provided by the nearest ancestor Gather Lights Render Pass.

For example, in this render pass prefab Kanzi lights the 3D nodes, which the Draw Objects Render Pass draws, using the light nodes collected by the parent Gather Lights Render Pass:

../../_images/gather-lights-draw-objects.png

The Gather Lights Render Pass has output properties that each contain the set of lights of specific type collected by that Gather Lights Render Pass. You can manually set a Draw Objects Render Pass or Draw Objects With Material Render Pass to use the lights provided by any Gather Lights Render Pass in the same render pass prefab.

../../_images/gather-lights-render-pass-properties.png

To set the Gather Lights Render Pass whose output lights you want to use to light 3D nodes:

  1. In the Library > Rendering > Render Pass Prefabs select the Draw Objects Render Pass or Draw Objects With Material Render Pass that you use to draw 3D content.

    ../../_images/draw-objects-render-pass-sibling.png
  2. In the Properties click + Add Binding, and in the Binding Editor set:

    • Property to the type of lights that you want to use:

      • Directional Lights for Directional Light nodes

      • Point Lights for Point Light nodes

      • Spot Lights for Spot Light nodes

    • Expression to the output lights property of the Gather Lights Render Pass that you want to use:

      • Output Directional Lights for Directional Light nodes

      • Output Point Lights for Point Light nodes

      • Output Spot Lights for Spot Light nodes

    For example, to use the Directional Light nodes of the sibling Gather Lights Render Pass of the render pass to which you add the binding, set:

    • Property to Directional Lights

    • Expression to

      {@../Gather Lights Render Pass/GatherLightsRenderPass.OutputDirectionalLights}
      

      Click Save.

    ../../_images/directional-lights-binding-editor.png
  3. Repeat the previous step to add bindings for the other types of light nodes that you want to use.

    ../../_images/draw-objects-render-pass-light-bindings.png
  4. Take the render passes into use:

    1. In the Node Tree select the Viewport 2D node that contains the 3D content that you want to render.

    2. In the Properties set the Render Pass Prefab property to the render pass prefab that contains the Gather Lights Render Pass that you use to collect the light nodes and the Draw Objects Render Pass or Draw Objects With Material Render Pass that draws the 3D content.