summaryrefslogtreecommitdiff
path: root/warper/bin/data/shaders
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-02-02 01:47:51 +0000
committerTim Redfern <tim@getdrop.com>2018-02-02 01:47:51 +0000
commit7c50a03c5857310aa383b1ba89a18792c96724b1 (patch)
tree97727831c97af5c06b39064dfdba60d61f7c7ae3 /warper/bin/data/shaders
parent2b6c19dd192b07fe5980f667e26015da51c3106d (diff)
lots
Diffstat (limited to 'warper/bin/data/shaders')
-rw-r--r--warper/bin/data/shaders/ofxWarp/ControlPoint.frag16
-rw-r--r--warper/bin/data/shaders/ofxWarp/ControlPoint.vert23
-rw-r--r--warper/bin/data/shaders/ofxWarp/WarpBilinear.frag57
-rw-r--r--warper/bin/data/shaders/ofxWarp/WarpBilinear.vert21
-rw-r--r--warper/bin/data/shaders/ofxWarp/WarpPerspective.frag38
-rw-r--r--warper/bin/data/shaders/ofxWarp/WarpPerspective.vert21
6 files changed, 176 insertions, 0 deletions
diff --git a/warper/bin/data/shaders/ofxWarp/ControlPoint.frag b/warper/bin/data/shaders/ofxWarp/ControlPoint.frag
new file mode 100644
index 0000000..87ef7a3
--- /dev/null
+++ b/warper/bin/data/shaders/ofxWarp/ControlPoint.frag
@@ -0,0 +1,16 @@
+#version 150
+
+in vec2 vTexCoord;
+in vec4 vColor;
+
+out vec4 fragColor;
+
+void main(void)
+{
+ vec2 uv = vTexCoord * 2.0 - 1.0;
+ float d = dot(uv, uv);
+ float rim = smoothstep(0.7, 0.8, d);
+ rim += smoothstep(0.3, 0.4, d) - smoothstep(0.5, 0.6, d);
+ rim += smoothstep(0.1, 0.0, d);
+ fragColor = mix(vec4( 0.0, 0.0, 0.0, 0.25), vColor, rim);
+}
diff --git a/warper/bin/data/shaders/ofxWarp/ControlPoint.vert b/warper/bin/data/shaders/ofxWarp/ControlPoint.vert
new file mode 100644
index 0000000..8eccc63
--- /dev/null
+++ b/warper/bin/data/shaders/ofxWarp/ControlPoint.vert
@@ -0,0 +1,23 @@
+#version 150
+
+// OF default uniforms and attributes
+uniform mat4 modelViewProjectionMatrix;
+uniform vec4 globalColor;
+
+in vec4 position;
+in vec2 texcoord;
+in vec4 color;
+
+// App uniforms and attributes
+in vec4 iPositionScale;
+in vec4 iColor;
+
+out vec2 vTexCoord;
+out vec4 vColor;
+
+void main(void)
+{
+ vTexCoord = texcoord;
+ vColor = globalColor * iColor;
+ gl_Position = modelViewProjectionMatrix * vec4(position.xy * iPositionScale.z + iPositionScale.xy, position.zw);
+}
diff --git a/warper/bin/data/shaders/ofxWarp/WarpBilinear.frag b/warper/bin/data/shaders/ofxWarp/WarpBilinear.frag
new file mode 100644
index 0000000..14597bb
--- /dev/null
+++ b/warper/bin/data/shaders/ofxWarp/WarpBilinear.frag
@@ -0,0 +1,57 @@
+#version 150
+
+uniform sampler2D uTexture;
+uniform vec4 uExtends;
+uniform vec3 uLuminance;
+uniform vec3 uGamma;
+uniform vec4 uEdges;
+uniform vec4 uCorners;
+uniform float uExponent;
+uniform bool uEditing;
+
+in vec2 vTexCoord;
+in vec4 vColor;
+
+out vec4 fragColor;
+
+float map(in float value, in float inMin, in float inMax, in float outMin, in float outMax)
+{
+ return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
+}
+
+float grid(in vec2 uv, in vec2 size)
+{
+ vec2 coord = uv / size;
+ vec2 grid = abs(fract(coord - 0.5) - 0.5) / (2.0 * fwidth(coord));
+ float line = min(grid.x, grid.y);
+ return 1.0 - min(line, 1.0);
+}
+
+void main(void)
+{
+ vec4 texColor = texture(uTexture, vTexCoord);
+
+ vec2 mapCoord = vec2(map(vTexCoord.x, uCorners.x, uCorners.z, 0.0, 1.0), map(vTexCoord.y, uCorners.y, uCorners.w, 0.0, 1.0));
+
+ float a = 1.0;
+ if (uEdges.x > 0.0) a *= clamp(mapCoord.x / uEdges.x, 0.0, 1.0);
+ if (uEdges.y > 0.0) a *= clamp(mapCoord.y / uEdges.y, 0.0, 1.0);
+ if (uEdges.z > 0.0) a *= clamp((1.0 - mapCoord.x) / uEdges.z, 0.0, 1.0);
+ if (uEdges.w > 0.0) a *= clamp((1.0 - mapCoord.y) / uEdges.w, 0.0, 1.0);
+
+ const vec3 one = vec3(1.0);
+ vec3 blend = (a < 0.5) ? (uLuminance * pow(2.0 * a, uExponent)) : one - (one - uLuminance) * pow(2.0 * (1.0 - a), uExponent);
+
+ texColor.rgb *= pow(blend, one / uGamma);
+
+ if (uEditing)
+ {
+ float f = grid(mapCoord.xy * uExtends.xy, uExtends.zw);
+ vec4 gridColor = vec4(1.0f);
+ fragColor = mix(texColor * vColor, gridColor, f);
+ }
+ else
+ {
+ fragColor = texColor * vColor;
+ }
+}
diff --git a/warper/bin/data/shaders/ofxWarp/WarpBilinear.vert b/warper/bin/data/shaders/ofxWarp/WarpBilinear.vert
new file mode 100644
index 0000000..81e4fad
--- /dev/null
+++ b/warper/bin/data/shaders/ofxWarp/WarpBilinear.vert
@@ -0,0 +1,21 @@
+#version 150
+
+// OF default uniforms and attributes
+uniform mat4 modelViewProjectionMatrix;
+uniform vec4 globalColor;
+
+in vec4 position;
+in vec2 texcoord;
+in vec4 color;
+
+// App uniforms and attributes
+out vec2 vTexCoord;
+out vec4 vColor;
+
+void main(void)
+{
+ vTexCoord = texcoord;
+ vColor = globalColor;
+
+ gl_Position = modelViewProjectionMatrix * position;
+}
diff --git a/warper/bin/data/shaders/ofxWarp/WarpPerspective.frag b/warper/bin/data/shaders/ofxWarp/WarpPerspective.frag
new file mode 100644
index 0000000..82c1a0b
--- /dev/null
+++ b/warper/bin/data/shaders/ofxWarp/WarpPerspective.frag
@@ -0,0 +1,38 @@
+#version 150
+
+uniform sampler2D uTexture;
+uniform vec3 uLuminance;
+uniform vec3 uGamma;
+uniform vec4 uEdges;
+uniform vec4 uCorners;
+uniform float uExponent;
+
+in vec2 vTexCoord;
+in vec4 vColor;
+
+out vec4 fragColor;
+
+float map(in float value, in float inMin, in float inMax, in float outMin, in float outMax)
+{
+ return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
+}
+
+void main(void)
+{
+ vec4 texColor = texture(uTexture, vTexCoord);
+
+ vec2 mapCoord = vec2(map(vTexCoord.x, uCorners.x, uCorners.z, 0.0, 1.0), map(vTexCoord.y, uCorners.y, uCorners.w, 0.0, 1.0));
+
+ float a = 1.0;
+ if (uEdges.x > 0.0) a *= clamp(mapCoord.x / uEdges.x, 0.0, 1.0);
+ if (uEdges.y > 0.0) a *= clamp(mapCoord.y / uEdges.y, 0.0, 1.0);
+ if (uEdges.z > 0.0) a *= clamp((1.0 - mapCoord.x) / uEdges.z, 0.0, 1.0);
+ if (uEdges.w > 0.0) a *= clamp((1.0 - mapCoord.y) / uEdges.w, 0.0, 1.0);
+
+ const vec3 one = vec3(1.0);
+ vec3 blend = (a < 0.5) ? (uLuminance * pow(2.0 * a, uExponent)) : one - (one - uLuminance) * pow(2.0 * (1.0 - a), uExponent);
+
+ texColor.rgb *= pow(blend, one / uGamma);
+
+ fragColor = texColor * vColor;
+}
diff --git a/warper/bin/data/shaders/ofxWarp/WarpPerspective.vert b/warper/bin/data/shaders/ofxWarp/WarpPerspective.vert
new file mode 100644
index 0000000..81e4fad
--- /dev/null
+++ b/warper/bin/data/shaders/ofxWarp/WarpPerspective.vert
@@ -0,0 +1,21 @@
+#version 150
+
+// OF default uniforms and attributes
+uniform mat4 modelViewProjectionMatrix;
+uniform vec4 globalColor;
+
+in vec4 position;
+in vec2 texcoord;
+in vec4 color;
+
+// App uniforms and attributes
+out vec2 vTexCoord;
+out vec4 vColor;
+
+void main(void)
+{
+ vTexCoord = texcoord;
+ vColor = globalColor;
+
+ gl_Position = modelViewProjectionMatrix * position;
+}