aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-01-25 17:13:23 +0000
committers-ol <s-ol@users.noreply.github.com>2020-01-25 17:13:23 +0000
commitcce4b6501dc0e8afacece8c79c2929ced0e6420b (patch)
tree4a3029f281dc7aad85f5e84ff97c4f8eb225caab
parentfix OSC server creation error handling (diff)
downloadglsl-view-cce4b6501dc0e8afacece8c79c2929ced0e6420b.tar.gz
glsl-view-cce4b6501dc0e8afacece8c79c2929ced0e6420b.zip
remove offset default uniform
-rw-r--r--shaders/test.frag21
-rw-r--r--src/main.zig10
2 files changed, 20 insertions, 11 deletions
diff --git a/shaders/test.frag b/shaders/test.frag
index d9b76c1..9dd03ea 100644
--- a/shaders/test.frag
+++ b/shaders/test.frag
@@ -6,7 +6,24 @@ out vec4 color;
uniform float offset;
uniform float r;
+uniform float radius = 1.;
+uniform float pitch = 440.;
+
+vec3 getcol() {
+ vec2 c = vec2(0.8, 0.2);
+ if (pitch > 4.0)
+ return c.xyy;
+ else if (pitch > 3.0)
+ return c.yxy;
+ else
+ return c.yxx;
+}
+
void main() {
- color = vec4(mod(uv.xyx + offset + vec2(0,0.5).xxy, vec3(1)), 1);
- color.r = r;
+ vec2 p = uv*2.-1.;
+ p.y *= 16./9.;
+
+ color = vec4(mod(p.xyx + offset + vec2(0,0.5).xxy, vec3(1)), 1);
+ color.r = r;
+ color.rgb = mix(color.rgb, getcol(), smoothstep(1, 0.9, length(p) / pow(radius, 0.4)));
}
diff --git a/src/main.zig b/src/main.zig
index bde9767..0530024 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -91,10 +91,8 @@ pub fn main() !void {
\\in vec2 uv;
\\out vec4 color;
\\
- \\uniform float offset;
- \\
\\void main() {
- \\ color = vec4(offset,0,0,1); // mod(uv + offset, vec2(1)), 0, 1);
+ \\ color = vec4(0,0,0,1);
\\}
);
defer main_program.destroy();
@@ -106,8 +104,6 @@ pub fn main() !void {
var fbo = try gl.FramebufferObject.create(config.width, config.height);
defer fbo.destroy();
- var offset: f32 = 0;
-
const control = try ctrl.ControlServer.init(&arena.allocator, config.osc);
defer control.destroy();
@@ -131,10 +127,6 @@ pub fn main() !void {
c.glClear(c.GL_COLOR_BUFFER_BIT);
main_program.bind();
- offset += @floatCast(f32, elapsed / 4);
- if (main_program.uniformLocation("offset")) |location| {
- main_program.setUniform1f(location, offset);
- } else |_| {}
constants.normalizedQuad.draw();
fbo.unbind();