Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Simulating Lens Flares? 20

spectecjr asks: "Everyone's seen lens flare effects being used in various 3D games recently (including Half Life, Unreal Tournament, etc); but typically, these effects are simulated using Photoshop to create textures which are then billboarded to the screen. So how do the people who write Photoshop plug-ins simulate lens flares? All the tutorials on the 'net seem to be of the nature of the fake-out method used above. So if you were going to write a lens flare simulation from scratch, how would you do it?" Interesting question. It would be interesting to know the mathematics behind modeling lens flares, using the Photoshop model and more realistic models, if they exist.
This discussion has been archived. No new comments can be posted.

Simulating Lens Flares?

Comments Filter:
  • Hmm. (Score:3, Informative)

    by Tomun ( 144651 ) on Saturday September 29, 2001 @06:41PM (#2369052)
    this page [jonathanclark.com] says that the appearance of the flare depends on the kind of camera that produced it. So if you want to simulate a flare the first question should be "what type of camera am I trying to simulate?"
    • Re:Hmm. (Score:5, Informative)

      by CyberLife ( 63954 ) on Sunday September 30, 2001 @01:32AM (#2369720)
      Actually, the camera has almost nothing to do with it. It's internal reflections within the lens, hence the name. Essentially, it all boils down to the fact that glass isn't a perfect conductor of light.

      As light enters a lens, most of it is refracted towards the optical center. Some however is specularly reflected back towards the source just like it bounced off a mirror. When this happens on the outer lens element, the light just goes back into the scene. But when it happens on an inner element, it has to go back through other pieces of glass, each of which has the potential to re-reflect it back towards the film.

      Most light in a scene isn't strong or coherent enough to cause any noticable effect. If however you have a strong, concentrated stream of light (e.g. the sun) then you will see a series of reflections arranged in a line intersecting the light source and the optical center of the lens. That's why in moving images lens flares always seem to pivot around the center of the frame.

      Not all lens flares look the same either. The construction of the lens and the aperture settings can affect how it looks. Some flares consist of multi-faceted shapes such as octogons. This is caused by the aperture of the lens (made of many straight pieces) being less than fully-open.

      One of the more popular flares is oval shaped with bright, blue horizonal lines. The oval shape is a result of using an anamorphic image format. In this kind of system, the lens compresses the image horizontally to fit more information into a small frame area, and then a complementary lens is used on the projector to stretch it back out for presentation. If a flare happens inside the camera lens after the compression stage, it's recorded on film as a circular image. But when that circle is projected, it's streched out with the rest of the frame and becomes an oval.

      The blue lines effect seems to be an artifact that's unique to Panavision lenses. Although due to it's popularity I have heard of other lens makers trying to copy it.

      Even strong lights outside the frame can cause problems. This stems from the fact that lenses and frames are different shapes. The round lens draws in more light than what is actually recorded in the rectangular frame. This extra light can still bounce around the lens and get reflected into the shot. This is why higher-end photographers (especially those in the motion picture industry) use matte boxes. These rectangular housings fit around the front of the lens and hold black, opaque masks called mattes between the lens and the scene. These mattes have a rectangular hole in them just big enough to be oustide the frame line. The point is to keep all light out of the lens except what is necessary to fill the frame.

      - Milo Hyson
      CyberLife Labs/CyberLife Pictures

  • Gamedev.net (Score:3, Informative)

    by John Jorsett ( 171560 ) on Saturday September 29, 2001 @09:57PM (#2369394)
    Take a look at this article [gamedev.net] on gamedev.net. It might contain what you're after.
    • How in the world was this flame bait? The referred page does talk about constructing lens flares, there's not a goat.cx [www.goat.cx] image to be seen and even seems fairly well written.
  • by TheLink ( 130905 ) on Sunday September 30, 2001 @09:04AM (#2370115) Journal
    Sure simulating fog, heat mirages would make things look more realistic but why are people simulating lens flares? When was the last time you got lens flares in your normal vision?

    If you are seeing weird stuff like that in real life maybe you have glaucoma or need to consult an eye doctor ASAP :).
    • We're used to seeing lens flares in movies and TV. Intentionally adding them to games and other CGI makes the experience more cinematic, giving it a little edge of fantasy.
    • well... when my glasses and windshield are dirty enough, i get some approximation of a lens flare
    • You can get a "flare" in your normal vision... after all light does go through a lens in your eye. I know it's nothing like the ones we see in movies and TV, but if you stare at the right light, you'll get a glow or some streaking effect (especially if your eye is a little watery... try it with christmas lights) Ummm... last time that I got a lens flare in my normal vision was when I was driving home today from the bright lights of a car, and I have perfect vision, so I'm not gonna be rushing out to my eye doctor soon...

      There's always a reason to do something...
      • Little after-thought...

        What if the guy wanted to use it for a game where you have a movie clip or some sort of cinematic event? Or say they're looking through glass in goggles, a helmit, cockpit, or anything (...driving in a car...), and the glass isn't perfectly clear, which might produce a streak/flare.... again, there's always a reason to do something...
    • Isn't it obvious? He's trying to insert Forest Gump into the Zapruder film.
  • by Bazman ( 4849 ) on Monday October 01, 2001 @05:30AM (#2372848) Journal
    Gimp has a lens flare simulator in its FlareFX plug-in. Why not get the gimp source and find out how it does it? An option not available for the Photoshop version.

    Baz
  • People are used to this camera artifacts, and think something is wrong if they are missing.

    Maya (http://www.aliaswavefront.com) for example not only offers lens flares but field of view (so the backgroung and foreground are blury, and only the mid-ground is in focus - or whatever you want).

    Alias also has some code to add or remove the distortion from panavision cameras (camera used by movie companies).

  • As an artist, I have seen entirely too many lens flare effects used in print and other static media. It seems to me that people try to use the addition of a flare to add excitement to an image, but it has become too much.... As far as games and other interactive media are concerned, however, I think that the use of the lens flare could be nice.... Think about driving a car up a hill towards the west in the evening...as you crest the hill, you are temporarily blinded. This could be another interesting use for lens-flare like image manipulations.... I do not have any idea how the math behind the photoshop filter works, but it could be very useful to explore, and possibly create new ways of manipulating the virtual in ways that cannot yet be done in the physical world.... This kind of visual stimulus could really change perceptions! Now thats exciting.
  • POV-Ray is a great freeware raytracing engine for Win, Mac, and Unix. It makes use of an easy to learn text-format scene description language. There was a set of include files available for POV-Ray that you could use in your scene description to describe the "camera" lenses and thus yield up many teriffic lens flares. I forgot the name of the package, but I think you can still find it in the contrib section. Very impressive!

    http://www.povray.org/ [povray.org]

If a thing's worth having, it's worth cheating for. -- W.C. Fields

Working...