SFML community forums
Help => Graphics => Topic started by: Robustprogram on June 30, 2014, 06:54:30 am
-
I have a poorly pieced shadow system and I am just wondering how to blend both the shadows and light together as I have absolutely no idea how to blend it together. Any help will be appreciated :D
-
Btw this is the best I could do with render Textures ...
I am hopeless XD
-
What have you tried exactly?
Have you already had a look at existing libraries like Let There Be Light or GLLight2D?
-
I tried to use the SFML standard blendmodes by having the lights get drawn onto a rendertexture with blendmode Add for the light and Multiply for the shadow. I then applied the rendertexture to a sprite and I draw the sprite with no other blendmodes.
Also I had a look at both libraries you posted but both of them use OpenGL and that is going to open up more problems as I haven't worked with OpenGL before and just ran into problems when I ran some tests with OpenGL.
-
I have not worked with those two libraries, but don't they abstract from OpenGL?
Also, there are meanwhile far more blendmodes than the four in SFML 2.1. Check out the latest master branch if you're interested.
-
Simplest to implement:
http://en.sfml-dev.org/forums/index.php?topic=14154.msg99530#msg99530
Complicated but potentially more efficient:
Use the shadow geometry to clip the light geometry and accumulate the lights in a single render texture using additive blending, then apply that render texture to the scene using multiplicative blending.
http://www.redblobgames.com/articles/visibility/
-
@Lee R. Holy crap, thanks for the tip as I have finally implemented a shadow system now :D
But speaking on clipping, how do we clip in sfml. One thing I was interested in was it possible to clip the area from displaying the light at all.
But still thanks for the example as it really helped me