ported more effects to gles

This commit is contained in:
itsmattkc
2019-03-28 21:43:05 +11:00
parent 86bd06795a
commit 31bb862715
39 changed files with 50 additions and 113 deletions
+4 -8
View File
@@ -1,7 +1,3 @@
#version 120
uniform sampler2D tex0;
varying vec2 vTexCoord;
const float PI = 3.1415926535;
uniform vec2 resolution;
@@ -18,15 +14,15 @@ vec2 distort(vec2 p, vec2 offset) {
return 0.5 * (p + 1.0);
}
void main(void) {
vec4 process(vec4 col) {
vec2 offset = vec2(xoff/resolution.x, yoff/resolution.y);
vec2 xy = 2.0 * vTexCoord - 1.0 - offset;
vec2 xy = 2.0 * v_texcoord - 1.0 - offset;
vec2 uv;
float d = length(xy);
uv = distort(xy, offset);
if (uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0) {
gl_FragColor = texture2D(tex0, uv);
return texture2D(texture, uv);
} else {
discard;
return vec4(0.0);
}
}
-16
View File
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect name="Drop Shadow" category="Stylize">
<row name="Color">
<field type="color" r="0" g="0" b="0" id="shadowcolor"/>
</row>
<row name="Softness">
<field type="double" min="0" default="20" id="shadowsoftness"/>
</row>
<row name="Opacity">
<field type="double" min="0" default="100" max="100" id="shadowopacity"/>
</row>
<row name="Distance">
<field type="double" min="0" default="20" id="shadowdistance"/>
</row>
<shader vert="common.vert" frag="dropshadow.frag"/>
</effect>
@@ -4,9 +4,6 @@ feel free to use or modify at will*/
/*the follwing three functions convert RGB into YCbCr in the same manner as in JPEG images*/
uniform sampler2D tex;
varying vec2 vTexCoord;
uniform vec3 key_color;
uniform float tola;
uniform float tolb;
@@ -36,12 +33,10 @@ float colorclose(float Cb_p,float Cr_p,float Cb_key,float Cr_key,float tola,floa
return (1.0);
}
void main(void) {
vec4 process(vec4 texture_color) {
float cb_key = rgb2cb(key_color);
float cr_key = rgb2cr(key_color);
vec4 texture_color = texture2D(tex, vTexCoord);
float cb = rgb2cb(texture_color.rgb);
float cr = rgb2cr(texture_color.rgb);
float mask = colorclose(cb, cr, cb_key, cr_key, (tola/100.0), (tolb/100.0));
@@ -61,5 +56,5 @@ void main(void) {
} else if (mode == 2) { // original
}
gl_FragColor = texture_color;
return texture_color;
}
@@ -2,10 +2,6 @@
Based on Edward Cannon's Simple Chroma Key (adaptation by Olive Team)
RGB to HSV based on MattKC's toonify source code
Feel free to modify and use at will */
#version 110
uniform sampler2D tex;
varying vec2 vTexCoord;
uniform float loc;
uniform float hic;
@@ -57,8 +53,7 @@ bool isNotIncreasingSequence(float a, float b, float c) {
return (c < b || a > b);
}
void main(void) {
vec4 texture_color = texture2D(tex,vTexCoord);
vec4 process(vec4 texture_color) {
vec3 color = texture_color.rgb;
float toCheck = 0.0;
@@ -79,5 +74,5 @@ void main(void) {
}
texture_color.a = isNotIncreasingSequence(loc, toCheck, hic) ? (invert ? texture_color.a : 0.0) : (invert ? 0.0 : texture_color.a);
texture_color.rgb *= texture_color.a;
gl_FragColor = texture_color;
return texture_color;
}
@@ -1,15 +1,12 @@
#version 120
uniform sampler2D tex0;
varying vec2 vTexCoord;
#define M_PI 3.1415926535897932384626433832795
uniform float size;
void main(void) {
vec4 process(vec4 col) {
float maxFactor = 2.0 - (size * 0.01);
vec2 uv;
vec2 xy = 2.0 * vTexCoord - 1.0;
vec2 xy = 2.0 * v_texcoord - 1.0;
float d = length(xy);
if (d < (2.0-maxFactor)) {
d = length(xy * maxFactor);
@@ -20,8 +17,7 @@ void main(void) {
uv.x = r * cos(phi) + 0.5;
uv.y = r * sin(phi) + 0.5;
} else {
uv = vTexCoord;
uv = v_texcoord;
}
vec4 c = texture2D(tex0, uv);
gl_FragColor = c;
return texture2D(texture, uv);
}
@@ -1,12 +1,7 @@
#version 110
uniform float hue;
uniform float saturation;
uniform float brightness;
uniform sampler2D myTexture;
varying vec2 vTexCoord;
vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
@@ -23,9 +18,7 @@ vec3 hsv2rgb(vec3 c) {
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main(void) {
vec4 tex_color = texture2D(myTexture, vTexCoord);
vec4 process(vec4 tex_color) {
vec3 hsv = rgb2hsv(tex_color.rgb);
hsv.r += (hue/360.0);
hsv.g *= (saturation*0.01);
@@ -33,10 +26,8 @@ void main(void) {
vec3 rgb = hsv2rgb(hsv);
gl_FragColor = vec4(
rgb.r,
rgb.g,
rgb.b,
return vec4(
rgb.rgb,
tex_color.a
);
}
+5 -23
View File
@@ -1,33 +1,14 @@
#version 110
varying vec2 vTexCoord;
uniform sampler2D tex0; // scene buffer
uniform float scale;
uniform float centerx;
uniform float centery;
uniform bool mirrorx;
uniform bool mirrory;
void main(void) {
vec2 texCoord = vTexCoord;
/*vec2 coord = vec2(
mod(vTexCoord.x*tilecount, 1.0),
mod(vTexCoord.y*tilecount, 1.0)
);
if (mirrorx && mod(vTexCoord.x*tilecount, 2.0) > 1.0) {
coord.x = 1.0 - coord.x;
}
if (mirrory && mod(vTexCoord.y*tilecount, 2.0) > 1.0) {
coord.y = 1.0 - coord.y;
}*/
vec4 process(vec4 col) {
float adj_scale = scale*0.01;
vec2 scaled_coords = (vTexCoord/adj_scale);
vec2 scaled_coords = (v_texcoord/adj_scale);
vec2 coord = scaled_coords-vec2(0.5/adj_scale, 0.5/adj_scale)+vec2(0.5, 0.5)+vec2(-centerx*0.01, -centery*0.01);
vec2 modcoord = mod(coord, 1.0);
@@ -39,5 +20,6 @@ void main(void) {
modcoord.y = 1.0 - modcoord.y;
}
gl_FragColor = vec4(texture2D(tex0, modcoord));
return vec4(texture2D(texture, modcoord));
}
+5 -12
View File
@@ -1,20 +1,14 @@
#version 110
uniform sampler2D sceneTex; // 0
uniform float lensRadiusX;
uniform float lensRadiusY;
uniform bool circular;
uniform vec2 resolution;
// uniform vec2 lensRadius; // 0.45, 0.38
varying vec2 vTexCoord;
void main(void) {
vec4 process(vec4 c) {
if (lensRadiusX == 0.0) {
discard;
return vec4(0.0);
}
vec4 c = texture2D(sceneTex, vTexCoord);
vec2 vignetteCoord = vTexCoord;
vec2 vignetteCoord = v_texcoord;
if (circular) {
float ar = (resolution.x/resolution.y);
vignetteCoord.x *= ar;
@@ -22,6 +16,5 @@ void main(void) {
}
float dist = distance(vignetteCoord, vec2(0.5,0.5));
float size = (lensRadiusX*0.01);
c *= smoothstep(size, size*0.99*(1.0-lensRadiusY*0.01), dist);
gl_FragColor = c;
}
return vec4(c.rgb * smoothstep(size, size*0.99*(1.0-lensRadiusY*0.01), dist), c.a);
}