Sun Shafts
Manual     Reference     Scripting   
Reference Manual > Components > Image Effect Scripts > Sun Shafts

Sun Shafts

The Sun Shafts image effect simulates the radial light scattering (also known as the "god ray" effect) that arises when a very bright light source is partly obscured.

As with the other image effects, this effect is only available in Unity Pro and you must have the Pro Standard Assets installed before it becomes available.


Example of the Sun Shafts effect

Properties

Rely on Z BufferThis option can be used when no depth textures are available or they are too expensive to calculate (eg, in forward rendering with a large number of objects). Note that if this option is disabled then Sun Shafts must be the very first image effect applied to the camera.
ResolutionThe resolution at which the shafts are generated. Lower resolutions are faster to calculate and create softer results.
Blend ModeChose between the softer Screen mode and the simpler Add mode.
Sun TransformThe transform of the light source that casts the Sun Shafts. Only the position is significant.
Center on ...Within the editor, position the Sun Transform object at the center of the game view camera.
Shafts colorThe tint color of the shafts.
Distance falloffThe degree to which the shafts' brightness diminishes with distance from the Sun Transform object.
Blur sizeThe radius over which pixel colours are combined during blurring.
Blur iterationsThe number of repetitions of the blur operation. More iterations will give smoother blurring but each has a cost in processing time.
IntensityThe brightness of the generated shafts.
Use alpha maskDefines how much the alpha channel of the color buffer should be used when generating Sun Shafts. This is useful when your skybox has a proper alpha channel that defines a mask (eg, for clouds blocking the sun shafts).

Blend Modes: Add and Screen

Blend modes determine the way that two images will be combined when overlaid. Each pixel from the base image is combined mathematically with the pixel in the corresponding position in the overlay image. Two blend modes are available for Unity image effects, Add and Screen.

Add Mode

When the images are blended in Add mode, the values of the color channels (red, green and blue) are simply added together and clamped to the maximum value of 1. The overall effect is that areas of each image that aren't especially bright can easily blend to maximum brightness in the result. The final image tends to lose color and detail and so Add mode is useful when a dazzling "white out" effect is required.

Screen Mode

Screen mode is so named because it simulates the effect of projecting the two source images onto a white screen simultaneously. Each color channel is combined separately but identically to the others. Firstly, the channel values of the two source pixels are inverted (ie, subtracted from 1). Then, the two inverted values are multiplied together and the result is inverted. The result is brighter than either of the two source pixels but it will be at maximum brightness only if one of the source colors was also. The overall effect is that more color variation and detail from the source images is preserved, leading to a gentler effect than Add mode.

Hardware support

This effect requires a graphics card with pixel shaders (2.0) or OpenGL ES 2.0. Additionally, depth texture support is required. PC: NVIDIA cards since 2004 (GeForce 6), AMD cards since 2004 (Radeon 9500), Intel cards since 2006 (GMA X3000); Mobile: OpenGL ES 2.0 with depth texture support; Consoles: Xbox 360, PS3.

All image effects automatically disable themselves when they can not run on end-users graphics card.

Page last updated: 2011-09-27