Someone could recommend a good 'Flare' function??

Blitz3D Forums/Blitz3D Userlibs/Someone could recommend a good 'Flare' function??

Pinete(Posted 2007) [#1]
Hi all,
I've been looking for 'flares' functions/libs at the forums and I've tried some of them, but i've not achieved a good one...
Some of them are very slow and other ones are too complicated..
Could you please recommend me a good flare function or lib to use in my game, with media, if it is possible?

Thanks in advance!


JoeGr(Posted 2007) [#2]
You mean lens flares? This one is very good:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1107


Pinete(Posted 2007) [#3]
Thanks JoeGr,

I've deal with this one and I've encountered various issues..
the first one is this lib is slow... In its code there are a lot of picks and that's not important managing the demo scene but beyond that, it is.
The second issue is it uses spritecontrol to draw the flares, I've used spritecontrol during a lot of time and it has some bugs that make it very unstable under some circumstances..

I'm looking for something more simple.
However, and of course, thanks a lot, really for recommend me this one!
:)

More ideas will be wellcome!


JoeGr(Posted 2007) [#4]
IIRC if you take out the code that changes the colour of the flares then it gets a lot faster - easily fast enough to use in most situations I would have thought - and it still looks good. I doubt you'll find a much better system to be honest.

What bugs have you found with sprite control? I'm using it for something at the moment so I'm interested to know.


Pinete(Posted 2007) [#5]
Hi JoeGr,

Thanks for your response.
I remember spritecontrol was one of the first libraries I used because it seemed to me very usable, easy and fast.
I didn't remember exactly but I start to use nsprite even being poor in some aspects (it a great library, however) bacause spritecontrol gave me MAV errors sometimes and messages saying that certains sprites didn't exist, even being sure those sprites existed and were created...
I'm not being very clear but as I said, to be honest, I just remember I was researching for a week what was the reason I got that errors and I didn't achieve very much.

If Spritecontrol is ok for you, continue using, of course, because I cannot give you more details in order to recommend you any other lib.

Best regards!


Barliesque(Posted 2007) [#6]
One of these days I plan to simplify that code so that it doesn't depend on SpriteControl, most of which it doesn't really even need. I have yet to encounter any problems with MAV's, so I'm betting the fault wasn't really with SpriteControl.

I don't think I was ever really happy with the way the code as a whole was structured--it's not as neatly modular as I'd like. If you have problems with it still, have a look at the comments in the archive where someone was having a problem--it was a matter of things being in the right order I think, and globals being properly initialized. I forget to be honest, so have a look.

As JoeGr says above, you can remove the flare colorizing code and greatly improve performance. Depending on the scene, this feature can run quite well or take a big chunk out of your performance--it's not for all projects. I came up with that for a project that featured stained glass windows in the ceiling, for which the effect was really stunning.


Naughty Alien(Posted 2007) [#7]
..actually i modify this lens flare system for my own purpose and its quite fast without bugs at all..one thing you have to be aware of is also number of objects you are going to use for pick checking, so once you using it properly it should done job just nicely...


John Blackledge(Posted 2007) [#8]
Hey Naughty - nice one.
I'm currently using the lens flare in one of my projects, but it does slow things down.
A faster version would be very welcome.
Will you share?


Pinete(Posted 2007) [#9]
Thanks a lot for your answers!
I agree with John, a faster version would be very welcome!

All the best!


jfk EO-11110(Posted 2007) [#10]
Just a sidenote: For Sunflare you may use something like this. But for an ordinary lightbulb flare you have to find a workaround for the visibility check of the light source. Cause checking a number of bulbs with Linepick may slow things down a lot.

Currently I use bulb flares that are z-sorted normally. Not that great, I know. Any ideas?


Barliesque(Posted 2007) [#11]
@Pinete:
I think what Naughty Alien is saying is not that he's optimized the code, but that he's using it carefully to get a speed increase--carefully choosing as few entities as possible to make pickable for linepicks.

@jfk:
I think you could use this method for lightbulbs as well, but you'd need to keep track of a shortlist of linepicks for each lightbulb. If a lightbulb isn't on screen, then there's no need to do any linepicks for it. If you've got a room with several bulbs, then you'll probably be in trouble with too many linepicks--unless, there's nothing in the room that can obscure any of them. In that case, all you need is to figure out whether the camera is inside the room--or something like that. For lightbulbs, you almost certainly don't need to colorize the flare.

Another good idea is to fade and eventually turn off flares the further they are from the camera--of course this doesn't apply to the sun! But you can turn off the sun flare when the camera is indoors.

My example sun flare just demonstrates some flare techniques, but is not a comprehensive solution. I think you would really need to integrate all of these ideas into whatever world loading system you're using. One of these days, I want to come back to this and make it a more fully featured solution, so that you can have an array of light sources, each with their own optimal flare settings.