I need some special blend effects, but I'm not sure how to write.
1. Additive with alpha
It works like this:
R = MIN(dR + sR*A, 255)
G = MIN(dG + sG*A, 255)
B = MIN(dB + sB*A, 255)
In which A is a custom alpha factor.
2. Color additive
I don't know how to call this. Basically it uses additive blend to source image with a color before using normal alpha blend with destination image.
Maybe it can be divided into 2 steps, but I don't know how to blend a color instead of an image.
3. ...
Again I don't know how to call this. It is similar to 1.
R = MIN(dR + sR*sR, 255)
G = MIN(dG + sG*sG, 255)
B = MIN(dB + sB*sB, 255)
4. Can I use an external alpha mask?
Can someone helps me with blend mode?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Can someone helps me with blend mode?
This is not helping much.MarekkPie wrote:[links to the wiki without any explanation]
With A = 1 - sA, this is equivalent to the "premultiplied" blend mode coming in LÖVE 0.8. The premultiplied blend equation is:utunnels wrote:1. Additive with alpha
Code: Select all
R = srcR + (1 - srcA) * dstR
Use love.graphics.setColor(r,g,b,a) before drawing the image. This will tint the image in the defined color. Be sure to reset it to white afterwards.utunnels wrote:2. Color additive
This is not possible without pixel effects (coming in 0.8).utunnels wrote:Again I don't know how to call this. It is similar to 1.
Not with blend modes, but it is possible with pixel effects. 0.8 will also introduce stencils, which are sort of an alpha map (but then again, they aren't). With stencils, you can set some regions to be fully opaque, whereas others will be fully transparent.utunnels wrote:4. Can I use an external alpha mask?
[1] In theory this should be possible and there was some discussion about allowing the user to define new blend modes by exposing the underlying blend equations quite a while ago, but as it stands, this will not happen.
Re: Can someone helps me with blend mode?
Not exactly, the original equation (you may notice, I'm trying to port something) is based on additive, except a custom alpha is applied to the source image.vrld wrote:With A = 1 - sA, this is equivalent to the "premultiplied" blend mode coming in LÖVE 0.8. The premultiplied blend equation is:There is no (easy) other way to set A to a custom value.Code: Select all
R = srcR + (1 - srcA) * dstR
However, I just tested setColor works perfectly for adding custom A, so this is solved.
Code: Select all
love.graphics.setColor(255,255,255,128)
love.graphics.setBlendMode("additive")
love.graphics.draw(sprite, 200, 200)
But setColor doesn't make the image brighter, if I recall correctly?Use love.graphics.setColor(r,g,b,a) before drawing the image. This will tint the image in the defined color. Be sure to reset it to white afterwards.
For example, a pixel is (128,128,128), after using setColor(128, 0 0) it becomes (64, 0, 0) instead of (255, 128, 128)
I see.This is not possible without pixel effects (coming in 0.8).
Maybe that is what I want.0.8 will also introduce stencils, which are sort of an alpha map (but then again, they aren't). With stencils, you can set some regions to be fully opaque, whereas others will be fully transparent.
I want to make some sort of window shutter effect like those transitions in PowerPoint.
Who is online
Users browsing this forum: No registered users and 80 guests