Added manipulative shader sources
This commit is contained in:
71
tools/src/manipulative/Video Artifacts.frag
Normal file
71
tools/src/manipulative/Video Artifacts.frag
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
// https://www.shadertoy.com/view/MltBzf
|
||||||
|
|
||||||
|
float rand(vec2 p)
|
||||||
|
{
|
||||||
|
float t = floor(iTime * 20.) / 10.;
|
||||||
|
return fract(sin(dot(p, vec2(t * 12.9898, t * 78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
float noise(vec2 uv, float blockiness)
|
||||||
|
{
|
||||||
|
vec2 lv = fract(uv);
|
||||||
|
vec2 id = floor(uv);
|
||||||
|
|
||||||
|
float n1 = rand(id);
|
||||||
|
float n2 = rand(id+vec2(1,0));
|
||||||
|
float n3 = rand(id+vec2(0,1));
|
||||||
|
float n4 = rand(id+vec2(1,1));
|
||||||
|
|
||||||
|
vec2 u = smoothstep(0.0, 1.0 + blockiness, lv);
|
||||||
|
|
||||||
|
return mix(mix(n1, n2, u.x), mix(n3, n4, u.x), u.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
float fbm(vec2 uv, int count, float blockiness, float complexity)
|
||||||
|
{
|
||||||
|
float val = 0.0;
|
||||||
|
float amp = 0.5;
|
||||||
|
|
||||||
|
while(count != 0)
|
||||||
|
{
|
||||||
|
val += amp * noise(uv, blockiness);
|
||||||
|
amp *= 0.5;
|
||||||
|
uv *= complexity;
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float glitchAmplitude = 0.4; // increase this
|
||||||
|
const float glitchNarrowness = 8.0;
|
||||||
|
const float glitchBlockiness = 4.0;
|
||||||
|
const float glitchMinimizer = 12.0; // decrease this
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
vec2 a = vec2(uv.x * (iResolution.x / iResolution.y), uv.y);
|
||||||
|
vec2 uv2 = vec2(a.x / iResolution.x, exp(a.y));
|
||||||
|
vec2 id = floor(uv * 8.0);
|
||||||
|
//id.x /= floor(texture(iChannel0, vec2(id / 8.0)).r * 8.0);
|
||||||
|
|
||||||
|
// Generate shift amplitude
|
||||||
|
float shift = glitchAmplitude * pow(fbm(uv2, int(rand(id) * 12.), glitchBlockiness, glitchNarrowness), glitchMinimizer);
|
||||||
|
|
||||||
|
// Create a scanline effect
|
||||||
|
float scanline = abs(cos(uv.y * 400.));
|
||||||
|
scanline = smoothstep(0.0, 2.0, scanline);
|
||||||
|
shift = smoothstep(0.00001, 0.2, shift);
|
||||||
|
|
||||||
|
// Apply glitch and RGB shift
|
||||||
|
float colR = texture(iChannel0, vec2(uv.x + shift, uv.y)).r * (1. - shift) ;
|
||||||
|
float colG = texture(iChannel0, vec2(uv.x - shift, uv.y)).g * (1. - shift) + rand(id) * shift;
|
||||||
|
float colB = texture(iChannel0, vec2(uv.x - shift, uv.y)).b * (1. - shift);
|
||||||
|
// Mix with the scanline effect
|
||||||
|
vec3 f = vec3(colR, colG, colB) - (0.1);
|
||||||
|
|
||||||
|
// Output to screen
|
||||||
|
fragColor = vec4(f, 1.0);
|
||||||
|
}
|
||||||
110
tools/src/manipulative/Video Glitch 02.frag
Normal file
110
tools/src/manipulative/Video Glitch 02.frag
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
// https://www.shadertoy.com/view/lsfGD2
|
||||||
|
|
||||||
|
float sat( float t ) {
|
||||||
|
return clamp( t, 0.0, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 sat( vec2 t ) {
|
||||||
|
return clamp( t, 0.0, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//remaps inteval [a;b] to [0;1]
|
||||||
|
float remap ( float t, float a, float b ) {
|
||||||
|
return sat( (t - a) / (b - a) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//note: /\ t=[0;0.5;1], y=[0;1;0]
|
||||||
|
float linterp( float t ) {
|
||||||
|
return sat( 1.0 - abs( 2.0*t - 1.0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 spectrum_offset( float t ) {
|
||||||
|
float t0 = 3.0 * t - 1.5;
|
||||||
|
//return vec3(1.0/3.0);
|
||||||
|
return clamp( vec3( -t0, 1.0-abs(t0), t0), 0.0, 1.0);
|
||||||
|
/*
|
||||||
|
vec3 ret;
|
||||||
|
float lo = step(t,0.5);
|
||||||
|
float hi = 1.0-lo;
|
||||||
|
float w = linterp( remap( t, 1.0/6.0, 5.0/6.0 ) );
|
||||||
|
float neg_w = 1.0-w;
|
||||||
|
ret = vec3(lo,1.0,hi) * vec3(neg_w, w, neg_w);
|
||||||
|
return pow( ret, vec3(1.0/2.2) );
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//note: [0;1]
|
||||||
|
float rand( vec2 n ) {
|
||||||
|
return fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
//note: [-1;1]
|
||||||
|
float srand( vec2 n ) {
|
||||||
|
return rand(n) * 2.0 - 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float mytrunc( float x, float num_levels )
|
||||||
|
{
|
||||||
|
return floor(x*num_levels) / num_levels;
|
||||||
|
}
|
||||||
|
vec2 mytrunc( vec2 x, float num_levels )
|
||||||
|
{
|
||||||
|
return floor(x*num_levels) / num_levels;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
float aspect = iResolution.x / iResolution.y;
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
uv.y = 1.0 - uv.y;
|
||||||
|
|
||||||
|
float time = mod(iTime, 32.0); // + modelmat[0].x + modelmat[0].z;
|
||||||
|
|
||||||
|
float GLITCH = 0.1 + iMouse.x / iResolution.x;
|
||||||
|
|
||||||
|
//float rdist = length( (uv - vec2(0.5,0.5))*vec2(aspect, 1.0) )/1.4;
|
||||||
|
//GLITCH *= rdist;
|
||||||
|
|
||||||
|
float gnm = sat( GLITCH );
|
||||||
|
float rnd0 = rand( mytrunc( vec2(time, time), 6.0 ) );
|
||||||
|
float r0 = sat((1.0-gnm)*0.7 + rnd0);
|
||||||
|
float rnd1 = rand( vec2(mytrunc( uv.x, 10.0*r0 ), time) ); //horz
|
||||||
|
//float r1 = 1.0f - sat( (1.0f-gnm)*0.5f + rnd1 );
|
||||||
|
float r1 = 0.5 - 0.5 * gnm + rnd1;
|
||||||
|
r1 = 1.0 - max( 0.0, ((r1<1.0) ? r1 : 0.9999999) ); //note: weird ass bug on old drivers
|
||||||
|
float rnd2 = rand( vec2(mytrunc( uv.y, 40.0*r1 ), time) ); //vert
|
||||||
|
float r2 = sat( rnd2 );
|
||||||
|
|
||||||
|
float rnd3 = rand( vec2(mytrunc( uv.y, 10.0*r0 ), time) );
|
||||||
|
float r3 = (1.0-sat(rnd3+0.8)) - 0.1;
|
||||||
|
|
||||||
|
float pxrnd = rand( uv + time );
|
||||||
|
|
||||||
|
float ofs = 0.05 * r2 * GLITCH * ( rnd0 > 0.5 ? 1.0 : -1.0 );
|
||||||
|
ofs += 0.5 * pxrnd * ofs;
|
||||||
|
|
||||||
|
uv.y += 0.1 * r3 * GLITCH;
|
||||||
|
|
||||||
|
const int NUM_SAMPLES = 10;
|
||||||
|
const float RCP_NUM_SAMPLES_F = 1.0 / float(NUM_SAMPLES);
|
||||||
|
|
||||||
|
vec4 sum = vec4(0.0);
|
||||||
|
vec3 wsum = vec3(0.0);
|
||||||
|
for( int i=0; i<NUM_SAMPLES; ++i )
|
||||||
|
{
|
||||||
|
float t = float(i) * RCP_NUM_SAMPLES_F;
|
||||||
|
uv.x = sat( uv.x + ofs * t );
|
||||||
|
vec4 samplecol = texture( iChannel0, uv, -10.0 );
|
||||||
|
vec3 s = spectrum_offset( t );
|
||||||
|
samplecol.rgb = samplecol.rgb * s;
|
||||||
|
sum += samplecol;
|
||||||
|
wsum += s;
|
||||||
|
}
|
||||||
|
sum.rgb /= wsum;
|
||||||
|
sum.a *= RCP_NUM_SAMPLES_F;
|
||||||
|
|
||||||
|
//fragColor = vec4( sum.bbb, 1.0 ); return;
|
||||||
|
|
||||||
|
fragColor.a = sum.a;
|
||||||
|
fragColor.rgb = sum.rgb; // * outcol0.a;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user