4

I want to create a lens flare in OpenGL C++. I referred this video and star rendering code.

double calculateGlowSize(double diameter, double temperature, double distance) {
    static const double DSUN = 1392684.0;
    static const double TSUN = 5778.0;

    // Georg's magic formula
    double d = distance; // Distance
    double D = diameter * DSUN;
    double L = (D * D) * pow(temperature / TSUN, 4.0); // Luminosity
    return 0.016 * pow(L, 0.25) / pow(d, 0.5); // Size
}

but i want the output to be more like the image shown below.

enter image description here

How do i create a lens flare effect?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Suraksha Ajith
  • 872
  • 2
  • 12
  • 23
  • See [Finding distance to an LED](https://stackoverflow.com/a/42764104/2521214) to distinguish what kind of effect you want. In your image I see scattering (that glow) , light trap or charge jump (the horizontal brightest line) and iris flare (those thinner bright lines emitting from center of light source). I do not see any lens flare (like in your video) So which one you really want or all of them ? Some games fake those with alpha blending and animated texture. The flares are usually dependent on the angle between center screen ray and Light source which is converted to displacement. – Spektre Aug 06 '17 at 13:16
  • In the links here: [Is it possible to make realistic n-body solar system simulation in matter of size and mass?](https://stackoverflow.com/a/28020934/2521214) you can find some stuff needed for your app (like BV to RGB etc) – Spektre Aug 06 '17 at 13:20
  • from quick search this looks promising [Pseudo Lens Flare](http://john-chapman-graphics.blogspot.sk/2013/02/pseudo-lens-flare.html) – Spektre Aug 06 '17 at 13:34

0 Answers0