{"id":5639,"date":"2024-04-24T18:40:13","date_gmt":"2024-04-24T10:40:13","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=5639"},"modified":"2024-04-24T21:25:22","modified_gmt":"2024-04-24T13:25:22","slug":"%e6%a8%a1%e6%8b%9f2d%e8%8d%89","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=5639","title":{"rendered":"Unity\u4e2d\u6a21\u62df2D\u8349"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"318\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2024\/04\/image.png\" alt=\"\" class=\"wp-image-5640\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2024\/04\/image.png 820w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2024\/04\/image-512x199.png 512w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2024\/04\/image-768x298.png 768w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2024\/04\/image-160x62.png 160w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/figure>\n\n\n\n<p>\u573a\u666f\u4e2d\u5927\u6279\u91cf\u7684\u8349\u53ef\u4ee5\u4f7f\u7528SkinnedMeshRender\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u9876\u70b9\u52a8\u753b\u6765\u6a21\u62df<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001x\u8f74\u53d7y\u7684\u5f71\u54cd\uff0c\u6a21\u62df\u6a2a\u5411\u6447\u6446<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>float offset = sin(y);\ninput.y += offset;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u9632\u6b62\u6240\u6709\u8349\u4e00\u8d77\u6447\u6446<\/h2>\n\n\n\n<p>\u4f7f\u7528\u5e72\u6270\u7cfb\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>float wo = unity_ObjectToWorld&#91;0]&#91;3]+unity_ObjectToWorld&#91;1]&#91;3]+unity_ObjectToWorld&#91;2]&#91;3];\n\u5373\u628axyz\u7684\u5750\u6807\u503c\u4f5c\u4e3a\u5e72\u6270\u7cfb\u6570<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u5b8c\u6574\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>float4 input = v.vertex;\r\nfloat wo = unity_ObjectToWorld&#91;0]&#91;3]+unity_ObjectToWorld&#91;1]&#91;3]+unity_ObjectToWorld&#91;2]&#91;3];\r\nfloat freq = pow( sin(_Time.x * wo * _Param1.x + input.y * _Param1.y), 2);\r\ninput.x += (input.y * freq * _Param1.z);\r\no.pos = UnityObjectToClipPos(input);<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u573a\u666f\u4e2d\u5927\u6279\u91cf\u7684\u8349\u53ef\u4ee5\u4f7f\u7528SkinnedMeshRender\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u9876\u70b9\u52a8\u753b\u6765\u6a21\u62df \u4e00\u3001x\u8f74\u53d7y\u7684\u5f71\u54cd\uff0c\u6a21\u62df [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/5639"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5639"}],"version-history":[{"count":3,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/5639\/revisions"}],"predecessor-version":[{"id":5643,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/5639\/revisions\/5643"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}