Lenz Flarez!!!11!

Started by Ryan Timothy B, Sun 17/01/2010 11:22:07

Previous topic - Next topic

Ryan Timothy B

Alright.  Yesterday I came across Ali's smooth scrolling module and I saw two great words "lens flares".  But his wasn't very impressive at all, so I decided to write up my own lens flares module in less than half a day.  All the lens flares graphics were created by me with the use of gradients and lots of tweaking.

Have a look at the picture:


You can also download the compiled demo here (without source):
www.bryvis.com/entertainment/other/lensflares/lens_flares_brighter.zip (New, brighter effect when you stare at the sun with the camera)
http://www.bryvis.com/entertainment/other/lensflares/lens_flares.zip (Old file)

(Use the arrow keys to move the viewport and watch the lens flares move around and fade in/out depending how far it is from the camera)

Graphics are 800x600, and I used 9 objects to make the lens flares, 1 object for the sun, 1 object for the Earth, and 1 object for the Earth's edge shine. (12 objects in total)


Would anyone find something like this useful?

The Sun (or light source) doesn't have to be static, it can move.  So this could be headlights on a moving car, or a flashlight aiming at the 'camera', or one of those shiny spacecrafts, m0ds catches glimpses of flying through the sky at night ;D, etc.

I have plans on making it so if the light source is covered by rudimentary shapes like circles, rectangles, or triangles, that the lens flares will start to dim until they are not seen anymore.


Let me know what you guys think.  Is it realistic looking?  Or do you have any ideas or suggestions that you'd find useful?
I figured GenGen was the best place for this since the module isn't complete and ready for general use yet, I'm just looking for feedback. :P

Ali

#1
Very nice, Ryan! Much better than the flares in the parallax module.

The one thing that seems to be missing is, when all of the flares coincide, you should fade in a strong flare which whites out the screen. Not long ago I mocked up this kind of flare in after effects, and adding a hint of a rainbow ring around the edges of the screen when flare was got intense helped blend the fake flare with a real flare in video footage.

How customisable are the flare elements, or is it up to the user to create and position them? does the module allow the player to tune intensity?

Great work, I look forward to seeing what comes of this.

Dualnames

I've just checked it too, and to guess from the FOG, those are sprites used to do the lens flare, but Ryan is handling the behaviour of the sprites. Well done, apart from the fact that on direct stare the flare should blink me, it's perfect. I'd love to see a demo with a character moving. And perhaps a demo with Ali's module to smooth camera movement!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ryan Timothy B

#3
Thanks guys.

Yeah I meant to write what it's currently capable of and what the user can tweak.

For everything and each flare this is called in the rep_ex (probably should be rep_ex_always, but at the moment I didn't have any blocking moments, so I didn't care. :P):

function lensflare_flare(int sourceX, int sourceY, Object*obj, int sprite, float distance, int transparency, bool fade, int baseline, optional int viewX, optional int viewY)


SourceX and SourceY: these coordinates are the location that the object evolves around.  So the sun may be: x:100, y:100, but the flares are: sun.x, sun.y because they evolve around the sun (but since the sun or light source 'can' move, is why I've made the flares follow the sun's actual position).

obj: is obviously the object, which makes things easier so you can just do:  obj.X=500, for example.

sprite: is the sprite number. 0 makes it optional, that way if it's optional you could always have an animating flare, sun or light source, instead of just a static sprite.
Also 0 is in case you'd rather just use the graphic you initially set the object at, etc.  All the flares are centered according to the vertical and horizontal center of the sprite image.  So even if your light source or flare is oddly shaped, it will be centered properly, instead of what AGS does with the bottom left corner for objects.

distance: This controls how far from the SourceX and SourceY the object is.  Positive numbers go towards the viewport, and negative numbers go away from the viewport (which I didn't actually use, other than the planet).  0.0: would be static.  It doesn't move from it's evolve point.

transparency: Right now it's a black background, so the flares are pretty easy to see.  All of them in this demo are set at 50% transparency.  So if someone had a brighter background, they could make the flares and such easier to see by decreasing the transparency.

fade: False, means the object doesn't fade when it's further from the viewport, while True does.  The flares fade, but the Sun and Planet do not.

baseline: I decided giving the player control of the baseline would be the best idea.  That way they can customize it to exactly how they see fit.

optional viewX and viewY: If you change this, the thing to affect the light source position wouldn't automatically be the viewport.  The only thing in the demo that I've made not use the viewport to determine the position, is the edge lighting of the planet.  Instead it follows the sun.  That way, if you move the viewport around, it still holds on the correct side of the planet.  I will need to tweak this one a little before releasing it.


That's pretty much it.  The user can control just about everything I can see them needing to.

Yeah, I was thinking about putting in a darkness the more you look at the sun.  I'll update it soon and show you the results.
Also it's only about 25 lines of code, in all. :P  (not including the calling of the lensflare_flare() function in the room scripts)

edit: Sorry, I didn't write that well enough.  I 'think' I'll be adding a darkness on the background whenever you look at the object more.  I might, not sure yet.  But I'll definitely add the blanket of whiteness (center gradient, so the edges are easier to see), whenever you stare at the sun.



EDIT:  Added a Brighter overlay!

You guys better get your glasses out for this one  8), I think It's a huge improvement with it only being one extra object added (13 in total now).
It 'almost' makes me want to squint... almost..
www.bryvis.com/entertainment/other/lensflares/lens_flares_brighter.zip

Matt Frith

This is great Ryan.  I have been looking for a good way to make a stylish effect such as this for a particular room in the game I am currently working on and just like magic, you pop up with this. It's like you are some sort of psychic.

Just great.  Keep up the good work!

m0ds

Yep seems like a neat module Ryan, and it didn't even take a spacecraft in the demo to get me excited  ::)  The effect looks realistic, and I imagine it could funk up some scenes very nicely. Well done!1

Ryan Timothy B

Thanks m0ds. I swear, I'll have a few scenes in the next few releases with little UFO's and such.  I'll try to give demonstrations on what the lens flares can be used on.  :P

Tier: that's cool that you're actually in need of something like this.  That will definitely push me into making it fully functional as an actual module as soon as possible and with a very easy interface (easier and better than the one I posted above, since I've had a few more days to think about it).

eri0o

Sorry for Necroing... But does anyone still has the lens flare module from Ryan Timoothy ?

SMF spam blocked by CleanTalk