{"id":1573,"date":"2017-03-15T11:18:05","date_gmt":"2017-03-15T02:18:05","guid":{"rendered":"http:\/\/www.digifie.jp\/blog\/?p=1573"},"modified":"2017-03-15T11:18:05","modified_gmt":"2017-03-15T02:18:05","slug":"unity-%e6%b0%b4%e3%81%ae%e6%8f%ba%e3%82%89%e3%81%8e%e3%81%a8%e6%b0%b4%e9%9d%a2%e3%81%ae%e5%8f%8d%e5%b0%84%e3%81%a3%e3%81%bd%e3%81%84%e3%83%9d%e3%82%b9%e3%83%88%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af","status":"publish","type":"post","link":"https:\/\/www.digifie.jp\/blog\/archives\/1573","title":{"rendered":"Unity \u6c34\u306e\u63fa\u3089\u304e\u3068\u6c34\u9762\u306e\u53cd\u5c04\u3063\u307d\u3044\u30dd\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8"},"content":{"rendered":"<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fwww.digifie.jp%2Fblog%2Farchives%2F1573&t=Unity%20%E6%B0%B4%E3%81%AE%E6%8F%BA%E3%82%89%E3%81%8E%E3%81%A8%E6%B0%B4%E9%9D%A2%E3%81%AE%E5%8F%8D%E5%B0%84%E3%81%A3%E3%81%BD%E3%81%84%E3%83%9D%E3%82%B9%E3%83%88%E3%82%A8%E3%83%95%E3%82%A7%E3%82%AF%E3%83%88' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/www.digifie.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.digifie.jp\/blog\/archives\/1573\" data-text=\"Unity \u6c34\u306e\u63fa\u3089\u304e\u3068\u6c34\u9762\u306e\u53cd\u5c04\u3063\u307d\u3044\u30dd\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8\" data-via=\"LLC DigiFie\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n<p>\u524d\u56de\u3001GLSL \u304b\u3089\u79fb\u690d\u3057\u3066<a href=\"http:\/\/www.digifie.jp\/blog\/archives\/1561\">\u6c34\u306e\u6ce2\u7d0b\u3068\u63fa\u3089\u304e\u3063\u307d\u3044\u30dd\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8<\/a>\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f GLSL Sandbox \u306e\u3053\u308c <a href=\"http:\/\/glslsandbox.com\/e#39055.2\" target=\"_blank\">http:\/\/glslsandbox.com\/e#39055.2<\/a>  \u3092\u79fb\u690d\u3057\u3066\u3001\u6c34\u306e\u63fa\u3089\u304e\u3068\u6c34\u9762\u306e\u53cd\u5c04\u3063\u307d\u3044\u30dd\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><iframe loading=\"lazy\" width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/E_KDbcocbvM\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u79fb\u690d\u5143\u306e\u30b3\u30fc\u30c9\u3068\u3001\u79fb\u690d\u5f8c\u306e\u30b3\u30fc\u30c9\u3092\u6bd4\u8f03\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u79fb\u690d\u5143 GLSL \u306e main \u95a2\u6570<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvoid main( void ) {\r\n\tvec2 sp = surfacePosition;\/\/vec2(.4, .7);\r\n\tvec2 p = sp * 15.0 - vec2(20.0);\r\n\tvec2 i = p;\r\n\tfloat c = 0.0; \/\/ brightness; larger -&gt; darker\r\n\tfloat inten = 0.025; \/\/ brightness; larger -&gt; brighter\r\n\tfloat speed = 1.5; \/\/ larger -&gt; slower\r\n\tfloat speed2 = 3.0; \/\/ larger -&gt; slower\r\n\tfloat freq = 0.8; \/\/ ripples\r\n\tfloat xflow = 1.5; \/\/ flow speed in x direction\r\n\tfloat yflow = 0.0; \/\/ flow speed in y direction\r\n\r\n\tfor (int n = 0; n &lt; MAX_ITER; n++) {\r\n\t\tfloat t = time * (1.0 - (3.0 \/ (float(n) + speed)));\r\n\t\ti = p + vec2(cos(t - i.x * freq) + sin(t + i.y * freq) + (time * xflow), sin(t - i.y * freq) + cos(t + i.x * freq) + (time * yflow));\r\n\t\tc += 1.0 \/ length(vec2(p.x \/ (sin(i.x + t * speed2) \/ inten), p.y \/ (cos(i.y + t * speed2) \/ inten)));\r\n\t}\r\n\t\r\n\tc \/= float(MAX_ITER);\r\n\tc = 1.5 - sqrt(c);\r\n\tgl_FragColor = vec4(vec3(c * c * c * c), 0.0) + vec4(0.0, 0.4, 0.55, 1.0);\r\n}\r\n<\/pre>\n<p>\u79fb\u690d\u5f8c\u306eUnity\u7528\u30a4\u30e1\u30fc\u30b8\u30a8\u30d5\u30a7\u30af\u30c8\u306e frag \u95a2\u6570<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ \u30a8\u30c7\u30a3\u30bf\u304b\u3089\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b Properties \u306b\u5909\u6570\u3092\u767b\u9332\u3057\u3066\u304a\u304f\r\nsampler2D _MainTex;\r\nint _MaxIter;\r\nfloat _Refrection;\r\nfloat _Brightness;\r\nfloat _Fineness;\r\nfloat _Speed;\r\nfloat _Speed2;\r\nfloat _Power;\r\nfloat _DirectionX;\r\nfloat _DirectionY;\r\nfixed4 _Color;\r\n\r\nfixed4 frag (v2f_img i) : SV_Target\r\n{\r\n\tfloat time = _Time * 30;\r\n\t\r\n\thalf2 sp = i.uv; \/\/ surfacePosition \u306f i.uv \u3067\u7f6e\u304d\u63db\u3048\u308b\r\n\thalf2 p = sp * _Fineness - half2(_Fineness * 1.3, _Fineness * 1.3);\r\n\thalf2 _i = p;\r\n\tfloat c = _Refrection;\r\n\tfloat inten = .025 * _Brightness;\r\n\tfloat speed = _Speed;\r\n\tfloat speed2 = _Speed2;\r\n\tfloat freq = _Power;\r\n\tfloat xflow = _DirectionX;\r\n\tfloat yflow = _DirectionY;\r\n\t\r\n\tfor (int n = 0; n &lt; float(_MaxIter); n++) \r\n\t{\r\n\t\tfloat t = time * (1.0 - (3.0 \/ (n + speed)));\r\n\t\t_i = p + half2(cos(t - _i.x * freq) + sin(t + _i.y * freq) + (time * xflow), sin(t - _i.y * freq) + cos(t + _i.x * freq) + (time * yflow));\r\n\t\tc += 1.0 \/ length(half2(p.x \/ (sin(_i.x + t * speed2) \/ inten), p.y \/ (cos(_i.y + t * speed2) \/ inten)));\r\n\t}\r\n\r\n\tc \/= _MaxIter;\r\n\tc = 1.5 - sqrt(c);\r\n\r\n\t\/\/ _MainTex \u306b\u30a8\u30d5\u30a7\u30af\u30c8\u3092\u9069\u7528\u3055\u305b\u308b\u305f\u3081\u306b uv \u306b\u5909\u5f62\u3092\u52a0\u3048\u3064\u3064\u6ce2\u306e\u30a8\u30d5\u30a7\u30af\u30c8\u3092 tex \u306b\u52a0\u7b97\u3059\u308b\r\n\t\/\/ _Color \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3057\u3066\u30a8\u30c7\u30a3\u30bf\u304b\u3089\u8272\u5473\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\r\n\thalf3 _col = half3(c * c * c * c, c * c * c * c, c * c * c * c) + half3(_Color.r, _Color.g, _Color.b);\r\n\thalf4 tex = tex2D(_MainTex, i.uv + c * .025);\r\n\treturn tex + (half4(_col, 1) * .5);\r\n\t\r\n\t\/\/ \u4e0a\u306e\u4e09\u884c\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u4e0b\u8a18\u3092\u6709\u52b9\u306b\u3059\u308b\u3068\u79fb\u690d\u5143\u306e GLSL \u3068\u540c\u3058\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308b\r\n\/\/\thalf3 _col = half3(c * c * c * c, c * c * c * c, c * c * c * c) + half3(0.0, 0.4, 0.55);\r\n\/\/\treturn half4(_col, 1);\r\n\r\n}\r\n<\/pre>\n<p>\u4eca\u56de\u3082\u8907\u96d1\u306a\u3068\u3053\u308d\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u5c11\u3057\u3060\u3051\u30dd\u30a4\u30f3\u30c8\u3092\u3002<\/p>\n<p>vec \u7cfb\u306e\u5909\u6570\u306e\u578b\u3092 half \u306b\u7f6e\u304d\u63db\u3048\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u306e\u969b vec \u3060\u3068 vec2(0.0) \u306e\u3088\u3046\u306b x, y \u304c\u540c\u3058\u5024\u306e\u6642\u306f\u7701\u7565\u3057\u3066\u66f8\u304d\u307e\u3059\u304c\u3001half \u3067 half2(0.0) \u3068\u66f8\u304f\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u306e\u3067\u3081\u3093\u3069\u304f\u3055\u3044\u3051\u3069\u7701\u7565\u305b\u305a\u306b half2(0.0, 0.0) \u3068\u66f8\u304f\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br \/>\nGLSL \u3067\u306f surfacePosition \u3068\u306a\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u306f Cg\/HLSL \u3067\u306f i.uv \u3067\u3088\u3055\u305d\u3046\u3067\u3059\u3002<br \/>\n\u3042\u3068\u3001\u79fb\u690d\u5143\u306e\u30a8\u30d5\u30a7\u30af\u30c8\u3092 _MainTex \u306b\u53cd\u6620\u3055\u305b\u308b\u65b9\u6cd5\u306f\u4e0a\u8a18\u30b3\u30fc\u30c9\u5185\u3067\u30b3\u30e1\u30f3\u30c8\u3057\u3066\u3044\u308b\u901a\u308a\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u3044\u304f\u3064\u304b\u306e\u5909\u6570\u3092 Properties \u306b\u767b\u9332\u3057\u3066\u3001\u4e0b\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u306e\u3088\u3046\u306bUnity\u30a8\u30c7\u30a3\u30bf\u4e0a\u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.digifie.jp\/blog\/wp-content\/uploads\/2017\/03\/44887e992a33c2b62540e4fb33fedefb.png\" alt=\"\" width=\"792\" height=\"438\" class=\"aligncenter size-full wp-image-1577\" srcset=\"https:\/\/www.digifie.jp\/blog\/wp-content\/uploads\/2017\/03\/44887e992a33c2b62540e4fb33fedefb.png 792w, https:\/\/www.digifie.jp\/blog\/wp-content\/uploads\/2017\/03\/44887e992a33c2b62540e4fb33fedefb-300x166.png 300w, https:\/\/www.digifie.jp\/blog\/wp-content\/uploads\/2017\/03\/44887e992a33c2b62540e4fb33fedefb-768x425.png 768w\" sizes=\"(max-width: 792px) 100vw, 792px\" \/><\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fwww.digifie.jp%2Fblog%2Farchives%2F1573&t=Unity%20%E6%B0%B4%E3%81%AE%E6%8F%BA%E3%82%89%E3%81%8E%E3%81%A8%E6%B0%B4%E9%9D%A2%E3%81%AE%E5%8F%8D%E5%B0%84%E3%81%A3%E3%81%BD%E3%81%84%E3%83%9D%E3%82%B9%E3%83%88%E3%82%A8%E3%83%95%E3%82%A7%E3%82%AF%E3%83%88' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/www.digifie.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.digifie.jp\/blog\/archives\/1573\" data-text=\"Unity \u6c34\u306e\u63fa\u3089\u304e\u3068\u6c34\u9762\u306e\u53cd\u5c04\u3063\u307d\u3044\u30dd\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8\" data-via=\"LLC DigiFie\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u3001GLSL \u304b\u3089\u79fb\u690d\u3057\u3066\u6c34\u306e\u6ce2\u7d0b\u3068\u63fa\u3089\u304e\u3063\u307d\u3044\u30dd\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f GLSL Sandbox \u306e\u3053\u308c http:\/\/glslsandbox.com\/e#39055.2 \u3092\u79fb\u690d\u3057\u3066\u3001\u6c34\u306e\u63fa\u3089\u304e\u3068\u6c34 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[32],"tags":[],"_links":{"self":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts\/1573"}],"collection":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/comments?post=1573"}],"version-history":[{"count":5,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts\/1573\/revisions"}],"predecessor-version":[{"id":1579,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts\/1573\/revisions\/1579"}],"wp:attachment":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/media?parent=1573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/categories?post=1573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/tags?post=1573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}