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

Author Topic: Is it possibile to something like this with blending?  (Read 2786 times)

0 Members and 1 Guest are viewing this topic.

Neomex

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Is it possibile to something like this with blending?
« on: December 30, 2011, 03:37:17 pm »
Hey there,
Let's say I've got two Sprites, both are invisible to player, but when sprite B ( object ) is drawn on sprite A ( background ), part of A is shown.
What would be best way to achieve such effect, allowing two 'B objects' to blend only with A?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Is it possibile to something like this with blending?
« Reply #1 on: December 30, 2011, 04:07:17 pm »
Most likely render to texture and/or pixel shaders. Are you trying to do some kind of light cones or light sources in general?

Neomex

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Is it possibile to something like this with blending?
« Reply #2 on: December 30, 2011, 04:31:59 pm »
Planning to make some nice effect (hoping it will be nice), not light related.

So I would probably have to set all pixels alpha channel in background to 0, to make it transparent, and then when another sprite shows on top of it, switch related background pixels to not-transparent, seems like a hard thing with extremely low shader writing experience.

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Is it possibile to something like this with blending?
« Reply #3 on: December 31, 2011, 12:20:04 am »
My first (quick and poorly thought out) solution would be this:

Render both sprites with 50% opacity to an empty target. Create a sprite from this and render that with a fragment shader that simply discards a pixel if the opacity is anything less than 100%

Lynix

  • Sr. Member
  • ****
  • Posts: 403
    • View Profile
Is it possibile to something like this with blending?
« Reply #4 on: December 31, 2011, 01:46:06 pm »

 

anything