SFML community forums

Help => Graphics => Topic started by: Lo-X on June 27, 2011, 07:20:21 pm

Title: [Solved] How to : Flash light
Post by: Lo-X on June 27, 2011, 07:20:21 pm
Hi,

I would like to have a big Flash Light for my game when something explode.
But I don't know how to proceed, I think that I may use Shaders, but on what ?
A sprite ? The shader will only be applied on the texture of the sprite so, bad idea
A render image ? But how can I have the flash ?

If you have some advices, it will be with pleasure =)
Title: [Solved] How to : Flash light
Post by: Cuban-Pete on June 27, 2011, 07:28:38 pm
You could flash the whole screen with a white image. ...but people might get an hearth attack because of it. What you could also do is shake the camera a little.  :)
Title: [Solved] How to : Flash light
Post by: Lo-X on June 27, 2011, 07:34:40 pm
Quote from: "Cuban-Pete"
You could flash the whole screen with a white image. ...but people might get an hearth attack because of it. What you could also do is shake the camera a little.  :)


Shake the camera is a great idea, but flash the whole screen is a bit radical.


Edit : I found this : http://www.gamedev.net/topic/304874-looking-for-spotlight-shader-tutorial/
Someone say that Shader is not the great solution, so I will searsh with the light manager tutorial on the wiki
Title: [Solved] How to : Flash light
Post by: Jove on June 27, 2011, 08:20:41 pm
Create a sprite graphic in an image editor that is a circular gradient which fades out the transparency along with the colours (use greys); so it would be white in the middle, going out to dark/transparent.

In the game place the sprite where the light bloom should be then expand its X/Y scale quickly whilst rapidly reducing the alpha channel to zero.

I stumbled across this while working on my game (a spacey shooter) and it's very effective indeed, without the need for shaders. It creates a very convincing flash of light.

Let me know if you want an example .PNG and I'll send it to you.

** EDIT -> Additive blend mode is your friend.
Title: [Solved] How to : Flash light
Post by: Lo-X on June 27, 2011, 10:07:42 pm
Yes if you can show me an example
I thought about the blend mode while reading a light tutorial

and.. thank you !
Title: [Solved] How to : Flash light
Post by: Jove on June 27, 2011, 11:10:25 pm
Here's the .PNG which is 192x192 size for up-scaling purposes:

(http://www.jestofevekites.com/markc/bloom.png)

Here's what it looks like in action :

(http://www.jestofevekites.com/markc/screengrab.png)

On the far right is the player's ship being hit and shedding particles. Around the ship is the light flash/bloom effect from the above image.

You can actually do quite a lot of very impressive visual effects with SFML just using the right kind of images and some particle code/blending techniques.  The same lightweight particle engine I use to create that effect can also easily create sparks (just visible) and also great big fire effects!

Hope this helps.
Title: [Solved] How to : Flash light
Post by: Lo-X on June 28, 2011, 01:19:54 am
Quote from: "Jove"
Hope this helps.


Yes a lot. Big fat thank you :D
Ps: I've made my own flash image
Title: [Solved] How to : Flash light
Post by: OniLinkPlus on June 28, 2011, 06:30:15 am
Creepers! Creepers everywhere!