Add source-atop and destination-atop
This commit is contained in:
@@ -32,8 +32,10 @@ Blend filters take two inputs ("source" and "destination"), they are intended to
|
|||||||
#### Porter-Duff blends
|
#### Porter-Duff blends
|
||||||
- `SourceIn`, Porter-Duff source-in blend, intersect source and destination opacity and keep source colors
|
- `SourceIn`, Porter-Duff source-in blend, intersect source and destination opacity and keep source colors
|
||||||
- `SourceOut`, Porter-Duff source-out blend, subtract destination from source opacity and keep source colors
|
- `SourceOut`, Porter-Duff source-out blend, subtract destination from source opacity and keep source colors
|
||||||
|
- `SourceAtop`, Porter-Duff source-atop blend, uses destination opacity, layers source on top and keeps both colors
|
||||||
- `DestinationIn`, Porter-Duff destination-in blend, intersect source and destination opacity and keep source colors
|
- `DestinationIn`, Porter-Duff destination-in blend, intersect source and destination opacity and keep source colors
|
||||||
- `DestinationOut`, Porter-Duff destination-out blend, subtract destination from source opacity and keep destination colors
|
- `DestinationOut`, Porter-Duff destination-out blend, subtract destination from source opacity and keep destination colors
|
||||||
|
- `DestinationAtop`, Porter-Duff destination-atop blend, uses source opacity, layers destination on top and keeps both colors
|
||||||
- `Xor`, Porter-Duff xor blend, picks colors from input with highest opacity or none with opacities are equal
|
- `Xor`, Porter-Duff xor blend, picks colors from input with highest opacity or none with opacities are equal
|
||||||
|
|
||||||
#### Various blends
|
#### Various blends
|
||||||
|
|||||||
@@ -89,8 +89,10 @@ class Screen : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragm
|
|||||||
|
|
||||||
class SourceIn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-in.frag")))
|
class SourceIn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-in.frag")))
|
||||||
class SourceOut : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-out.frag")))
|
class SourceOut : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-out.frag")))
|
||||||
|
class SourceAtop : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-atop.frag")))
|
||||||
class DestinationIn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-in.frag")))
|
class DestinationIn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-in.frag")))
|
||||||
class DestinationOut : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-out.frag")))
|
class DestinationOut : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-out.frag")))
|
||||||
|
class DestinationAtop : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-atop.frag")))
|
||||||
class Xor : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/xor.frag")))
|
class Xor : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/xor.frag")))
|
||||||
|
|
||||||
class MultiplyContrast : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/multiply-contrast.frag")))
|
class MultiplyContrast : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/multiply-contrast.frag")))
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0;
|
||||||
|
uniform sampler2D tex1;
|
||||||
|
|
||||||
|
out vec4 o_color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
|
|
||||||
|
float lsrc = src.a * (1.0 - dest.a);
|
||||||
|
float lboth = src.a * dest.a;
|
||||||
|
|
||||||
|
o_color = src * lsrc + dest * 0.0 + dest * lboth;
|
||||||
|
}
|
||||||
@@ -7,9 +7,10 @@ uniform sampler2D tex1;
|
|||||||
out vec4 o_color;
|
out vec4 o_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 a = texture(tex0, v_texCoord0);
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
vec4 b = texture(tex1, v_texCoord0);
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
|
|
||||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
float lboth = src.a * dest.a;
|
||||||
o_color = vec4(na, 1.0) * b.a * a.a;
|
|
||||||
|
o_color = dest * lboth;
|
||||||
}
|
}
|
||||||
@@ -6,9 +6,10 @@ uniform sampler2D tex1;
|
|||||||
|
|
||||||
out vec4 o_color;
|
out vec4 o_color;
|
||||||
void main() {
|
void main() {
|
||||||
vec4 a = texture(tex0, v_texCoord0);
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
vec4 b = texture(tex1, v_texCoord0);
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
|
|
||||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
float ldest = dest.a * (1.0 - src.a);
|
||||||
o_color = vec4(na, 1.0) * max(a.a - b.a, 0.0);
|
|
||||||
|
o_color = dest * ldest;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0;
|
||||||
|
uniform sampler2D tex1;
|
||||||
|
|
||||||
|
out vec4 o_color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
|
|
||||||
|
float ldest = dest.a * (1.0 - src.a);
|
||||||
|
float lboth = src.a * dest.a;
|
||||||
|
|
||||||
|
o_color = dest * ldest + src * lboth;
|
||||||
|
}
|
||||||
@@ -6,9 +6,10 @@ uniform sampler2D tex1;
|
|||||||
|
|
||||||
out vec4 o_color;
|
out vec4 o_color;
|
||||||
void main() {
|
void main() {
|
||||||
vec4 a = texture(tex0, v_texCoord0);
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
vec4 b = texture(tex1, v_texCoord0);
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
|
|
||||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
float lboth = src.a * dest.a;
|
||||||
o_color = vec4(nb, 1.0) * a.a * b.a;
|
|
||||||
|
o_color = src * lboth;
|
||||||
}
|
}
|
||||||
@@ -6,9 +6,10 @@ uniform sampler2D tex1;
|
|||||||
|
|
||||||
out vec4 o_color;
|
out vec4 o_color;
|
||||||
void main() {
|
void main() {
|
||||||
vec4 a = texture(tex0, v_texCoord0);
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
vec4 b = texture(tex1, v_texCoord0);
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
|
|
||||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
float lsrc = src.a * (1.0 - dest.a);
|
||||||
o_color = vec4(nb, 1.0) * max(b.a - a.a, 0.0);
|
|
||||||
|
o_color = src * lsrc;
|
||||||
}
|
}
|
||||||
@@ -6,19 +6,11 @@ uniform sampler2D tex1;
|
|||||||
|
|
||||||
out vec4 o_color;
|
out vec4 o_color;
|
||||||
void main() {
|
void main() {
|
||||||
vec4 a = texture(tex0, v_texCoord0);
|
vec4 src = texture(tex0, v_texCoord0);
|
||||||
vec4 b = texture(tex1, v_texCoord0);
|
vec4 dest = texture(tex1, v_texCoord0);
|
||||||
vec4 color = vec4(0.0);
|
|
||||||
|
|
||||||
vec3 na = a.a == 0.0 ? vec3(0.0) : a.rgb/a.a;
|
float lsrc = src.a * (1.0 - dest.a);
|
||||||
vec3 nb = b.a == 0.0 ? vec3(0.0) : b.rgb/b.a;
|
float ldest = dest.a * (1.0 - src.a);
|
||||||
if (a.a > b.a) {
|
|
||||||
color = vec4(na, 1.0) * (b.a == 0.0? a.a : (1.0-b.a));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.a > a.a) {
|
o_color = src * lsrc + dest * ldest;
|
||||||
color = vec4(nb, 1.0) * (a.a == 0.0? b.a : (1.0-a.a));
|
|
||||||
}
|
|
||||||
|
|
||||||
o_color = color;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user