SFML community forums

Help => Graphics => Topic started by: GalakTozawr on May 07, 2014, 09:32:53 pm

Title: Dynamic light(shadow), as create?
Post by: GalakTozawr on May 07, 2014, 09:32:53 pm
(http://4.firepic.org/4/images/2014-05/07/gamtwab5b3rg.png)
(http://4.firepic.org/4/images/2014-05/07/7dyvqv1z5v4e.png)
(http://4.firepic.org/4/images/2014-05/07/2jf1i57ihq6i.png)
Light should move.
what tools are needed for this?
An example of what I want to get:
(http://4.firepic.org/4/images/2014-05/07/iwqtxog3t172.gif)
Only moving light areas must be many.
Title: Re: Dynamic light(shadow), as create?
Post by: Nexus on May 07, 2014, 09:45:50 pm
There are different possibilites. The simplest one would be a texture that acts as a stencil/mask and that is drawn on top of the colored image. Use the latest master revision on GitHub to benefit from the new sf::BlendMode class.

An alternative is a GLSL fragment shader.
Title: Re: Dynamic light(shadow), as create?
Post by: GalakTozawr on May 07, 2014, 09:57:08 pm
Sorry to bother you, you can give sample?

Or how to implement lighting as there:
https://www.youtube.com/watch?v=WBQxB4DqY7Q#t=28

Or some simple lighting system. And my happiness will unlimited!
I use sfml 2.1

Title: Re: Dynamic light(shadow), as create?
Post by: Nexus on May 07, 2014, 10:21:46 pm
Basically:
sf::BlendMode customBlendMode = ...;

window.draw(background);
window.draw(mask, customBlendMode);
This approach is of course limited, but it is able to lighten/darken a constant area. You may not even need custom blend modes if you simply want to darken an existing image.

More is explained in the tutorials and documentation about rendering sprites and blend modes, please read them.

Lighting systems have already been provided as an SFML extension, search for "Let There Be Light" and "GLLight2D" in the project forum.