{"id":3038,"date":"2013-05-06T17:08:59","date_gmt":"2013-05-06T15:08:59","guid":{"rendered":"http:\/\/hintz.bplaced.net\/?p=3038"},"modified":"2015-03-16T01:31:01","modified_gmt":"2015-03-16T00:31:01","slug":"rose-animation","status":"publish","type":"post","link":"http:\/\/hintz.bplaced.net\/de\/2013\/webgl\/rose-animation\/","title":{"rendered":"WebGL Rose Animation"},"content":{"rendered":"<p><\/p>\n<p class=\"webgl\"><img decoding=\"async\" src=\"http:\/\/hintz.bplaced.net\/images\/2013\/05\/rose-animation.jpg\" \/><a href=\"http:\/\/glslsandbox.com\/e#7873.0\"><canvas width=\"620\" height=\"620\"><script type=\"x-shader\/x-vertex\">attribute vec2 position; void main() { gl_Position = vec4(position, 0, 1); }<\/script><script type=\"x-shader\/x-fragment\">\n#ifdef GL_ES\nprecision mediump float;\n#endif\nuniform float time;\nuniform vec2 mouse;\nuniform vec2 resolution;\n\/\/ 2013-03-30 by @hintz\n#define CGFloat float\n#define M_PI 3.14159265359\nvec4 hsvtorgb(vec3 col)\n{\n    float iH = floor(mod(col.x,1.0)*6.0);\n    float fH = mod(col.x,1.0)*6.0-iH;\n    float p = col.z*(1.0-col.y);\n    float q = col.z*(1.0-fH*col.y);\n    float t = col.z*(1.0-(1.0-fH)*col.y);\n  if (iH==0.0)\n  {\n    return vec4(col.z, t, p, 1.0);\n  }\n  if (iH==1.0)\n  {\n    return vec4(q, col.z, p, 1.0);\n  }\n  if (iH==2.0)\n  {\n    return vec4(p, col.z, t, 1.0);\n  }\n  if (iH==3.0)\n  {\n    return vec4(p, q, col.z, 1.0);\n  }\n  if (iH==4.0)\n  {\n    return vec4(t, p, col.z, 1.0);\n  } \n  return vec4(col.z, p, q, 1.0); \n}\nvoid main(void) \n{\n\tvec2 position = 0.5*(gl_FragCoord.xy - 0.5 * resolution) \/ resolution.y;\n\tfloat x = position.x;\n\tfloat y = position.y;\n\tCGFloat a = atan(x, y);\n    \tCGFloat d = sqrt(x*x+y*y);\n    \tCGFloat d0 = 0.5*(sin(d-time)+1.5)*d+0.02*time;\n    \tCGFloat d1 = 5.0; \n    \tCGFloat u = mod(a*d1+sin(d*10.0+time), M_PI*2.0)\/M_PI*0.5 - 0.5;\n    \tCGFloat v = mod(pow(d0*4.0, 0.75),1.0) - 0.5;\n    \tCGFloat dd = sqrt(u*u+v*v*d1);\n    \tCGFloat aa = atan(u, v);\n    \tCGFloat uu = mod(aa*3.0+3.0*cos(dd*16.0-time), M_PI*2.0)\/M_PI*0.5 - 0.5;\n    \t\/\/ CGFloat vv = mod(dd*4.0,1.0) - 0.5;\n    \tCGFloat d2 = sqrt(uu*uu+v*v)*1.5;   \n\tgl_FragColor = hsvtorgb(vec3(dd+time*0.5\/d1, dd, d2));\n}\n<\/script><\/canvas><\/a><\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":3049,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[144],"tags":[149,150,56,189],"_links":{"self":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3038"}],"collection":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/comments?post=3038"}],"version-history":[{"count":16,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3038\/revisions"}],"predecessor-version":[{"id":3184,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3038\/revisions\/3184"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media\/3049"}],"wp:attachment":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media?parent=3038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/categories?post=3038"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/tags?post=3038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}