mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
adding shaders to the repo
This commit is contained in:
@@ -329,7 +329,7 @@ class Actions(object):
|
||||
|
||||
def check_if_should_start_openframeworks(self):
|
||||
if self.data.settings['other']['VIDEO_BACKEND']['value'] == 'openframeworks':
|
||||
subprocess.Popen(["make run --directory=~/openFrameworks/apps/myApps/c_o_n_j_u_r" ], shell=True)
|
||||
subprocess.Popen(["make run --directory=~/openFrameworks10/apps/myApps/c_o_n_j_u_r" ], shell=True)
|
||||
|
||||
def exit_openframeworks(self):
|
||||
self.video_driver.osc_client.send_message("/exit", True)
|
||||
|
||||
@@ -3,27 +3,27 @@
|
||||
//
|
||||
// Originally Created by Matthew Fargo on 2014/06/23.
|
||||
//
|
||||
|
||||
uniform sampler2D inputImageTexture;
|
||||
uniform float u_x0;
|
||||
//#version 120
|
||||
varying vec2 v_texcoord;
|
||||
uniform sampler2D u_tex0;
|
||||
uniform int radius;
|
||||
|
||||
const vec2 src_size = vec2 (1.0 / 680.0, 1.0 / 1024.0);
|
||||
|
||||
void main (void) {
|
||||
highp int index = int(u_x0 * 10.0);
|
||||
vec2 uv = gl_TexCoord[0].xy;
|
||||
//highp int radius = int(u_x0 * 10.0);
|
||||
|
||||
vec4 textureColor = texture2D(inputImageTexture, uv);
|
||||
vec4 textureColor = texture2D(u_tex0, v_texcoord);
|
||||
|
||||
float n = float((radius + 1) * (radius + 1));
|
||||
int i; int j;
|
||||
vec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);
|
||||
vec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);
|
||||
vec3 c;
|
||||
vec3 c;
|
||||
|
||||
for (j = -radius; j <= 0; ++j) {
|
||||
for (i = -radius; i <= 0; ++i) {
|
||||
c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;
|
||||
for(j = radius; j <= 0; ++j) {
|
||||
for(i = radius; i <= 0; ++i) {
|
||||
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
|
||||
m0 += c;
|
||||
s0 += c * c;
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
for (j = -radius; j <= 0; ++j) {
|
||||
for (i = 0; i <= radius; ++i) {
|
||||
c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;
|
||||
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
|
||||
m1 += c;
|
||||
s1 += c * c;
|
||||
}
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
for (j = 0; j <= radius; ++j) {
|
||||
for (i = 0; i <= radius; ++i) {
|
||||
c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;
|
||||
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
|
||||
m2 += c;
|
||||
s2 += c * c;
|
||||
}
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
for (j = 0; j <= radius; ++j) {
|
||||
for (i = -radius; i <= 0; ++i) {
|
||||
c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;
|
||||
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
|
||||
m3 += c;
|
||||
s3 += c * c;
|
||||
}
|
||||
34
shader_experiments/Shaders/PostProcessing.frag
Executable file
34
shader_experiments/Shaders/PostProcessing.frag
Executable file
@@ -0,0 +1,34 @@
|
||||
precision highp float;
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
uniform sampler2D u_tex0;
|
||||
|
||||
|
||||
// http://www.iquilezles.org/apps/shadertoy/?p=Postpro
|
||||
void main(){
|
||||
vec2 q = gl_FragCoord.xy / u_resolution.xy;
|
||||
vec2 uv = 0.5 + (q-0.5)*(0.9 + 0.1*sin(0.2*u_time));
|
||||
|
||||
vec3 oricol = texture2D(u_tex0,vec2(q.x,1.0-q.y)).xyz;
|
||||
vec3 col;
|
||||
|
||||
col.r = texture2D(u_tex0,vec2(uv.x+0.003,-uv.y)).x;
|
||||
col.g = texture2D(u_tex0,vec2(uv.x+0.000,-uv.y)).y;
|
||||
col.b = texture2D(u_tex0,vec2(uv.x-0.003,-uv.y)).z;
|
||||
|
||||
col = clamp(col*0.5+0.5*col*col*1.2,0.0,1.0);
|
||||
|
||||
col *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y);
|
||||
|
||||
col *= vec3(0.8,1.0,0.7);
|
||||
|
||||
col *= 0.9+0.1*sin(10.0*u_time+uv.y*1000.0);
|
||||
|
||||
col *= 0.97+0.03*sin(110.0*u_time);
|
||||
|
||||
float comp = smoothstep( 0.2, 0.7, sin(u_time) );
|
||||
col = mix( col, oricol, clamp(-2.0+2.0*q.x+3.0*comp,0.0,1.0) );
|
||||
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
||||
46
shader_experiments/Shaders/another_default.vert
Normal file
46
shader_experiments/Shaders/another_default.vert
Normal file
@@ -0,0 +1,46 @@
|
||||
// this is the default vert file used by glslVeiwer
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
uniform mat4 u_modelViewProjectionMatrix;
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec3 a_normal;
|
||||
attribute vec2 a_texcoord;
|
||||
|
||||
varying vec4 v_position;
|
||||
varying vec4 v_color;
|
||||
varying vec3 v_normal;
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
|
||||
#ifdef SHADOW_MAP
|
||||
uniform mat4 u_lightMatrix;
|
||||
varying vec4 v_lightcoord;
|
||||
#endif
|
||||
|
||||
#ifdef MODEL_HAS_TANGENTS
|
||||
varying mat3 v_tangentToWorld;
|
||||
#endif
|
||||
|
||||
void main(void) {
|
||||
|
||||
v_position = a_position;
|
||||
v_color = a_color;
|
||||
v_normal = a_normal;
|
||||
v_texcoord = a_texcoord;
|
||||
|
||||
#ifdef MODEL_HAS_TANGENTS
|
||||
vec3 worldTangent = a_tangent.xyz;
|
||||
vec3 worldBiTangent = cross(v_normal, worldTangent) * sign(a_tangent.w);
|
||||
v_tangentToWorld = mat3(normalize(worldTangent), normalize(worldBiTangent), normalize(v_normal));
|
||||
#endif
|
||||
|
||||
#ifdef SHADOW_MAP
|
||||
v_lightcoord = u_lightMatrix * v_position;
|
||||
#endif
|
||||
|
||||
gl_Position = u_modelViewProjectionMatrix * v_position;
|
||||
}
|
||||
|
||||
17
shader_experiments/Shaders/center_circle.frag
Normal file
17
shader_experiments/Shaders/center_circle.frag
Normal file
@@ -0,0 +1,17 @@
|
||||
precision mediump float;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
void main(void) {
|
||||
|
||||
vec2 center = u_resolution / 2.0;
|
||||
vec2 pos = gl_FragCoord.xy;
|
||||
vec2 dist = center - pos;
|
||||
float len = length(dist);
|
||||
|
||||
vec3 color = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
if (len < 5.0){ color.r = 1.0; }
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
||||
23
shader_experiments/Shaders/default.vert
Normal file
23
shader_experiments/Shaders/default.vert
Normal file
@@ -0,0 +1,23 @@
|
||||
attribute vec4 position;
|
||||
attribute vec4 color;
|
||||
attribute vec3 normal;
|
||||
attribute vec2 texcoord;
|
||||
|
||||
uniform mat4 modelViewProjectionMatrix;
|
||||
|
||||
varying vec4 v_position;
|
||||
varying vec4 v_color;
|
||||
varying vec3 v_normal;
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
uniform mat4 u_modelViewProjectionMatrix;
|
||||
|
||||
void main() {
|
||||
v_position = position;
|
||||
v_color = color;
|
||||
v_normal = normal;
|
||||
v_texcoord = texcoord;
|
||||
|
||||
gl_Position = modelViewProjectionMatrix * position;
|
||||
|
||||
}
|
||||
32
shader_experiments/Shaders/generate/another_hypnotic.frag
Normal file
32
shader_experiments/Shaders/generate/another_hypnotic.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
vec3 color = vec3(0.0,0.0,0.0);
|
||||
|
||||
vec2 pos = gl_FragCoord.xy;
|
||||
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
||||
st.x *= u_resolution.x/u_resolution.y;
|
||||
|
||||
vec2 s1 = vec2(u_resolution.x*(0.5 + 0.25*cos(u_time)), u_resolution*(0.5 + 0.25*sin(u_time)));
|
||||
vec2 s2 = vec2(u_resolution.x*(0.5 + 0.25*sin(u_time)), u_resolution*(0.5 + 0.25*cos(u_time)));
|
||||
vec2 s3 = vec2(u_resolution.x*0.5, u_resolution*0.5);
|
||||
|
||||
float r1 = pow(pow(pos.x-s1.x,2.0) + pow(pos.y-s1.y,2.0), 0.5);
|
||||
float r2 = pow(pow(pos.x-s2.x,2.0) + pow(pos.y-s2.y,2.0), 0.5);
|
||||
float r3 = pow(pow(pos.x-s3.x,2.0) + pow(pos.y-s3.y,2.0), 0.5);
|
||||
|
||||
color += vec3(0.5 + 0.5*sign(sin((0.1 + 0.05*sin(u_time+2.0))*r1 - 1.0*u_time)), 0.0, 0.0);
|
||||
color += vec3(0.0, 0.0, 0.5 + 0.5*sign(sin((0.1 + 0.05*sin(u_time))*r2 - 1.2*u_time)));
|
||||
color += vec3(0.0, 0.5 + 0.5*sign(sin((0.1 + 0.05*sin(u_time+0.5))*r3 - 1.1*u_time)), 0.0);
|
||||
|
||||
|
||||
|
||||
gl_FragColor = vec4(color,1.);
|
||||
}
|
||||
31
shader_experiments/Shaders/generate/colour_sine.frag
Normal file
31
shader_experiments/Shaders/generate/colour_sine.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform float u_time;
|
||||
uniform float u_x0;
|
||||
uniform float u_x1;
|
||||
|
||||
void main() {
|
||||
vec3 colour = vec3(0.0,0.0,0.0);
|
||||
if(u_x0 < (1.0 / 3.0)){
|
||||
colour[0] = 1.0;
|
||||
}
|
||||
else if(u_x0 > (2.0 / 3.0)){
|
||||
colour[1] = 1.0;
|
||||
}
|
||||
else{
|
||||
colour[2] = 1.0;
|
||||
}
|
||||
if(u_x1 < (1.0 / 3.0)){
|
||||
colour[1] = 1.0;
|
||||
}
|
||||
else if(u_x1 > (2.0 / 3.0)){
|
||||
colour[2] = 1.0;
|
||||
}
|
||||
else{
|
||||
colour[0] = 1.0;
|
||||
}
|
||||
gl_FragColor = vec4(colour, 1.0);
|
||||
|
||||
}
|
||||
@@ -3,7 +3,8 @@ precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform float u_time;
|
||||
uniform float u_x0;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(sin(u_time),0.0,0.0,1.0);
|
||||
gl_FragColor = vec4(sin(1000.0*u_x0*u_time),0.0,0.0,1.0);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// copied from http://glslsandbox.com/e#47821.0
|
||||
//gen-shader
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
@@ -6,12 +7,13 @@ precision mediump float;
|
||||
#extension GL_OES_standard_derivatives : enable
|
||||
|
||||
uniform float u_time;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_x0;
|
||||
uniform float u_x1;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
void main( void ) {
|
||||
|
||||
vec2 position = ( gl_FragCoord.xy / u_resolution.xy ) + u_mouse / 4.0;
|
||||
vec2 position = ( gl_FragCoord.xy / u_resolution.xy ) + (u_resolution.x * u_x0, u_resolution.y * u_x1) / 4.0;
|
||||
|
||||
float color = 0.0;
|
||||
color += sin( position.x * cos( u_time / 15.0 ) * 80.0 ) + cos( position.y * cos( u_time / 15.0 ) * 10.0 );
|
||||
10
shader_experiments/Shaders/generate/simple_blobs.frag
Normal file
10
shader_experiments/Shaders/generate/simple_blobs.frag
Normal file
@@ -0,0 +1,10 @@
|
||||
precision mediump float;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
float sin1(float t) { return (sin(t) * 0.5 + 0.5); }
|
||||
|
||||
void main(void) {
|
||||
vec2 p = ( gl_FragCoord.xy / min(u_resolution.x, u_resolution.y));
|
||||
gl_FragColor = vec4(vec3(sin1(p.x * 10.0 + sin1(p.y * 10.0 + u_time)) * sin1(p.y * 10.0 + sin1(p.x * 10.0 + u_time))), 1.0);
|
||||
}
|
||||
40
shader_experiments/Shaders/generate/spectrum.frag
Normal file
40
shader_experiments/Shaders/generate/spectrum.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
// Tenjix
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
const float position = 0.0;
|
||||
const float scale = 8.0;
|
||||
const float intensity = 1.0;
|
||||
|
||||
float band(vec2 pos, float amplitude, float frequency) {
|
||||
float wave = scale * amplitude * sin(2.0 * PI * frequency * pos.x + u_time) / 6.05;
|
||||
float light = clamp(amplitude * frequency * 0.002, 0.001 + 0.001 / scale, 5.0) * scale / abs(wave - pos.y);
|
||||
return light;
|
||||
}
|
||||
|
||||
void main( void ) {
|
||||
|
||||
vec3 color = vec3(0., 0.5, 1.0);
|
||||
color = color == vec3(0.0)? vec3(0.10, 0.5, 10.0) : color;
|
||||
vec2 pos = (gl_FragCoord.xy / u_resolution.xy);
|
||||
pos.y += - 0.5 - position;
|
||||
|
||||
float spectrum = 0.0;
|
||||
|
||||
spectrum += band(pos, 0.1, 10.0);
|
||||
spectrum += band(pos, 0.2, 8.0);
|
||||
spectrum += band(pos, 0.10, 5.0);
|
||||
spectrum += band(pos, 0.09, 3.0);
|
||||
spectrum += band(pos, 0.8, 2.0);
|
||||
spectrum += band(pos, 1.0, 1.0);
|
||||
|
||||
gl_FragColor = vec4(color * spectrum, spectrum);
|
||||
|
||||
}
|
||||
24
shader_experiments/Shaders/generate/squarewaves.frag
Normal file
24
shader_experiments/Shaders/generate/squarewaves.frag
Normal file
@@ -0,0 +1,24 @@
|
||||
//gen-shader
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
uniform float u_x0;
|
||||
uniform float u_x1;
|
||||
uniform float u_x2;
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 color = vec3(0.0,0.0,0.0);
|
||||
vec2 pos = gl_FragCoord.xy;
|
||||
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
||||
st.x *= u_resolution.x/u_resolution.y;
|
||||
|
||||
color += vec3(u_x0*sign(sin(0.05*pos.x - u_time + sin(0.05*pow(pos.y,1.5) - u_time))),0.,0.);
|
||||
color += vec3(0., 0., sign(cos(0.03*pos.x - 2.0*u_x1*u_time + 0.5*sin(0.05*pos.y - 2.0*u_x2*u_time))));
|
||||
|
||||
gl_FragColor = vec4(color,1.);
|
||||
|
||||
}
|
||||
23
shader_experiments/Shaders/generate/zoom_clouds.frag
Normal file
23
shader_experiments/Shaders/generate/zoom_clouds.frag
Normal file
@@ -0,0 +1,23 @@
|
||||
//gen-shader
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
uniform float u_x0;
|
||||
|
||||
void main() {
|
||||
vec2 pos = gl_FragCoord.xy;
|
||||
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
||||
st.x *= u_resolution.x/u_resolution.y;
|
||||
|
||||
vec3 color = vec3(0.0,0.0,0.0);
|
||||
|
||||
color += vec3(sin(0.05*pos.x - cos(u_x0*u_time)) + cos(0.05*pos.x/(0.1 + abs(cos(u_time/5.0)))),0.0,0.0);
|
||||
color += vec3(sin(0.05*pos.y - cos(u_time/5.0)) + cos(0.05*pos.y/(0.1 + abs(cos(u_time/5.0)))),0.0,0.0);
|
||||
color += vec3(0.0, 0.0, sin(u_time));
|
||||
|
||||
gl_FragColor = vec4(color,1.);
|
||||
|
||||
}
|
||||
40
shader_experiments/Shaders/process/gray_divisions.frag
Normal file
40
shader_experiments/Shaders/process/gray_divisions.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
//pro-shader
|
||||
#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;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
varying vec2 texcoord0;
|
||||
uniform sampler2D tex0;
|
||||
varying vec2 v_texcoord;
|
||||
uniform sampler2D u_tex0;
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
vec2 pos = gl_FragCoord.xy;
|
||||
vec4 texColor = texture2D(tex0, texcoord0);
|
||||
vec4 texColor = texture2D(u_tex0, v_texcoord);
|
||||
|
||||
texColor.r *= (sin(0.05*pos.x - cos(u_time)) + cos(0.05*pos.x/(0.1 + abs(cos(u_time/5.0)))));
|
||||
texColor.r *= (sin(0.05*pos.y - cos(u_time/5.0)) + cos(0.05*pos.y/(0.1 + abs(cos(u_time/5.0)))));
|
||||
58
shader_experiments/Shaders/process/hsv_control.frag
Normal file
58
shader_experiments/Shaders/process/hsv_control.frag
Normal file
@@ -0,0 +1,58 @@
|
||||
//pro-shader
|
||||
#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;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
15
shader_experiments/Shaders/process/invert_effect.frag
Normal file
15
shader_experiments/Shaders/process/invert_effect.frag
Normal file
@@ -0,0 +1,15 @@
|
||||
//pro-shader
|
||||
|
||||
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() {
|
||||
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);
|
||||
}
|
||||
43
shader_experiments/Shaders/process/kaleidoscope.frag
Normal file
43
shader_experiments/Shaders/process/kaleidoscope.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
27
shader_experiments/Shaders/process/mirror.frag
Normal file
27
shader_experiments/Shaders/process/mirror.frag
Normal file
@@ -0,0 +1,27 @@
|
||||
//pro-shader
|
||||
#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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
41
shader_experiments/Shaders/process/s-wobble.frag
Normal file
41
shader_experiments/Shaders/process/s-wobble.frag
Normal file
@@ -0,0 +1,41 @@
|
||||
//pro-shader
|
||||
#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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
66
shader_experiments/Shaders/process/simple_colorizer.frag
Normal file
66
shader_experiments/Shaders/process/simple_colorizer.frag
Normal file
@@ -0,0 +1,66 @@
|
||||
//pro-shader
|
||||
#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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
34
shader_experiments/Shaders/process/wobble.frag
Normal file
34
shader_experiments/Shaders/process/wobble.frag
Normal file
@@ -0,0 +1,34 @@
|
||||
//pro-shader
|
||||
#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.05*u_x2*sin( pos.y* 60.0*u_x3 + u_time * 1.0 );
|
||||
pos.y += 0.05*u_x0*sin( pos.x* 60.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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
101
shader_experiments/Shaders/shaderExample.frag
Executable file
101
shader_experiments/Shaders/shaderExample.frag
Executable file
@@ -0,0 +1,101 @@
|
||||
precision highp float; // this will make the default precision high
|
||||
|
||||
//we passed this in from our vert shader
|
||||
varying vec2 texcoord0;
|
||||
|
||||
//These are variables we set in our ofApp using the ofShader API
|
||||
|
||||
//our texture reference
|
||||
//passed in by
|
||||
//shader.setUniformTexture("tex0", sourceImage.getTextureReference(), sourceImage.getTextureReference().texData.textureID);
|
||||
uniform sampler2D u_tex0;
|
||||
|
||||
//width and height that we are working with
|
||||
//passed in by
|
||||
//shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight());
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
//a changing value to work with
|
||||
//passed in by
|
||||
//shader.setUniform1f("time", ofGetElapsedTimef());
|
||||
uniform float u_time;
|
||||
|
||||
|
||||
//Each shader has one main() function you can use
|
||||
//Below are a few implementations. Make sure you have all but one commented out
|
||||
|
||||
//Shaders are compiled at runtime meaning that you can just change the shader file
|
||||
//and re-run the ofApp without compiling
|
||||
|
||||
|
||||
// just draw the texture to screen
|
||||
/*void main()
|
||||
{
|
||||
gl_FragColor = texture2D(u_tex0, texcoord0);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
// draw the texture to screen, inverted
|
||||
/*void main()
|
||||
{
|
||||
vec4 texColor = texture2D(u_tex0, texcoord0);
|
||||
gl_FragColor = vec4(1.0-texColor.r, 1.0-texColor.g, 1.0-texColor.b, texColor.a);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
// let's wobble the image channels around independently, a bit Fear and Loathing in Las Vegas style
|
||||
void main()
|
||||
{
|
||||
mediump float newTime = u_time * 2.0;
|
||||
|
||||
vec2 newTexCoord;
|
||||
newTexCoord.s = texcoord0.s + (cos(newTime + (texcoord0.s*20.0)) * 0.01);
|
||||
newTexCoord.t = texcoord0.t + (sin(newTime + (texcoord0.t*20.0)) * 0.01);
|
||||
|
||||
mediump vec2 texCoordRed = newTexCoord;
|
||||
mediump vec2 texCoordGreen = newTexCoord;
|
||||
mediump vec2 texCoordBlue = newTexCoord;
|
||||
|
||||
texCoordRed += vec2( cos((newTime * 2.76)), sin((newTime * 2.12)) )* 0.01;
|
||||
texCoordGreen += vec2( cos((newTime * 2.23)), sin((newTime * 2.40)) )* 0.01;
|
||||
texCoordBlue += vec2( cos((newTime * 2.98)), sin((newTime * 2.82)) )* 0.01;
|
||||
|
||||
mediump float colorR = texture2D( u_tex0, texCoordRed ).r;
|
||||
mediump float colorG = texture2D( u_tex0, texCoordGreen).g;
|
||||
mediump float colorB = texture2D( u_tex0, texCoordBlue).b;
|
||||
mediump float colorA = texture2D( u_tex0, texCoordBlue).a;
|
||||
mediump vec4 outColor = vec4( colorR, colorG, colorB, colorA);
|
||||
|
||||
gl_FragColor = outColor;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
//This is the internal RPi vert shader for reference
|
||||
precision lowp float;
|
||||
|
||||
uniform sampler2D src_tex_unit0;
|
||||
|
||||
uniform float usingTexture;
|
||||
uniform float bitmapText;
|
||||
|
||||
varying vec4 colorVarying;
|
||||
varying vec2 texCoordVarying;
|
||||
|
||||
void main(){
|
||||
vec4 tex;
|
||||
if(usingTexture>.5){
|
||||
tex = texture2D(src_tex_unit0, texCoordVarying);
|
||||
if(bitmapText>.5 && tex.a < 0.5){
|
||||
discard;
|
||||
}else{
|
||||
gl_FragColor = colorVarying*tex;
|
||||
}
|
||||
}else{
|
||||
gl_FragColor = colorVarying;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,18 +0,0 @@
|
||||
pi@raspberrypi:~ $ pivideo -q all -v
|
||||
PiVideo Version 1.13
|
||||
Port used for video processor is: i2c1
|
||||
PiCapture SD1 is ready
|
||||
No active video detected
|
||||
Selected video source is: auto
|
||||
Active video source is: video1
|
||||
Raspberry Pi camera port is not active
|
||||
Video processor firmware version: 07-07811E
|
||||
Video processor hardware id: 583F861021C29880
|
||||
|
||||
pi@raspberrypi:~ $ raspivid -md 6 -awbg 1.0,1.0 -awb off -ex off -o
|
||||
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
|
||||
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
|
||||
mmal: Failed to create camera component
|
||||
mmal: main: Failed to create camera component
|
||||
mmal: Camera is not detected. Please check carefully the camera module is installed correctly
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
attribute vec4 position;
|
||||
attribute vec2 texcoord;
|
||||
uniform mat4 modelViewProjectionMatrix;
|
||||
|
||||
varying vec2 texcoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = modelViewProjectionMatrix * position;
|
||||
texcoord0 = texcoord;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
|
||||
varying vec2 texcoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
vec4 texColour = texture2D(tex0, texcoord0);
|
||||
gl_FragColor = vec4(1.0-texColour.r,1.0-texColour.g,1.0-texColour.b,texColour.a);
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// Author:
|
||||
// Title:
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
vec2 pos = gl_FragCoord.xy;
|
||||
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
||||
st.x *= u_resolution.x/u_resolution.y;
|
||||
|
||||
/*float wave_length = 180.0;
|
||||
float period = 5.0;
|
||||
float speed = wave_length/period;
|
||||
float speed = 100.0;
|
||||
float period = wave_length/speed;
|
||||
float x_coef = 6.28/wave_length;
|
||||
float t_coef = 6.28/period;*/
|
||||
|
||||
|
||||
vec3 color = vec3(0.0,0.0,0.0);
|
||||
|
||||
/*vec3 col1 = vec3(0.5, 0.0, 0.1);
|
||||
vec3 col2 = vec3(0.2, 0.1, 0.8);
|
||||
|
||||
float mixer = sin(u_time);
|
||||
|
||||
color = mix(col1, col2, mixer);*/
|
||||
|
||||
// -------- Hypnotic circle thing ----------
|
||||
/*vec2 s1 = vec2(u_resolution.x*(0.5 + 0.25*cos(u_time)), u_resolution*(0.5 + 0.25*sin(u_time)));
|
||||
vec2 s2 = vec2(u_resolution.x*(0.5 + 0.25*sin(u_time)), u_resolution*(0.5 + 0.25*cos(u_time)));
|
||||
vec2 s3 = vec2(u_resolution.x*0.5, u_resolution*0.5);
|
||||
|
||||
float r1 = pow(pow(pos.x-s1.x,2.0) + pow(pos.y-s1.y,2.0), 0.5);
|
||||
float r2 = pow(pow(pos.x-s2.x,2.0) + pow(pos.y-s2.y,2.0), 0.5);
|
||||
float r3 = pow(pow(pos.x-s3.x,2.0) + pow(pos.y-s3.y,2.0), 0.5);
|
||||
|
||||
color += vec3(0.5 + 0.5*sign(sin((0.1 + 0.05*sin(u_time+2.0))*r1 - 1.0*u_time)), 0.0, 0.0);
|
||||
color += vec3(0.0, 0.0, 0.5 + 0.5*sign(sin((0.1 + 0.05*sin(u_time))*r2 - 1.2*u_time)));
|
||||
color += vec3(0.0, 0.5 + 0.5*sign(sin((0.1 + 0.05*sin(u_time+0.5))*r3 - 1.1*u_time)), 0.0);*/
|
||||
|
||||
// ------- cool square wave thing ----------
|
||||
//color += vec3(sign(sin(0.05*pos.x - u_time + sin(0.05*pow(pos.y,1.5) - u_time))),0.,0.);
|
||||
//color += vec3(0., 0., sign(cos(0.03*pos.x - u_time + 0.5*sin(0.05*pos.y - u_time))));
|
||||
|
||||
// ------- puff in puff out diamond --------
|
||||
color += vec3(sin(0.05*pos.x - cos(u_time)) + cos(0.05*pos.x/(0.1 + abs(cos(u_time/5.0)))),0.0,0.0);
|
||||
color += vec3(sin(0.05*pos.y - cos(u_time/5.0)) + cos(0.05*pos.y/(0.1 + abs(cos(u_time/5.0)))),0.0,0.0);
|
||||
color += vec3(0.0, 0.0, sin(u_time));
|
||||
//color = vec3(st.y);
|
||||
|
||||
|
||||
|
||||
gl_FragColor = vec4(color,1.);
|
||||
}
|
||||
Reference in New Issue
Block a user