Page 1 of 1

Color blending help

Posted: Mon Jul 24, 2023 9:14 am
by Gunroar:Cannon()
I have a light system that changes the alpha value of items depending in how far they are away from light. The problem is that they appear see through when far and infront of an object. I know I could instead multiply the color of the item by its alpha value and set BlendModeAlpha to "premultiplied" but I was hoping there was another solution that doesn't involve touching the item's color.

Re: Color blending help

Posted: Tue Jul 25, 2023 1:39 pm
by Gunroar:Cannon()
Is it that my request doesn't make sense or ... (I see how it might not make sense)

Like picture 1 is drawn.

Then I want to draw another picture (2) on top of that one but darker just by changing opacity only.

But now picture 1 can be seen through picture 2.

Any fix?

Re: Color blending help

Posted: Tue Jul 25, 2023 1:44 pm
by darkfrei
Show pictures what you have and what you want.

Re: Color blending help

Posted: Wed Jul 26, 2023 6:03 pm
by Gunroar:Cannon()
Ahhh... getting a screenshot currently would be kind of inconvenient ... but I have this picture:

Image

Where the transparent boos (ghosts) are what I'm getting but I just want them to be the same dark shade while not being see-through. Is it possible?

Re: Color blending help

Posted: Wed Jul 26, 2023 6:08 pm
by UnixRoot
I'm not sure if I understand your problem, but couldn't you just render the darker sprites to a separate canvas and make the whole canvas transparent instead of every single sprite?

Re: Color blending help

Posted: Wed Jul 26, 2023 9:52 pm
by zingo
To render a sprite darker, but without any transparency, I think you could just set the red, green, and blue values before you draw whatever you want to draw, and then reset the color back to normal. If you don't want your sprites to be "see through", then there's no need to mess with alpha values at all. I hope this is sort of what you are going for.

Code: Select all

function love.draw ( )

--less color saturation should result in whatever is drawn
--appearing darker.

 love.graphics.setColor (0.5, 0.5, 0.5) 
  --draw your darker ghost here
 love.graphics.setColor (1, 1, 1)
  --whatever is drawn after this will be drawn normally.
end

Re: Color blending help

Posted: Mon Jul 31, 2023 7:04 am
by Gunroar:Cannon()
Yes. that achieves what I wanted, but the thing is I was cheap. :)

I used a variable that holds the alpha value so I could change a creative's light just by alpha and told myself "I'm sure there's a way to make it so the alpha doesn't actually make it see through using shaders, blendmodes, or something". Oh well.