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.
Hmm. (Score:3, Informative)
Re:Hmm. (Score:5, Informative)
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
Re:Hmm. (Score:1)
Gamedev.net (Score:3, Informative)
Re:Gamedev.net (Score:1)
What's the point of simulating an aberration? (Score:3, Flamebait)
If you are seeing weird stuff like that in real life maybe you have glaucoma or need to consult an eye doctor ASAP
Re:What's the point of simulating an aberration? (Score:1)
Re:What's the point of simulating an aberration? (Score:1)
Re:What's the point of simulating an aberration? (Score:1)
There's always a reason to do something...
Re:What's the point of simulating an aberration? (Score:1)
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...
Re:What's the point of simulating an aberration? (Score:2)
You use it all the time. It's called binary (except when you add numbers, you don't carry the 1). Modulo 2 arithmetic.
XOR is based on this. CRC checksums are based on this. Most crypto appears to be based on this. It's not exactly 'useless'.
Simon
Re:What's the point of simulating an aberration? (Score:1)
First off... where the hell did you get that form?? 1=3?? (without changing bases)
Second, If discovering a new way to do something "runravel"'s (???) the universe, then the system of the universe that we believed in wasn't true to begin with.
Re:What's the point of simulating an aberration? (Score:2)
Use the source, Luke. (Score:4, Informative)
Baz
Not only flares but distortion etc (Score:1)
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).
visual overload (Score:1)
Check out POVRay (Score:1)
http://www.povray.org/ [povray.org]