[orx-fx] convert to MPP
This commit is contained in:
40
orx-fx/src/shaders/glsl/blend/add.frag
Normal file
40
orx-fx/src/shaders/glsl/blend/add.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a > 0 ? a.rgb/a.a : vec3(0.0);
|
||||
vec3 nb = b.a > 0 ? b.rgb/b.a : vec3(0.0);
|
||||
|
||||
vec3 addColor = b.rgb;
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4((na + addColor), 1) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(min(na + nb, vec3(1.0)), 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
48
orx-fx/src/shaders/glsl/blend/color-burn.frag
Normal file
48
orx-fx/src/shaders/glsl/blend/color-burn.frag
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
float blendColorBurn(float base, float blend) {
|
||||
return (blend==0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0);
|
||||
}
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
blendColorBurn(na.r, nb.r),
|
||||
blendColorBurn(na.g, nb.g),
|
||||
blendColorBurn(na.b, nb.b)
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
50
orx-fx/src/shaders/glsl/blend/color-dodge.frag
Normal file
50
orx-fx/src/shaders/glsl/blend/color-dodge.frag
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
float dodge(float base, float blend) {
|
||||
return (blend==1.0)?blend:min(base/(1.0-blend),1.0);
|
||||
}
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
dodge(na.r, nb.r),
|
||||
dodge(na.g, nb.g),
|
||||
dodge(na.b, nb.b)
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
|
||||
}
|
||||
43
orx-fx/src/shaders/glsl/blend/darken.frag
Normal file
43
orx-fx/src/shaders/glsl/blend/darken.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
nb.r <= na.r? nb.r : na.r,
|
||||
nb.g <= na.g? nb.g : na.g,
|
||||
nb.b <= na.b? nb.b : na.b);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
32
orx-fx/src/shaders/glsl/blend/destination-atop.frag
Normal file
32
orx-fx/src/shaders/glsl/blend/destination-atop.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lsrc = src.a * (1.0 - dest.a);
|
||||
float lboth = src.a * dest.a;
|
||||
|
||||
vec4 result = src * lsrc + dest * 0.0 + dest * lboth;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
30
orx-fx/src/shaders/glsl/blend/destination-in.frag
Normal file
30
orx-fx/src/shaders/glsl/blend/destination-in.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lboth = src.a * dest.a;
|
||||
vec4 result = dest * lboth;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
31
orx-fx/src/shaders/glsl/blend/destination-out.frag
Normal file
31
orx-fx/src/shaders/glsl/blend/destination-out.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float ldest = dest.a * (1.0 - src.a);
|
||||
|
||||
vec4 result = dest * ldest;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
44
orx-fx/src/shaders/glsl/blend/hard-light.frag
Normal file
44
orx-fx/src/shaders/glsl/blend/hard-light.frag
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
nb.r <= 0.5? 2*na.r * nb.r : 1.0 - 2.0*(1.0 - na.r)*(1.0 - nb.r),
|
||||
nb.g <= 0.5? 2*na.g * nb.g : 1.0 - 2.0*(1.0 - na.g)*(1.0 - nb.g),
|
||||
nb.b <= 0.5? 2*na.b * nb.b : 1.0 - 2.0*(1.0 - na.b)*(1.0 - nb.b)
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
44
orx-fx/src/shaders/glsl/blend/lighten.frag
Normal file
44
orx-fx/src/shaders/glsl/blend/lighten.frag
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
nb.r >= na.r? nb.r : na.r,
|
||||
nb.g >= na.g? nb.g : na.g,
|
||||
nb.b >= na.b? nb.b : na.b);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
37
orx-fx/src/shaders/glsl/blend/multiply-contrast.frag
Normal file
37
orx-fx/src/shaders/glsl/blend/multiply-contrast.frag
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float ai = max(a.z, max(a.x, a.y));
|
||||
float bi = max(b.z, max(b.x, b.y));
|
||||
|
||||
vec3 f = a.rgb - (1.0-b.rgb)*2.0*b.a;
|
||||
|
||||
vec4 result;
|
||||
result.rgb = max(vec3(0.0), f) * (1.0) + b.rgb * (1.0-a.a);
|
||||
result.a = 1.0;
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
46
orx-fx/src/shaders/glsl/blend/multiply.frag
Normal file
46
orx-fx/src/shaders/glsl/blend/multiply.frag
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
vec3 u(vec4 x) {
|
||||
return x.a == 0.0? vec3(0.0) : x.rgb / x.a;
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = u(a);
|
||||
vec3 nb = u(b);
|
||||
vec3 mulColor = mix(vec3(1.0), nb, b.a);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(a.rgb * mulColor, a.a);
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(na * nb, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
|
||||
39
orx-fx/src/shaders/glsl/blend/normal.frag
Normal file
39
orx-fx/src/shaders/glsl/blend/normal.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float alpha = min(1,max(0, b.a));
|
||||
|
||||
vec4 result;
|
||||
if (!clip) {
|
||||
result = a * (1.0-alpha) + b;
|
||||
result.a = clamp(o_color.a, 0.0, 1.0);
|
||||
} else {
|
||||
result = a * (1.0-alpha) + b * a.a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
55
orx-fx/src/shaders/glsl/blend/overlay.frag
Normal file
55
orx-fx/src/shaders/glsl/blend/overlay.frag
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
vec3 demul(vec4 c) {
|
||||
if (c.a == 0) {
|
||||
return vec3(0.0);
|
||||
} else {
|
||||
return c.rgb / c.a;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = demul(a);
|
||||
vec3 nb = demul(b);
|
||||
|
||||
vec3 m = vec3(
|
||||
na.r <= 0.5? 2.0 * na.r * nb.r : (1.0 - 2.0 * (1.0 - na.r) * (1.0 - nb.r)),
|
||||
na.g <= 0.5? 2.0 * na.g * nb.g : (1.0 - 2.0 * (1.0 - na.g) * (1.0 - nb.g)),
|
||||
na.b <= 0.5? 2.0 * na.b * nb.b : (1.0 - 2.0 * (1.0 - na.b) * (1.0 - nb.b))
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
vec3 fc = na * (1.0 - b.a) + m * b.a;
|
||||
result = vec4(fc, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
|
||||
}
|
||||
25
orx-fx/src/shaders/glsl/blend/passthrough.frag
Normal file
25
orx-fx/src/shaders/glsl/blend/passthrough.frag
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 result = texture(tex0, v_texCoord0);
|
||||
#else
|
||||
vec4 result = texture2D(tex0, v_texCoord0);
|
||||
#endif
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
44
orx-fx/src/shaders/glsl/blend/screen.frag
Normal file
44
orx-fx/src/shaders/glsl/blend/screen.frag
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
1.0-((1.0-na.r)*(1.0-nb.r)),
|
||||
1.0-((1.0-na.g)*(1.0-nb.g)),
|
||||
1.0-((1.0-na.b)*(1.0-nb.b)));
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
32
orx-fx/src/shaders/glsl/blend/source-atop.frag
Normal file
32
orx-fx/src/shaders/glsl/blend/source-atop.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float ldest = dest.a * (1.0 - src.a);
|
||||
float lboth = src.a * dest.a;
|
||||
|
||||
vec4 result = dest * ldest + src * lboth;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
31
orx-fx/src/shaders/glsl/blend/source-in.frag
Normal file
31
orx-fx/src/shaders/glsl/blend/source-in.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lboth = src.a * dest.a;
|
||||
vec4 result = src * lboth;
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
31
orx-fx/src/shaders/glsl/blend/source-out.frag
Normal file
31
orx-fx/src/shaders/glsl/blend/source-out.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lsrc = src.a * (1.0 - dest.a);
|
||||
|
||||
vec4 result = src * lsrc;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
39
orx-fx/src/shaders/glsl/blend/subtract.frag
Normal file
39
orx-fx/src/shaders/glsl/blend/subtract.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a > 0 ? a.rgb/a.a : vec3(0.0);
|
||||
vec3 nb = b.a > 0 ? b.rgb/b.a : vec3(0.0);
|
||||
vec3 subColor = b.rgb;
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(max(na - subColor, vec3(0.0)), 1) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(max(na - nb, vec3(0.0)), 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
32
orx-fx/src/shaders/glsl/blend/xor.frag
Normal file
32
orx-fx/src/shaders/glsl/blend/xor.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lsrc = src.a * (1.0 - dest.a);
|
||||
float ldest = dest.a * (1.0 - src.a);
|
||||
|
||||
vec4 result = src * lsrc + dest * ldest;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user