Created
August 7, 2012 16:37
-
-
Save lingo/3287140 to your computer and use it in GitHub Desktop.
glsl fiddling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From iq's latest live coding video, "a simple eye ball" | |
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform float time; | |
const mediump mat4 rgbToYuv = mat4( 0.257, 0.439, -0.148, 0.06, | |
0.504, -0.368, -0.291, 0.5, | |
0.098, -0.071, 0.439, 0.5, | |
0.0, 0.0, 0.0, 1.0); | |
const mediump mat4 yuvToRgb = mat4( 1.164, 1.164, 1.164, -0.07884, | |
2.018, -0.391, 0.0, 1.153216, | |
0.0, -0.813, 1.596, 0.53866, | |
0.0, 0.0, 0.0, 1.0); | |
void main(void) | |
{ | |
vec2 O = -1.0 + 2.0 * (mouse.xy); | |
vec2 q = gl_FragCoord.xy / resolution.xy; | |
vec2 p = -1.0 + 2.0 * q; | |
p.x *= resolution.x/resolution.y; | |
float th = atan(p.y, p.x - O.x); | |
float r = sqrt(dot(p - O,p)); | |
float rr = sqrt(dot(p - O,p - O)); | |
float rays = 12.0; | |
float waves = rays / 4.0 + tan(cos(time)); | |
float PI = 3.14159265; float PI_2 = PI / 2.0; | |
vec4 col = vec4(abs(th/PI_2 + PI*(sin(time))) - 0.5, 0.5 ,1.0 - sqrt((sin(r*r + rr*rr))),0); | |
gl_FragColor = col * yuvToRgb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment