Color blending help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Gunroar:Cannon()
Party member
Posts: 1091
Joined: Thu Dec 10, 2020 1:57 am

Color blending help

Post 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.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
Gunroar:Cannon()
Party member
Posts: 1091
Joined: Thu Dec 10, 2020 1:57 am

Re: Color blending help

Post 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?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
darkfrei
Party member
Posts: 1184
Joined: Sat Feb 08, 2020 11:09 pm

Re: Color blending help

Post by darkfrei »

Show pictures what you have and what you want.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
Gunroar:Cannon()
Party member
Posts: 1091
Joined: Thu Dec 10, 2020 1:57 am

Re: Color blending help

Post 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?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
UnixRoot
Citizen
Posts: 90
Joined: Mon Nov 08, 2021 8:10 am

Re: Color blending help

Post 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?
zingo
Prole
Posts: 44
Joined: Mon Jan 16, 2023 7:34 am

Re: Color blending help

Post 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
User avatar
Gunroar:Cannon()
Party member
Posts: 1091
Joined: Thu Dec 10, 2020 1:57 am

Re: Color blending help

Post 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.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests