Lensflare

A Lens Flare adds the optical aberration caused by the dispersion of light entering the lens through its edges.

Based on ektogamat/R3F-Ultimate-Lens-Flare.

import { LensFlare } from '@react-three/postprocessing'

return <LensFlare />

Ignoring occlusion on some objects

To disable the occlusion effect, simply add userData={{ lensflare: 'no-occlusion' }} to your object/mesh props.

Improving performance

Use bvh <bvh><Scene></bvh> to enhance the internal raycaster performance.

Limitations

The Ultimate Lens Flare leverages the raycaster to examine the material type of objects and determine if they are MeshTransmissionMaterial or MeshPhysicalMaterial. It checks for the transmission parameter to identify glass-like materials. Therefore, for an object to behave like glass, its material should have either transmission = 1 or transparent = true and opacity = NUMBER. The effect automatically interprets the opacity NUMBER value to determine the brightness of the flare.

Credits

Example

R3F Lens LensFlare Example
R3F Lens LensFlare Example