[orx-fx] convert to MPP

This commit is contained in:
Edwin Jakobs
2021-06-27 21:07:44 +02:00
parent 7d524df2de
commit 4dfc5c31c8
144 changed files with 1197 additions and 847 deletions

View File

@@ -0,0 +1,39 @@
in vec2 v_texCoord0;
uniform sampler2D tex0;// input
uniform float blockWidth;
uniform float blockHeight;
uniform float blockOffsetX;
uniform float blockOffsetY;
uniform float sourceOffsetX;
uniform float sourceOffsetY;
uniform float sourceScale;
out vec4 o_color;
void main() {
vec2 uv = v_texCoord0;
vec2 blockSize = vec2(blockWidth, blockHeight);
vec2 blockOffset = vec2(blockOffsetX, blockOffsetY);
vec2 blockCoord = uv / blockSize + blockOffset;
ivec2 blockIndex = ivec2(blockCoord);
vec2 blockUV = mod(blockCoord - blockIndex, vec2(1.0));
vec2 blockAspect = vec2(1.0);
if (blockWidth < blockHeight) {
blockAspect = vec2(blockWidth / blockHeight, 1.0);
}
if (blockHeight < blockWidth) {
blockAspect = vec2(1.0, blockHeight/blockWidth);
}
vec2 tUV = mix(blockUV * blockSize, blockUV * blockAspect, sourceScale);
// vec2 fw = fwidth(blockCoord);
// float f = smoothstep(0.0, 0.01, blockUV.x) * smoothstep(0.0, 0.01, blockUV.y);
vec2 sourceOffset = vec2(sourceOffsetX, sourceOffsetY);
vec4 c = texture(tex0, mod(tUV + sourceOffset, vec2(1.0)));
o_color = c;
}

View File

@@ -0,0 +1,42 @@
in vec2 v_texCoord0;
uniform sampler2D tex0;// input
uniform sampler2D tex1;// input
uniform float offset;
uniform float gain;
uniform vec2 targetSize;
uniform float rotation;
uniform float feather;
uniform float sourceOpacity;
uniform float targetOpacity;
out vec4 o_color;
void main() {
float phi = radians(rotation);
float cp = cos(phi);
float sp = sin(phi);
mat2 rm = mat2(vec2(cp,sp), vec2(-sp,cp));
vec4 oa = texture(tex0, v_texCoord0);
vec4 b = texture(tex1, v_texCoord0);
float ar = targetSize.y / targetSize.x;
vec4 nb = b.a > 0? b/b.a : vec4(0.0);
vec2 offset = (nb.rg - vec2(offset))*vec2(gain) * nb.a;
offset = rm * offset * vec2(1.0, ar);
vec2 step = fwidth(v_texCoord0) * feather;
vec2 displaced = v_texCoord0 + offset;
float fx = smoothstep(0.0, step.x, displaced.x) * smoothstep(1.0, 1.0-step.x, displaced.x);
float fy = smoothstep(0.0, step.y, displaced.y) * smoothstep(1.0, 1.0-step.y, displaced.y);
vec4 a = texture(tex0, displaced) * mix(1.0, fx * fy, b.a);
o_color = (a + (1.0-a.a) * oa * sourceOpacity) * b.a * targetOpacity + (1.0-b.a*targetOpacity) * oa * sourceOpacity;
}

View File

@@ -0,0 +1,43 @@
uniform sampler2D tex0;
uniform float strength;
uniform float feather;
uniform float scale;
uniform float rotation;
in vec2 v_texCoord0;
out vec4 o_color;
void main() {
vec2 uv = v_texCoord0;
vec2 ts = textureSize(tex0, 0);
vec2 step = 1.0 / ts;
float phi = radians(rotation);
float cp = cos(phi);
float sp = sin(phi);
mat2 rm = mat2(vec2(cp,sp), vec2(-sp,cp));
float aspectRatio = ts.y / ts.x;
step.y /= aspectRatio;
step *= feather;
vec2 intensity = vec2(strength,
strength);
vec2 coords = uv;
coords = (coords - 0.5) * 2.0;
coords = rm * coords;
vec2 realCoordOffs;
realCoordOffs.x = (1.0 - coords.y * coords.y) * intensity.y * (coords.x);
realCoordOffs.y = (1.0 - coords.x * coords.x) * intensity.x * (coords.y);
vec2 fuv = ((uv - realCoordOffs) - vec2(0.5)) * scale + vec2(0.5);
float fx = smoothstep(0.0, step.x, fuv.x) * smoothstep(1.0, 1.0 - step.x, fuv.x);
float fy = smoothstep(0.0, step.y, fuv.y) * smoothstep(1.0, 1.0 - step.y, fuv.y);
vec4 color = texture(tex0, fuv) * fx * fy;
o_color = color;
}

View File

@@ -0,0 +1,71 @@
// created by florian berger (flockaroo) - 2016
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// single pass CFD
// ---------------
// this is some "computational flockarooid dynamics" ;)
// the self-advection is done purely rotational on all scales.
// therefore i dont need any divergence-free velocity field.
// with stochastic sampling i get the proper "mean values" of rotations
// over time for higher order scales.
//
// try changing "RotNum" for different accuracies of rotation calculation
// for even RotNum uncomment the line #define SUPPORT_EVEN_ROTNUM
#define RotNum 5
//#define SUPPORT_EVEN_ROTNUM
//#define keyTex iChannel3
//#define KEY_I texture(keyTex,vec2((105.5-32.0)/256.0,(0.5+0.0)/3.0)).x
const float ang = 2.0*3.1415926535/float(RotNum);
mat2 m = mat2(cos(ang), sin(ang), -sin(ang), cos(ang));
mat2 mh = mat2(cos(ang*0.5), sin(ang*0.5), -sin(ang*0.5), cos(ang*0.5));
uniform sampler2D tex0;
uniform float time;
uniform float random;
in vec2 v_texCoord0;
uniform vec2 targetSize;
uniform float blend;
out vec4 o_color;
float getRot(vec2 pos, vec2 b) {
vec2 Res = textureSize(tex0, 0);
vec2 p = b;
float rot = 0.0;
for (int i = 0; i < RotNum; i++) {
rot += dot(texture(tex0, fract((pos + p) / Res.xy)).xy -vec2(0.5), p.yx * vec2(1, -1));
p = m * p;
}
return rot / float(RotNum)/dot(b, b);
}
void main() {
vec2 pos = v_texCoord0 * targetSize;
vec2 Res = textureSize(tex0, 0);
vec2 b = vec2(cos(ang * random), sin(ang * random));
vec2 v = vec2(0);
float bbMax = 0.5 * Res.y;
bbMax *= bbMax;
for (int l = 0; l < 20; l++) {
if (dot(b, b) > bbMax) break;
vec2 p = b;
for (int i = 0; i < RotNum; i++) {
#ifdef SUPPORT_EVEN_ROTNUM
v += p.yx * getRot(pos + p, -mh * b);
#else
// this is faster but works only for odd RotNum
v += p.yx * getRot(pos + p, b);
#endif
p = m*p;
}
b *= 2.0;
}
o_color = vec4(0.0, 0.0, 0.0, 1.0);
o_color.xy = texture(tex0, fract((pos + v * vec2(-1, 1) * 2.0) / Res.xy)).xy * (1.0-blend) + v_texCoord0 * blend;
}

View File

@@ -0,0 +1,30 @@
in vec2 v_texCoord0;
uniform sampler2D tex0; // input
uniform float phase;
uniform float amplitude;
uniform float frequency;
out vec4 o_color;
uniform int segments;
float truncate(float x, int segments) {
if (segments == 0) {
return x;
} else {
return floor(x*segments) / segments;
}
}
void main() {
vec2 uv = v_texCoord0;
uv.x += amplitude * cos(truncate(uv.y, segments) * 3.1415926535 * frequency + phase * 3.1415926535);
if (uv.x >= 0.0 && uv.x < 1.0) {
if (segments == 0) {
o_color = texture(tex0, uv);
} else {
o_color = textureLod(tex0, uv, 0.0);
}
} else {
o_color = vec4(0.0);
}
}

View File

@@ -0,0 +1,43 @@
// based on https://www.shadertoy.com/view/wsBSWG by bloxard
uniform sampler2D tex0;
in vec2 v_texCoord0;
uniform vec3 cameraPosition;
uniform vec3 planePosition;
uniform mat4 planeMatrix;
uniform bool tile;
uniform vec2 targetSize;
out vec4 o_color;
void main() {
vec3 vCamPos = cameraPosition;
vec3 vPlanePos = planePosition;
vec3 vPlaneRight = vec3(1.0, 0.0, 0.0);
vec3 vPlaneUp = vec3(0.0, 1.0, 0.0);
mat3 m = mat3(planeMatrix);
vPlaneUp *= m;
vPlaneRight *= m;
vec3 vPlaneNormal = normalize(cross(vPlaneRight, vPlaneUp));
float fPlaneDeltaNormalDistance = dot(vPlanePos, vPlaneNormal) - dot(vPlaneNormal, vCamPos);
vec4 color = vec4(0.);
for (int m = 0; m < 2; m++) {
for (int n = 0; n < 2; n++) {
vec2 s = (v_texCoord0 - vec2(0.5)) * 2.0;
s*= vec2(1.0, targetSize.y / targetSize.x);
vec3 vRayDir = normalize(vec3(s, -1.0));
float t = fPlaneDeltaNormalDistance / dot(vPlaneNormal, vRayDir);
vec3 hitPos = vCamPos + vRayDir * t;
vec3 delta = hitPos - vPlanePos;
vec2 bary = vec2(dot(delta, vPlaneRight), dot(delta, vPlaneUp));
bary /= vec2(1.0, targetSize.y / targetSize.x);
bary += vec2(0.5);
if ((tile || (bary.x >= 0.0 && bary.x <= 1.0 && bary.y >=0.0 && bary.y <= 1.0)) && t > 0.0) {
color += texture(tex0, bary);
}
}
}
o_color = color * 0.25;
}

View File

@@ -0,0 +1,174 @@
// uniforms
uniform float gain;
uniform vec3 seed;
uniform float phase;
uniform float scale;
uniform float lacunarity;
uniform float decay;
uniform int octaves;
uniform sampler2D tex0;
uniform int xSegments;
uniform int ySegments;
uniform bool outputUV;
uniform vec2 offset;
// varyings
in vec2 v_texCoord0;
// outputs
out vec4 o_output;
// Simplex Noise 3D Implementation
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
// https://github.com/stegu/webgl-noise
//
//
vec3 mod289(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
return mod289(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise(vec3 v)
{
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
// First corner
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
// Other corners
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
// x0 = x0 - 0.0 + 0.0 * C.xxx;
// x1 = x0 - i1 + 1.0 * C.xxx;
// x2 = x0 - i2 + 2.0 * C.xxx;
// x3 = x0 - 1.0 + 3.0 * C.xxx;
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
// Permutations
i = mod289(i);
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float n_ = 0.142857142857; // 1.0/7.0
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
//Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}
vec3 segment(vec3 t, int x, int y) {
float sx = x == 0? t.x : floor(t.x * x) / x;
float sy = y == 0? t.y : floor(t.y * y) / y;
return vec3(sx,sy, t.z);
}
void main() {
float tx = 0.0;
float ty = 0.0;
float _gain = gain;
float shift = 100.0;
vec3 xseed = vec3(seed.xy, seed.z+cos(phase*3.1415926535));
vec3 yseed = vec3(seed.yx, seed.z+sin(phase*3.1415926535));
vec3 uv = vec3(v_texCoord0 + offset, 1.0) * 2.0 - 1.0;
vec3 px = ((segment(uv, xSegments, ySegments) + xseed) * scale);
vec3 py = ((segment(uv, xSegments, ySegments) + yseed + vec3(100.37, 40.51, 9.43)) * scale);
for (int o = 0; o < octaves; ++o) {
tx += snoise(px) * _gain;
ty += snoise(py) * _gain;
px = px * lacunarity + shift;
py = py * lacunarity + shift;
_gain *= decay;
}
vec2 distCoord = v_texCoord0 + vec2(tx, ty);
if (!outputUV) {
if (distCoord.x >= 0.0 && distCoord.y >= 0.0 && distCoord.x < 1.0 && distCoord.y < 1.0) {
if (xSegments == 0 && ySegments == 0) {
o_output = texture(tex0, distCoord);
} else {
o_output = textureLod(tex0, distCoord, 0.0);
}
} else {
o_output = vec4(0.0);
}
} else {
o_output = vec4(distCoord, 0.0, 1.0);
}
}

View File

@@ -0,0 +1,40 @@
in vec2 v_texCoord0;
uniform sampler2D tex0;// input
uniform int repeats;
uniform float zoom;
uniform float xOrigin;
uniform float yOrigin;
uniform float xOffset;
uniform float yOffset;
uniform float rotation;
out vec4 o_color;
void main() {
vec2 origin = vec2((xOrigin+1.0)/2.0, (yOrigin+1.0)/2.0);
vec2 ts = textureSize(tex0, 0);
float r = ts.x/ts.y;
vec2 offset = vec2(1.0, r) * vec2(xOffset, yOffset);
vec2 uv = v_texCoord0 - vec2(origin);
float rad = (rotation/180) * 3.1415926535;
vec2 cs0 = vec2(cos(rad), -sin(rad));
vec2 cs1 = vec2(sin(rad), cos(rad));
mat2 rotStep = mat2(cs0, cs1);
mat2 rot = rotStep;
vec4 c = texture(tex0, v_texCoord0);
for (int i = 1; i <= repeats; ++i) {
//vec2 s = (uv * (1.0 + zoom) * i) + vec2(0.5);
vec2 s = (rot * uv * pow(1.0 + zoom,i*1.0) )+ vec2(origin) + vec2(offset) * i;
float f = s.x >= 0.0 && s.y > 0.0 && s.x < 1.0 && s.y < 1.0? 1.0 : 0.0;
vec4 sc = texture(tex0, s) * f;
c = c * (1.0-sc.a) + sc;
if (c.a > 1.0) {
c.a = 1.0;
}
rot *= rotStep;
}
o_color = c;
}

View File

@@ -0,0 +1,40 @@
uniform sampler2D tex0;
in vec2 v_texCoord0;
uniform float phase;
uniform float rotation;
uniform float distortion;
uniform float frequency;
uniform float feather;
out vec4 o_color;
void main() {
float phi = radians(rotation);
float cp = cos(phi);
float sp = sin(phi);
mat2 rm = mat2(vec2(cp, sp), vec2(-sp, cp));
mat2 irm = transpose(rm);
float tw = 1.0 / frequency;
vec2 uv = rm * (v_texCoord0 - vec2(0.5)) + vec2(0.5) + vec2(phase * tw, 0.0);
float xd = (uv.x) * frequency;
float xo = (fract(xd) - 0.5) * 2.0;
float xf = fract(xd);
float offs = (1.0- xo * xo) * 1.0 * xo * distortion * 0.5;
float f = mix(1.0, (1.0 - xo * xo), distortion);
vec2 fuv = uv;
fuv.x = floor(uv.x * frequency) / frequency;
fuv.x += (xf - offs) * tw;
fuv = irm * (fuv - vec2(0.5) - vec2(phase * tw, 0.0)) + vec2(0.5);
vec2 step = fwidth(fuv) * feather;
float fx = smoothstep(0.0, step.x, fuv.x) * smoothstep(1.0, 1.0 - step.x, fuv.x);
float fy = smoothstep(0.0, step.y, fuv.y) * smoothstep(1.0, 1.0 - step.y, fuv.y);
vec4 c = texture(tex0, fuv) * f * fx * fy;
o_color = c;
}

View File

@@ -0,0 +1,64 @@
out vec4 o_output;
uniform sampler2D tex0;
in vec2 v_texCoord0;
uniform float time;
uniform float gain;
uniform float noiseLow;
uniform float noiseHigh;
uniform vec4 tint;
uniform bool monochrome;
uniform float deformAmplitude;
uniform float deformFrequency;
uniform float gapFrequency;
uniform float gapLow;
uniform float gapHigh;
#define HASHSCALE 443.8975
vec2 hash22(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
p3 += dot(p3, p3.yzx+19.19);
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
}
vec3 saturate(vec3 x) {
return clamp(x, vec3(0.0), vec3(1.0));
}
vec3 aberrationColor(float f) {
f = f * 3.0 - 1.5;
return saturate(vec3(-f, 1.0 - abs(f), f));
}
void main() {
float dk = 1.0/600.0;
o_output = vec4(0.0);
for (int k = 0; k < 10; ++k ) {
vec2 duv = v_texCoord0;
duv.y += smoothstep(pow(cos(time+k*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.0, v_texCoord0.x)*deformAmplitude * cos((time+k*dk)*deformFrequency);
duv.y += smoothstep(pow(1.0-cos(time+k*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.9, v_texCoord0.x)*deformAmplitude * cos((time+k*dk)*deformFrequency);
duv.y += sin(v_texCoord0.x*3.1415926535)*0.0;
float bc = floor(hash22(vec2(time+k*dk, (time+k*dk)*0.1)).x*20.0);
float gb3 = floor(duv.y*bc)/bc;
vec2 v = hash22(duv.xy*0.003+time+k*dk);
vec2 v2 = hash22(duv.xy*0.03+time+k*dk);
vec2 v2b = hash22(duv.yx*0.03+time+k*dk);
float stretch = (cos(time+k*dk)*0.001+0.002)*0.3+0.001;
vec2 h = hash22(duv.yy*stretch+time+k*dk);
float gap = smoothstep(gapLow, gapHigh, cos(gb3*(gapFrequency+duv.y*gapFrequency + (time+k*dk)*gapFrequency) +duv.x*gapFrequency)) * (cos(gb3)*0.5+0.5);
float r = smoothstep(noiseLow, noiseHigh, h.x*gap*v2.x)*1.0;
float g = smoothstep(noiseLow, noiseHigh, h.x*gap*v2.y)*1.0;
float b = smoothstep(noiseLow, noiseHigh, h.x*gap*v2b.x)*1.0;
float a = smoothstep(noiseLow, noiseHigh, h.x*gap*v2b.y)*1.0;
if (!monochrome) {
o_output += vec4(r, g, b, a)*gain * tint;
} else {
o_output += vec4(r, r, r, a)*gain * tint;
}
}
o_output *= o_output.a;
o_output += texture(tex0, v_texCoord0);
}

View File

@@ -0,0 +1,35 @@
in vec2 v_texCoord0;
uniform sampler2D tex0; // input
uniform float rotation;
uniform int xSegments;
uniform int ySegments;
out vec4 o_color;
uniform int segments;
float truncate(float x, int segments) {
if (segments == 0) {
return x;
} else {
return floor(x*segments) / segments;
}
}
void main() {
vec2 uv = v_texCoord0 - vec2(0.5);
float cr = cos(radians(rotation));
float sr = sin(radians(rotation));
mat2 rm = mat2(cr, -sr, sr, cr);
vec2 ruv = rm * uv;
vec2 truv = vec2( truncate(ruv.x, xSegments), truncate(ruv.y, ySegments));
vec2 tuv = transpose(rm) * truv + vec2(0.5);
vec4 c = vec4(0.0);
tuv.x = clamp(tuv.x, 0.0, 1.0);
tuv.y = clamp(tuv.y, 0.0, 1.0);
c = texture(tex0, tuv);
o_color = c * texture(tex0, v_texCoord0).a;
}

View File

@@ -0,0 +1,9 @@
in vec2 v_texCoord0;
uniform sampler2D tex0;// uvmap
uniform sampler2D tex1;// input
out vec4 o_color;
void main() {
vec2 uv = texture(tex0, v_texCoord0).xy;
o_color = texture(tex1, uv);
}

View File

@@ -0,0 +1,30 @@
in vec2 v_texCoord0;
uniform sampler2D tex0; // input
uniform float phase;
uniform float amplitude;
uniform float frequency;
out vec4 o_color;
uniform int segments;
float truncate(float x, int segments) {
if (segments == 0) {
return x;
} else {
return floor(x*segments) / segments;
}
}
void main() {
vec2 uv = v_texCoord0;
uv.y += amplitude * sin(truncate(uv.x, segments) * 3.1415926535 * frequency + phase * 3.1415926535);
if (uv.y >= 0.0 && uv.y < 1.0) {
if (segments == 0) {
o_color = texture(tex0, uv);
} else {
o_color = textureLod(tex0, uv, 0.0);
}
} else {
o_color = vec4(0.0);
}
}

View File

@@ -0,0 +1,68 @@
out vec4 o_output;
uniform sampler2D tex0;
in vec2 v_texCoord0;
uniform float time;
uniform float amplitude;
uniform float vfreq;
uniform float pfreq;
uniform float hfreq;
uniform float poffset;
uniform float scrollOffset0;
uniform float scrollOffset1;
uniform float borderHeight;
uniform bool linearInput;
uniform bool linearOutput;
#define HASHSCALE 443.8975
vec2 hash22(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
p3 += dot(p3, p3.yzx+19.19);
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
}
vec3 saturate(vec3 x) {
return clamp(x, vec3(0.0), vec3(1.0));
}
vec4 getVideo(vec2 uv, float amplitude, float seconds) {
float iTime = seconds;
vec2 look = mod(uv, vec2(1.0));
float window = 1.0/(1.0 + 20.0*(look.y-mod(iTime*vfreq, 1.0))*(look.y-mod(iTime*vfreq, 1.)));
look.x = look.x + sin(look.y*pfreq + poffset * 3.1415)/50 *(1.+cos(iTime*hfreq))*window*amplitude;
look.y = mod(look.y, 1.);
vec4 video = texture(tex0, look);
return video;
}
vec4 aberrationColor(float f) {
f = f * 3.0 - 1.5;
return vec4(saturate(vec3(-f, 1.0 - abs(f), f)), 1.0);
}
void main() {
vec4 c = vec4(0.0);
float aa = amplitude + smoothstep(borderHeight, 0.0, v_texCoord0.y)*4.0 + smoothstep(1.0-borderHeight, 1.0, v_texCoord0.y)*4.0;
float ds = scrollOffset1 - scrollOffset0;
if (aa > 0.0 || ds > 0.0) {
for (int i = 1; i < 16; ++i) {
vec4 lc = getVideo(v_texCoord0 + vec2(0.0, scrollOffset0+ds*i), aa, time-i/(16*60.0));
if (!linearInput) {
lc.rgb = pow(lc.rgb, vec3(2.2));
}
c += lc * (3.0/16.0) * aberrationColor(i/16.0);
}
o_output = c;
} else {
vec4 lc = texture(tex0, mod(v_texCoord0 + vec2(0.0, scrollOffset1), vec2(1.0)));
if (!linearInput) {
lc.rgb = pow(lc.rgb, vec3(2.2));
}
o_output = lc;
}
if (!linearOutput) {
o_output.rgb = pow(o_output.rgb, vec3(1/2.2));
}
}