tidying up some shader stuff (nameing etc)

This commit is contained in:
langolierz
2018-10-16 20:54:48 +00:00
parent f1ee096cb3
commit fc14b5023c
23 changed files with 69 additions and 416 deletions

View File

@@ -1,93 +0,0 @@
// KuwaharaFilter.cpp
// filterSandbox
//
// Originally Created by Matthew Fargo on 2014/06/23
//
//#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 radius = int(u_x0 * 10.0);
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;
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;
}
}
for (j = -radius; j <= 0; ++j) {
for (i = 0; i <= radius; ++i) {
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
m1 += c;
s1 += c * c;
}
}
for (j = 0; j <= radius; ++j) {
for (i = 0; i <= radius; ++i) {
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
m2 += c;
s2 += c * c;
}
}
for (j = 0; j <= radius; ++j) {
for (i = -radius; i <= 0; ++i) {
c = texture2D(u_tex0, v_texcoord + vec2(i,j) * src_size).rgb;
m3 += c;
s3 += c * c;
}
}
float min_sigma2 = 1e+2;
m0 /= n;
s0 = abs(s0 / n - m0 * m0);
float sigma2 = s0.r + s0.g + s0.b;
if (sigma2 < min_sigma2) {
min_sigma2 = sigma2;
gl_FragColor = vec4(m0, textureColor.a);
}
m1 /= n;
s1 = abs(s1 / n - m1 * m1);
sigma2 = s1.r + s1.g + s1.b;
if (sigma2 < min_sigma2) {
min_sigma2 = sigma2;
gl_FragColor = vec4(m1, textureColor.a);
}
m2 /= n;
s2 = abs(s2 / n - m2 * m2);
sigma2 = s2.r + s2.g + s2.b;
if (sigma2 < min_sigma2) {
min_sigma2 = sigma2;
gl_FragColor = vec4(m2, textureColor.a);
}
m3 /= n;
s3 = abs(s3 / n - m3 * m3);
sigma2 = s3.r + s3.g + s3.b;
if (sigma2 < min_sigma2) {
min_sigma2 = sigma2;
gl_FragColor = vec4(m3, textureColor.a);
}
}

View File

@@ -1,34 +0,0 @@
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);
}

View File

@@ -1,46 +0,0 @@
// 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;
}

View File

@@ -1,17 +0,0 @@
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);
}

View File

@@ -1,3 +1,4 @@
// this is the default.vert shader used by conjur , it ensures that the frag shaders run by glslViewer will also run in openframeworks
attribute vec4 position;
attribute vec4 color;
attribute vec3 normal;

View File

@@ -1,32 +0,0 @@
#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.);
}

View File

@@ -1,3 +1,6 @@
//gen-shader
//written by Tim Caldwell
// a simple example of how to use continuous parameters to perform switching functions
#ifdef GL_ES
precision mediump float;
#endif

View File

@@ -1,10 +0,0 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform float u_time;
uniform float u_x0;
void main() {
gl_FragColor = vec4(sin(1000.0*u_x0*u_time),0.0,0.0,1.0);
}

View File

@@ -9,17 +9,19 @@ precision mediump float;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
uniform vec2 u_resolution;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / u_resolution.xy ) + (u_resolution.x * u_x0, u_resolution.y * u_x1) / 4.0;
vec2 position = ( gl_FragCoord.xy / u_resolution.xy ) + (u_resolution.x, u_resolution.y * (u_x0*0.01)) / 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 );
color += sin( position.y * sin( u_time / 10.0 ) * 40.0 ) + cos( position.x * sin( u_time / 25.0 ) * 40.0 );
color += sin( position.x * sin( u_time / 5.0 ) * 10.0 ) + sin( position.y * sin( u_time / 35.0 ) * 80.0 );
color += sin( position.x * cos( u_time / 15.0 ) * 80.0 ) + cos( position.y * cos( u_time / 15.0 ) * 10.0 ) * u_x1;
color += sin( position.y * sin( u_time / 10.0 ) * 40.0 ) + cos( position.x * sin( u_time / 25.0 ) * 40.0 ) * u_x2;
color += sin( position.x * sin( u_time / 5.0 ) * 10.0 ) + sin( position.y * sin( u_time / 35.0 ) * 80.0 ) * u_x3;
color *= sin( u_time / 10.0 ) * 0.8;
gl_FragColor = vec4( vec3( color, color * 0.5, sin( color + u_time / 3.0 ) * 0.75 ), 1.0 );
gl_FragColor = vec4( vec3( color, color * 0.5 * sin(0.02*u_time) , sin( color + u_time / 3.0 ) * 0.75 ), 1.0 );
}

View File

@@ -0,0 +1,37 @@
//gen-shader
//written by Ben Caldwell
#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;
uniform float u_x3;
void main() {
vec3 color = vec3(0.0,0.0,0.0);
float mod_time = u_x0 * u_time;
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(mod_time)), u_resolution*(0.5 + 0.25*sin(mod_time)));
vec2 s2 = vec2(u_resolution.x*(0.5 + 0.25*sin(mod_time)), u_resolution*(0.5 + 0.25*cos(mod_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))*u_x1;
float r2 = (pow(pow(pos.x-s2.x,2.0) + pow(pos.y-s2.y,2.0), 0.5))*u_x2;
float r3 = (pow(pow(pos.x-s3.x,2.0) + pow(pos.y-s3.y,2.0), 0.5))*u_x3;
color += vec3(0.5 + 0.5*sign(sin((0.1 + 0.05*sin(mod_time+2.0))*r1 - 1.0*mod_time)), 0.0, 0.0);
color += vec3(0.0, 0.0, 0.5 + 0.5*sign(sin((0.1 + 0.05*sin(mod_time))*r2 - 1.2*mod_time)));
color += vec3(0.0, 0.5 + 0.5*sign(sin((0.1 + 0.05*sin(mod_time+0.5))*r3 - 1.1*mod_time)), 0.0);
gl_FragColor = vec4(color,1.);
}

View File

@@ -1,10 +0,0 @@
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);
}

View File

@@ -1,40 +0,0 @@
// 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);
}

View File

@@ -1,4 +1,5 @@
//gen-shader
//written by Ben Caldwell
#ifdef GL_ES
precision mediump float;
#endif
@@ -8,6 +9,7 @@ uniform float u_time;
uniform float u_x0;
uniform float u_x1;
uniform float u_x2;
uniform float u_x3;
void main() {
@@ -16,8 +18,8 @@ void main() {
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))));
color += vec3(u_x0*sign(sin(0.05*pos.x - u_time + sin(0.05*pow(pos.y,(0.7 + u_x1)) - u_time))),0.,0.);
color += vec3(0., 0., sign(cos(0.05*pos.x*u_x2 - 2.0*u_time + 5.0*u_x3*sin(0.05*pos.y - 2.0*u_time))));
gl_FragColor = vec4(color,1.);

View File

@@ -1,4 +1,5 @@
//gen-shader
//written by Ben Caldwell
#ifdef GL_ES
precision mediump float;
#endif
@@ -6,17 +7,19 @@ precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_x0;
uniform float u_x1;
void main() {
float mod_time = u_time*u_x0;
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));
color += vec3(sin(0.7*u_x1*pos.x - cos(u_x0*mod_time)) + cos(0.05*pos.x/(0.1 + abs(cos(mod_time/5.0)))),0.0,0.0);
color += vec3(sin(0.05*pos.y - cos(mod_time/5.0)) + cos(0.5*pos.y/(0.1 + abs(cos(mod_time/5.0)))),0.0,0.0);
color += vec3(0.0, 0.0, sin(mod_time));
gl_FragColor = vec4(color,1.);

View File

@@ -1,4 +1,5 @@
//pro-shader
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;
#endif
@@ -8,9 +9,6 @@ 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)
{

View File

@@ -1,16 +0,0 @@
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(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)))));
gl_FragColor = vec4(texColor.b, texColor.r, texColor.g, texColor.a);
}

View File

@@ -1,5 +1,6 @@
//pro-shader
//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;
@@ -7,7 +8,6 @@ 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);

View File

@@ -1,3 +1,4 @@
//pro-shader
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,6 @@
//pro-shader
//written by Tim Caldwell
//this is a basic example of how to effect input textures position
#ifdef GL_ES
precision mediump float;
#endif

View File

@@ -1,4 +1,5 @@
//pro-shader
//written by Tim Caldwell
#ifdef GL_ES
precision highp float;
#endif

View File

@@ -1,4 +1,5 @@
//pro-shader
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;
#endif

View File

@@ -1,4 +1,5 @@
//pro-shader
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;
#endif
@@ -17,8 +18,8 @@ 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.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;}

View File

@@ -1,101 +0,0 @@
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;
}
}
*/