"Screen" blend mode
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
"Screen" blend mode
Is is possible in 0.8 to set the blend mode to what in Photoshop is known as screen (GL_ONE, GL_ONE_MINUS_SRC_COLOR)? Painting grey (0.5) over grey (0.5) should result in grey-white (0.75).
Re: "Screen" blend mode
You could definitely do this with a PixelEffect. Just sample two images and put them through the math for a screen effect:
Code: Select all
result = (1.0 - ((1.0 - image1) * (1.0 - image2)))
Re: "Screen" blend mode
Thank you for replying.
After looking at slime's bloom shader and Photoshop math, I came up with this:
While I was figuring this out, I realised that I could only blend two Images/Canvases with this shader, and that I can't use it "on the fly", blending colours as I draw e.g. rectangles on top of each other. Is this correct? Is it somehow possible to blend colours on the fly?
After looking at slime's bloom shader and Photoshop math, I came up with this:
Code: Select all
#define BlendScreenf(base, blend) (1.0 - ((1.0 - base) * (1.0 - blend)))
#define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
#define BlendScreen(base, blend) Blend(base, blend, BlendScreenf)
extern Image texture;
vec4 effect(vec4 color, Image drawn, vec2 texture_coords, vec2 pixel_coords) {
vec4 base = Texel(drawn, texture_coords);
vec4 blend = Texel(texture, texture_coords);
return vec4(BlendScreen(base.rgb, blend.rgb), 1);
}
Re: "Screen" blend mode
Do you actually need the Screen blend mode, or would simple additive blending work? Try playing around with love.graphics.setBlendMode("additive")
Re: "Screen" blend mode
Thank you for your answers. I've abandoned the idea of using that particular blend mode. I have come to understand more about shaders, so it was not for naught.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 6 guests