tidying detour + usb rcording + a few other small bits

This commit is contained in:
langolierz
2019-07-02 20:41:51 +00:00
parent 37f2833090
commit 80d4eaa20a
31 changed files with 82 additions and 29 deletions

View File

@@ -0,0 +1,38 @@
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
vec3 rgb2grayscale(vec3 c)
{
return(vec3(dot(c, vec3(0.299, 0.587, 0.114))));
}
void main(){
vec2 pos = v_texcoord;
vec4 color = texture2D(u_tex0, pos);
vec3 gray = rgb2grayscale(color.rgb);
float divisions = 20.0 * u_x0 + 1.0;
vec3 newGray = vec3(float(int(gray.x*divisions))/divisions,float(int(gray.y*divisions))/divisions,float(int(gray.z*divisions))/divisions);
//if(gray.r + gray.g + gray.b )
gl_FragColor = vec4(newGray, color.a);
}

View File

@@ -0,0 +1,59 @@
//1-input
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform sampler2D u_tex1;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
vec3 rgb2grayscale(vec3 c)
{
return(vec3(dot(c, vec3(0.299, 0.587, 0.114))));
}
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));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main(){
vec2 pos = v_texcoord;
vec4 color = texture2D(u_tex0, pos);
vec3 hsv = rgb2hsv(color.rgb);
hsv.x += u_x0 - 0.5;
hsv.y += u_x1 - 0.5;
hsv.z += u_x2 - 0.5;
//hsv.x += -0.2;
vec3 rgb = hsv2rgb(hsv.xyz);
gl_FragColor = vec4(rgb, color.a);
}

View File

@@ -0,0 +1,15 @@
//1-input
//written by Tim Caldwell
// this is a simple example of how to change incoming textures colour
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
void main() {
vec4 texColour = texture2D(u_tex0, v_texcoord);
gl_FragColor = vec4(1.0 - u_x0 - texColour.r,1.0 -u_x1-texColour.g,1.0 - u_x2-texColour.b,texColour.a);
}

View File

@@ -0,0 +1,44 @@
//1-input
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.1415926538979323846
#define TWO_PI 2*PI
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
//uniform float kangleRad = 0.0;
//uniform vec2 u_resolution;
void main(){
int ksectors = 1 + int(u_x0*20.0);
vec2 screenCenter = vec2(0.5, 0.5) ;
vec2 kcenter = screenCenter + vec2(u_x2, u_x3);
float kangleRad = u_time*u_x1;
float twoPi = 3.1415926538979323846 * 2.0;
vec2 pos = v_texcoord ;
vec2 v = pos.xy - screenCenter;
float r = length(v);
float a = atan (v.y, v.x);
float A = twoPi / float(ksectors);
a = mod(a, A);
if (a > A/2.0 ){ a = A - a; }
a -= kangleRad;
vec2 u =vec2( cos(a), sin(a) ) * r;
u += kcenter;
gl_FragColor = texture2D(u_tex0, u);
}

View File

@@ -0,0 +1,29 @@
//1-input
//written by Tim Caldwell
//this is a basic example of how to effect input textures position
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
void main(){
vec2 pos = v_texcoord;
if(pos.x > u_x0){pos.x = 1.0 - pos.x;}
if(pos.y < u_x1){pos.y = 1.0 - pos.y;}
vec4 color = texture2D(u_tex0, pos);
gl_FragColor = color;
}

View File

@@ -0,0 +1,54 @@
//1-input
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform sampler2D u_tex1;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
vec4 rotate(sampler2D tex, vec2 pos){
vec4 texColourRotate;
vec2 center;
//center = vec2(u_x3 / u_resolution.x, u_x4 / u_resolution.y);
center = vec2(u_x1, u_x2);
pos.x = (pos.x - center.x)*(0.5 / u_x3) + center.x;
pos.y = (pos.y - center.y)*(0.5 / u_x3) + center.y;
float r = distance(center, pos);
float a = atan(pos.x - center.x, pos.y - center.y);
pos.x = r * cos(a + 2.0 * 3.141592 * u_x0) + 0.5;
pos.y = r * sin(a + 2.0 * 3.141592 * u_x0) + 0.5;
pos.x = 1.0 - pos.x;
if((pos.x < 0.0)||(pos.y < 0.0)||(pos.x > 1.0)||(pos.y > 1.0)){
texColourRotate = vec4(0.0);
}
else{
texColourRotate = texture2D(tex, pos);
}
return texColourRotate;
}
void main(){
vec2 pos = v_texcoord;
vec4 texColour0;
texColour0 = rotate(u_tex0, v_texcoord);
gl_FragColor = texColour0;
}

View File

@@ -0,0 +1,42 @@
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision highp float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
void main(){
vec2 pos = v_texcoord * u_resolution;
vec2 centre = u_resolution / 2.0;
vec2 norm = pos - centre;
//float r = distance(u_resolution, pos);
float r = length(norm);
//float theta = acos(norm.x / r);
float theta = atan(pos.y / pos.x);
//float newTheta = theta + 0.000;
theta += u_time*u_x0;
//pos.x = r*cos(theta) + centre.x;
pos.y = 4.0*u_x1*r*sin(theta) + centre.y;
pos.x = 4.0*(1.0-u_x2)*r*cos(theta) + centre.x;
//pos.y = r*sin(radians(theta)) + centre.y;
vec4 color = texture2D(u_tex0, pos / u_resolution);
gl_FragColor = color;
}

View File

@@ -0,0 +1,67 @@
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
uniform int intDiv;
vec3 rgb2grayscale(vec3 c)
{
return(vec3(dot(c, vec3(0.299, 0.587, 0.114))));
}
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));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main(){
vec2 pos = v_texcoord;
vec4 color = texture2D(u_tex0, pos);
vec3 gray = rgb2grayscale(color.rgb);
const int intDiv = 5;
float divisions = float(intDiv);
float lum = (gray.x + gray.y + gray.z) / 3.0;
vec3 newColor = vec3(0.0, 0.7, 0.7);
for (int i = 0; i < intDiv; i++ ){
if( lum >= float(i)/divisions && lum < (float(i)+1.0)/divisions){
newColor.x = mod((float(i)/divisions + u_x0*u_time*0.2)/u_x1 + u_x2,1.0);
}
}
gl_FragColor = vec4(hsv2rgb(newColor), color.a);
}

View File

@@ -0,0 +1,35 @@
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
void main(){
vec2 pos = v_texcoord;
//float amp = pos.y * 0.03 + .001;
pos.x += 0.07*u_x2*sin( pos.y* 70.0*u_x3 + u_time * 1.0 );
pos.y += 0.07*u_x0*sin( pos.x* 70.0*u_x1 + u_time * 1.0);
pos.y = mod(pos.y,1.0);
pos.x = mod(pos.x,1.0);
//if(pos.y > 1.0 || pos.y < 0.0){pos.y = 0.0;}
vec4 color = texture2D(u_tex0, pos);
gl_FragColor = color;
}

46
Shaders/1-input/zoom.frag Normal file
View File

@@ -0,0 +1,46 @@
//1-input
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D u_tex0;
uniform sampler2D u_tex1;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
vec4 zoom(sampler2D tex, vec2 pos){
vec4 texColourZoom;
vec2 center;
center = vec2(u_x2, u_x3);
pos.x = (pos.x - center.x)*(0.5 / u_x0) + center.x;
pos.y = (pos.y - center.y)*(0.5 / u_x0) + center.y;
if((pos.x < 0.0)||(pos.y < 0.0)||(pos.x > 1.0)||(pos.y > 1.0)){
texColourZoom = vec4(0.0);
}
else{
texColourZoom = texture2D(tex, pos);
}
return texColourZoom;
}
void main(){
vec2 pos = v_texcoord;
vec4 texColour0;
texColour0 = zoom(u_tex0, v_texcoord);
gl_FragColor = texColour0;
}