Lens flares are a visual effect used to emulate glowing light sources, glare, and camera lens flares. They can be used in 3 ways:

  1. By a light tag which may be attached to an object or effect. Lens flares belonging to attached lights on objects can be scaled by a function.
  2. By a sky light, used for the cinematic looking camera lens flares on the sun.
  3. By shaders which generate BSP lens flares into a level for static light sources.

Lens flares usually contain one or multiple reflections, which are indices of a bitmap rendered along a flare axis which passes through the flare and the center of the screen.

Ray of Buddha

Ray of Buddha shining through an alpha-tested texture

The "Ray of Buddha" effect is a glowing disk of light that simulates light beams when obstructed by the BSP and objects within it (even by alpha-tested transparent textures like foliage). This effect will appear if either the sun flag is set or occlusion radius is set to 50.

Halo supports multiple Rays of Buddha drawing simultaneously, seemingly for as many lens flares can render. However, it does not support distance-based fading and will simply pop in or out at the tag's far fade distance if set.

The appearance of Ray of Buddha is partially hard-coded. You can change its radius using occlusion radius. The shape and fade of the flare are controlled by the globals glow bitmap. Its yellowish tint is hard-coded in the sun_glow_draw.psh FX shader.

Related HaloScript

Function/global

Type

(rasterizer_lens_flares [boolean])

Toggles rendering of all lens flares.

Global
(rasterizer_lens_flares_occlusion [boolean])

Toggles lens flare occlusion. If set to false, lens flares will no longer be occluded and stay visible even through objects in the foreground.

Global
(rasterizer_lens_flares_occlusion_debug [boolean])

Displays red squares over lens flares in the environment. How much the square is occluded by other geometry or the view frustrum is how much the lens flare fades out. The size of the square relates to the occlusion radius.

Global
(rasterizer_ray_of_buddha [boolean])

Toggles the lens flare "god rays" effect, present on sky lights or lens flares explicitly set to sun.

Global

Structure and fields

FieldTypeComments
falloff anglefloat
cutoff anglefloat
cos falloff anglefloat
  • Cache only
cos cutoff anglefloat
  • Cache only
occlusion radiusfloat
  • Unit: world units

Primarily controls the size of the camera-facing occlusion square. The more this square is covered, the more the lens flare fades out. A larger radius covers more screen space and gradually fades in/out while passing behind objects in the foreground, while a small radius will cause the lens flare to quickly appear or disappear. The square can be visualized with rasterizer_lens_flares_occlusion_debug 1.

This also controls how far the test square is moved depending on the occlusion offset direction.

This field also interacts with the Ray of Buddha effect, controlling its radius when the sun flag is set. However if this radius is set to exactly 50 then the sun flag will be implied and Ray of Buddha will render too.

occlusion offset directionenum

Controls which direction the lens flare is offset. Ignored by the Ray of Buddha effect if this tag's sun flag is set, which always uses a marker forward offset.

OptionValueComments
toward viewer0x0

The occlusion test square is moved towards the viewer by the occlusion radius. This avoids the test square being always half-embedded if the lens flare is placed directly on a surface.

However, this offsets the test square perpendicularly toward the camera's view plane, not toward the camera location itself. This results in test squares near the edges of the screen not aligning with their lens flares, causing them to fade out even while on-screen. Avoid setting this value too high to make this less apparent.

marker forward0x1

The test square is moved in the "forward" direction of the marker by the occlusion radius, usually off the surface in the case of BSP lens flares.

none0x2

The test square is not offset.

near fade distancefloat
  • Unit: world units

The distance where the lens flare begins to fade out.

far fade distancefloat
  • Unit: world units

The distance where the lens flare becomes invisible. Distance-based fading is disabled when set to 0.

bitmapTagDependency: bitmap
flagsbitfield
FlagMaskComments
sun0x1

If set, gives this lens flare a Ray of Buddha effect. This flag is already implied for any lens flare with occlusion radius of 50 (typically used by sky lights).

no occlusion test0x2

If enabled, skips checking if this lens flare is occluded. It will render regardless of any obstructions in the way like BSP. This also prevents reflections from fading out when the flare's origin goes off-screen.

rotation functionenum
OptionValueComments
none0x0
rotation a0x1
rotation b0x2
rotation translation0x3
translation0x4
rotation function scalefloat
  • Default: 360

Yes, the default is indeed 360 radians.

horizontal scalefloat
  • Default: 1

Scales the lens flare's first reflection horizontally by this factor. Ignored and assumed 1 if this is set to 0.

vertical scalefloat
  • Default: 1

Scales the lens flare's first reflection vertically by this factor. Ignored and assumed 1 if this is set to 0.

reflectionsBlock
  • HEK max count: 32
FieldTypeComments
flagsbitfield
FlagMaskComments
align rotation with screen center0x1
radius not scaled by distance0x2
radius scaled by occlusion factor0x4
occluded by solid objects0x8
bitmap indexuint16
positionfloat
  • Unit: along flare axis
rotation offsetfloat
radiusBounds
  • Unit: world units
FieldTypeComments
minfloat
maxfloat
radius scaled byenum
OptionValueComments
none0x0
rotation0x1
rotation and strafing0x2
distance from center0x3
brightnessBounds
  • Min: 0
  • Max: 1
FieldTypeComments
minfloat
maxfloat
brightness scaled byenum?
tint colorColorARGB
FieldTypeComments
alphafloat
redfloat
greenfloat
bluefloat
color lower boundColorARGB?
color upper boundColorARGB?
more flagsbitfield
FlagMaskComments
interpolate colors in hsv0x1
more colors0x2
animation functionenum
OptionValueComments
one0x0
zero0x1
cosine0x2
cosine variable period0x3
diagonal wave0x4
diagonal wave variable period0x5
slide0x6
slide variable period0x7
noise0x8
jitter0x9
wander0xA
spark0xB
animation periodfloat
  • Unit: world units
  • Default: 1
animation phasefloat
  • Unit: world units

Acknowledgements

Thanks to the following individuals for their research or contributions to this topic:

  • Conscars (Tag field testing)
  • Kavawuvi (Invader tag definitions)
  • MosesOfEgypt (Tag structure research)