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

Author Topic: Light and Shadow Blending  (Read 2577 times)

0 Members and 1 Guest are viewing this topic.

Robustprogram

  • Newbie
  • *
  • Posts: 10
    • View Profile
Light and Shadow Blending
« 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

Robustprogram

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Light and Shadow Blending
« Reply #1 on: June 30, 2014, 07:11:19 am »
Btw this is the best I could do with render Textures ...

I am hopeless XD

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Light and Shadow Blending
« Reply #2 on: June 30, 2014, 08:02:05 am »
What have you tried exactly?

Have you already had a look at existing libraries like Let There Be Light or GLLight2D?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Robustprogram

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Light and Shadow Blending
« Reply #3 on: June 30, 2014, 09:06:41 am »
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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Light and Shadow Blending
« Reply #4 on: June 30, 2014, 10:27:09 pm »
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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Re: Light and Shadow Blending
« Reply #5 on: July 01, 2014, 01:06:15 am »
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/

Robustprogram

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Light and Shadow Blending
« Reply #6 on: July 01, 2014, 04:57:02 am »
@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

 

anything