// Copyright © 2017 Project Golan, all rights reserved. #version 120 uniform sampler2D DGE_Texture; uniform int DGE_Ticks; uniform float DGE_Seconds; varying vec4 color; varying vec4 texcoord; vec4 HSVToRGB(float h, float s, float v, float a) { h *= 360.0; if(h < 0) h = 0; else if(h > 359.5) h = 359.5; float chroma = v * s; float hp = h / 60.0; float x = chroma * (1 - abs(mod(hp, 2) - 1)); float r1 = 0, g1 = 0, b1 = 0; if(0 <= hp && hp < 1) r1 = chroma, g1 = x, b1 = 0; else if(1 <= hp && hp < 2) r1 = x, g1 = chroma, b1 = 0; else if(2 <= hp && hp < 3) r1 = 0, g1 = chroma, b1 = x; else if(3 <= hp && hp < 4) r1 = 0, g1 = x, b1 = chroma; else if(4 <= hp && hp < 5) r1 = x, g1 = 0, b1 = chroma; else if(5 <= hp && hp < 6) r1 = chroma, g1 = 0, b1 = x; float m = v - chroma; return vec4(r1 + m, g1 + m, b1 + m, a); } void main(void) { const float pi = 3.14159265; float t = (DGE_Seconds * 1000.0) / 32.0; vec2 uv = texcoord.xy * vec2(256.0, 224.0); float bx = uv.x + 0.5 * sin(t / 8.0); float by = uv.y + 0.5 * cos(t / 8.0); float v; v = sin((-bx + t) / 32.0); v += cos((by + t) / 32.0); v += sin((bx + by + t) / 32.0); v += sin((sqrt(pow(bx + sin(t / 3.0), 2.0) + pow(by + cos(t / 2.0), 2.0) + 1.0) + t) / 128.0); gl_FragColor = texture2D(DGE_Texture, texcoord.xy) * HSVToRGB(sin(v * pi) * 0.5 + 0.5, 1.0, 0.2, 1.0) * color; } // EOF