Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] How to : Flash light  (Read 6125 times)

0 Members and 1 Guest are viewing this topic.

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
[Solved] How to : Flash light
« 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 =)

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
[Solved] How to : Flash light
« Reply #1 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.  :)

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
[Solved] How to : Flash light
« Reply #2 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

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
[Solved] How to : Flash light
« Reply #3 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.
{much better code}

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
[Solved] How to : Flash light
« Reply #4 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 !

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
[Solved] How to : Flash light
« Reply #5 on: June 27, 2011, 11:10:25 pm »
Here's the .PNG which is 192x192 size for up-scaling purposes:



Here's what it looks like in action :



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.
{much better code}

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
[Solved] How to : Flash light
« Reply #6 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

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
[Solved] How to : Flash light
« Reply #7 on: June 28, 2011, 06:30:15 am »
Creepers! Creepers everywhere!
I use the latest build of SFML2