Light shafts

Light shafts, also called god rays, are visible rays of light.

Xenko light shafts are based on shadow maps and use raymarching rather than post effects, so they're visible even when the light source isn't. Any light source that casts shadows (ie , directional lights and ) can cast light shafts.

To create light shafts, use three components together: lights, light shafts, and light shaft bounding volumes.

By default, Xenko disables light shafts in new projects. To enable them:

The graphics compositor editor opens.

  • Select the forward renderer node.

Select forward renderer

  • In the Property Grid (on the right by default), next to Light shafts, click (Replace) and select LightShafts.

Select light shafts

  • Make sure the light shafts checkbox is selected.

For more information about the graphics compositor, see the Graphics compositor page.

2. Add a light shaft component

  • In your scene, select the entity with the light you want to create light shafts. This must be a light that casts shadows (ie a , directional light, or ).

  • In the Property Grid, in the Light component properties, make sure the Shadow checkbox is selected.

Enable light shafts

  • Click Add component and select Light shaft.

Game Studio adds a light shaft component to the entity.

  • In the Asset View, click Add asset.

  • Under Models, select a model in the shape you want the volume to be. For example, if you use a cube, light shafts will be created in a cube-shaped area.

Cube model

The Select an asset window opens.

  • You don't need a material for the model, so click Cancel to create a model without a material.

  • With the entity selected, in the Property Grid, click Add component and select light shaft bounding volume.

Add light shaft bounding volume component

  • In the light shaft bounding volume component properties, next to light shaft, click (Select an asset).

  • In the entity picker, select the entity with the directional light you want to create light shafts and click OK.

  • In the light shaft bounding volume component properties, next to Model, click Hand icon (Select an asset).

  • In the Select an asset window, select the model you created and click OK.

This model defines the shape of the light shaft bounding volume.

  • Using the transform component, position and scale the entity to cover the area where you want to create light shafts.
Tip

Show light shaft bounding volumes

Light shaft properties

To access these properties, in the graphics compositor editor, select the forward renderer node and expand Light Shafts.

These properties apply globally to all the light shafts in the scene.

Light shaft graphics compositor properties

PropertyDescription
Bounding volume buffer downsample levelLower values produce more precise volume buffer areas, but use more GPU
Light buffer downsample levelLower values produce sharper light shafts, but use more GPU

Light shafts work best in dark environments. You can adjust the light and light shaft component properties to achieve different results — for example, by changing the light color (in the light component properties) or the light shaft density (in the light shaft component properties).

Multiple light shafts viewed through one another can become visually noisy, as in the screenshot below:

To reduce this effect, in the light shaft component properties, reduce the density and increase the sample count.

Density factor

Alternatively, add additional bounding volumes and process them separately. To do this:

  • Create additional bounding volumes and position them to cover the areas where you want to create light shafts. Make sure the bounding volumes don't overlap, as this makes light shafts extra-bright.

  • In the light shaft component properties, make sure Process bounding volumes separately is selected.

Note

Processing bounding volumes separately uses more GPU.

See also