Hello all,
Today I’m releasing a simple lens flare system I wrote for an upcoming game of mine. This uses ParticleEmitters to achieve a lens flare effect, which also gives nice bloom and also allows for additive blending. This system is meant to be simple to use, so customization of lens flares is mainly achieved by using CollectionService to tag parts to put flares on, as well as attributes to customize flare type, distance, and strength.
Video Demonstration
Using Lens Flares
To start, just put the LensFlare folder into ReplicatedStorage.
Tag parts that you want to attach lens flares to with LensFlare. You can configure the type of lens flare added with the LensFlareStyle attribute. By default, the system comes with two types: Default and SmallLight.
You can further customize the flare with LensFlareDistance and LensFlareStrength.
- Distance adjusts the fade for the flare as you get further away from it. A value of 0 will make the flare visible from everywhere.
- Strength adjusts the opacity of the lens flare. 1 is the maximum opacity.
By default, a lens flare effect is also applied to the sky.
Creating Lens Flare Styles
Simply clone one of the existing folders under LensFlare.Assets to get started. As stated before, this system uses ParticleEmitters, so you should only use those when creating lens flares.
You can set up ParticleEmitters as you normally would, except for Size, Transparency, and Squash. These are controlled by Attributes you will apply which are listed below.
Positional Attributes
- Position: A
Vector3 / vectorattribute that describes how the emitter will be placed on screen. Note: Z position is not used.- The value of the X, Y coordinates determines whether the emitter is placed opposite of the source. A position of
1, 1places the emitter right at the source of the flare while a position of-1, -1places the emitter at the opposite end from the flare’s source, which is useful for lens flare ghosts. - A position of
-1, 1can be useful for anamorphic effects - it aligns it with the Y coordinate of the flare but on the opposite X coordinate.
- The value of the X, Y coordinates determines whether the emitter is placed opposite of the source. A position of
- PositionMult: A
numberscalar value which multipliesPositionby this amount. An easier way to describe the distance from the source of the flare.
Sequence Attributes
Note: Time 0 describes how the emitter looks when looking directly at the flare - time 1
describes how the emitter looks when it is off-screen.
All sequence attributes can simply just be set to one number if you want it to be consistent no matter the viewing angle.
- SizeFade: A
NumberSequencethat describes the size of the emitter depending on the angle the flare is viewed from. - TransparencyFade: A
NumberSequencethat describes the transparency of the emitter depending on the angle the flare is viewed from. - SquashFade:
A NumberSequencethat describes the squash of the emitter depending on the angle the flare is viewed from.
Miscellanous Attributes
- ColorBlend: A
numberattribute describing how much the ParticleEmitter inherits the hue of thePartthe lens flare is attached to. For example, settingColorBlendto1on a flare attached to a red part results in the emitter being turned red. - Rotates: A
booleanattribute that determines whether or not the emitter rotates as the viewing angle changes.
All attributes can be changed at run-time for easier experimentation!
Scripting API
There is a small scripting API associated with the system.
LensFlare.new(camera: Camera, flareStyle: string, part: BasePart): LensFlare
Creates a new Lens Flare object with specified camera, flare style, and part.
LensFlare.Destroy(self: LensFlare)
Destroys the Lens Flare and unhooks connections.
LensFlare.Update(self: LensFlare)
Updates all emitters and positions of attachments, and also checks for obstruction between flare source and camera. Note: a function hooking to RunService already calls this when you instantiate a new LensFlare.
Properties
LensFlare.Enabled: Determines whether the Lens Flare will be updated and rendered. This doesn’t affect LensFlare.Update, only the function inside the constructor that calls it.
LensFlare.Alpha: Strength of the lens flare taking into account distance and viewing angle.
Get it here!
https://create.roblox.com/store/asset/89532403908041/Lens-Flare-System
Demo place
If you have any feedback about the system, please let me know! This is my first post here, so there’s probably bound to be some issues. I’ll try and respond in a timely manner!
Attribution
Giving credit is not required, but appreciated!



