{"id":3164,"date":"2014-08-16T05:42:29","date_gmt":"2014-08-16T03:42:29","guid":{"rendered":"http:\/\/hintz.bplaced.net\/?p=3164"},"modified":"2015-03-16T01:28:08","modified_gmt":"2015-03-16T00:28:08","slug":"metamorphosis","status":"publish","type":"post","link":"http:\/\/hintz.bplaced.net\/de\/2014\/webgl\/metamorphosis\/","title":{"rendered":"Caterpillar Metamorphosis"},"content":{"rendered":"<p>Durch Neuordnung von Zellen entsteht aus einer Raupe ein schillernder Schmetterling.<\/p>\n<p class=\"webgl\"><img decoding=\"async\" src=\"http:\/\/hintz.bplaced.net\/images\/2014\/08\/caterpillar.jpg\" \/><a href=\"http:\/\/glslsandbox.com\/e#19194.13\"><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\/\/ Caterpillar 2014-08-16 by @hintz\n#define CGFloat float\n#define M_PI 3.14159265359\nvec3 hsvtorgb(float h, float s, float v)\n{\n\tfloat c = v * s;\n\th = mod((h * 6.0), 6.0);\n\tfloat x = c * (1.0 - abs(mod(h, 2.0) - 1.0));\n\tvec3 color;\n\tif (h < 1.0) \n\t{\n\t\tcolor = vec3(c, x, 0.0);\n\t}\n\telse if (h < 2.0) \n\t{\n\t\tcolor = vec3(x, c, 0.0);\n\t}\n\telse if (h < 3.0) \n\t{\n\t\tcolor = vec3(0.0, c, x);\n\t}\n\telse if (h < 4.0) \n\t{\n\t\tcolor = vec3(0.0, x, c);\n\t}\n\telse if (h < 5.0) \n\t{\n\t\tcolor = vec3(x, 0.0, c);\n\t}\n\telse if (h < 6.0) \n\t{\n\t\tcolor = vec3(c, 0.0, x);\n\t}\n\telse\n\t{\n\t\tcolor = vec3(0.0);\n\t}\n\tcolor += v - c;\n\treturn color;\n}\nvoid main(void) \n{\n\tvec2 position = (gl_FragCoord.xy - 0.5 * resolution) \/ resolution.y;\n\tfloat x = position.x;\n\tfloat y = position.y;\n\tvec3 color = vec3(0.0);\n\tfloat m = 9999.0;\n\tfloat t = time * 0.01;\n\tfor (int i = 1; i <= 60; i++)\n\t{\n\t\tfloat j = float(i);\n\t\tvec2 p = 0.5 * vec2(cos(j * t), sin(j * t * 1.01));\n\t\tfloat d = distance(p, position);\n\t\tif (d < m)\n\t\t{\n\t\t\tm = d;\n\t\t\tfloat d1 = 1.0 - d;\n\t\t\tcolor += pow(d1, 10.0) * hsvtorgb(j * 0.01234, 0.8, 1.0);\n\t\t}\n\t}\n\tgl_FragColor = vec4(color, 1.0);\n}\n<\/script><\/canvas><\/a><\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Durch Neuordnung von Zellen entsteht aus einer Raupe ein schillernder Schmetterling.<\/p>\n","protected":false},"author":1,"featured_media":3173,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[144],"tags":[149,189],"_links":{"self":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3164"}],"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=3164"}],"version-history":[{"count":10,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3164\/revisions"}],"predecessor-version":[{"id":3179,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3164\/revisions\/3179"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media\/3173"}],"wp:attachment":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media?parent=3164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/categories?post=3164"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/tags?post=3164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}