BetterLensFlare

Small contribution. Lens flare effect that JME lacked. It is a target-based effect which means that it requires a model to track position. Because of this it cannot be used for model-less sun effects displayed on skybox. There is a much simpler lightmap based Lens Flare for that written by t0neg0d here:

https://hub.jmonkeyengine.org/t/lens-flare-code-small-update-screens/23796

but I am not a great fan of such effects because they are essentially beyond control. Lightmap-based effects are pure postprocessing effects which aren’t aware of the environment. Target based lens flare is more complicated as it needs a geometry on the screen to track. It uses raycasting for this. With this method you apply lens flare on things that not necessarily are bright and remain full control over the effect.

The effect is built as a state. It should be backed by a BloomFilter outside of the lib. In the test I used the core bloom, but it’s kinda crappy. I recommend using MipmapsBloom from ShaderBlowEx lib. Bloom effects hides deficiencies of the effect i.e when the model’s origin point gets occluded and raycasting says it’s hidden while almost half of it is still visible. It doesn’t matter with fast-paced games but if you are moving slowly you can tell the difference.

Features:

  1. Target based - tracks specific model.
  2. Fake bloom - adds fake glow on top of the target.
  3. Anamorphism - vertical light distortion.
  4. Streaks - sun rays - two types- regular and advanced.
  5. Ghosts + Distortion - light dots.

https://jmonkeystore.com/d483a361-60de-4ebc-94d2-9096084010f5

5 Likes

Looks cool :slightly_smiling_face: