{"id":184,"date":"2024-02-16T15:04:30","date_gmt":"2024-02-16T23:04:30","guid":{"rendered":"https:\/\/karasu.tech\/?p=184"},"modified":"2024-09-22T21:23:48","modified_gmt":"2024-09-23T05:23:48","slug":"unity-shader-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e5%85%a5%e5%9c%9f%ef%bc%88%e4%b8%80%ef%bc%89","status":"publish","type":"post","link":"https:\/\/karasu.tech\/?p=184","title":{"rendered":"Unity Shader \u4ece\u5165\u95e8\u5230\u5165\u571f\u5b66\u4e60\u968f\u7b14\uff08\u4e00\uff09"},"content":{"rendered":"<p><strong>\u6e32\u67d3\u6838\u5fc3\u4e24\u6b65\uff1a<\/strong><br \/>\n1. position the vertices<br \/>\n2. color the pixels<\/p>\n<p>&nbsp;<br \/>\n<strong>Unity Shader\u6838\u5fc3\u5206\u4e3a\u4e09\u4e2a\u6a21\u5757<\/strong><br \/>\n1. vertices shader\uff08\u7528\u4e8e\u6355\u6349\u6e32\u67d3\u7269\u4f53\u7684\u7a7a\u95f4\u4f4d\u7f6e\uff0c\u540e\u6295\u5f71\u81f3\u6240\u5904\u7684\u5c4f\u5e55\u4f4d\u7f6e\uff09<br \/>\n2. fragment shader\uff08\u786e\u8ba4\u5728vertices shader\u5185\uff0c\u8fdb\u884c\u7740\u8272\uff0c\u901a\u5e38\u7528rgba\uff09<br \/>\n3. z-buffering\uff08\u8ba1\u7b97shader\u6240\u751f\u6548\u5bf9\u8c61\u5230\u76f8\u673a\u7684\u8ddd\u79bb\uff0c\u7528\u4e8e\u7740\u8272\u5668\u7684\u53e0\u52a0\u5c55\u793a\uff0c\u901a\u5e38\u7531\u6e32\u67d3\u5668\u672c\u8eab\u8fdb\u884c\u8ba1\u7b97\uff09<br \/>\n&nbsp;<br \/>\n<strong><em>\u5728Shader\u4e2d\uff0c\u6bcf\u4e2a\u9876\u70b9\u548c\u50cf\u7d20\u90fd\u662f\u76f8\u4e92\u72ec\u7acb\u8ba1\u7b97\u7684\uff08GPU\u7684\u5e76\u884c\u903b\u8f91\uff09\uff0c\u6240\u4ee5\u5728\u5199Shader\u7684Workpipline\u4e2d\uff0c\u4e0e\u4ee5\u5f80\u7684\u7f16\u7a0b\u903b\u8f91\u4e0d\u540c<\/em><\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/Image-8-1024x300.png\" alt=\"\" \/><br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<p>\u6982\u5ff5\u6027\u9636\u6bb5\u7684\u6e32\u67d3\u6d41\u6c34\u7ebf\uff1a<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5e94\u7528\u9636\u6bb5 \u2192 \u51e0\u4f55\u9636\u6bb5 \u2192 \u5149\u6805\u5316\u9636\u6bb5<br \/>\n&nbsp;<br \/>\n<strong>\u4ee5\u4e0a\u6bcf\u4e2a\u9636\u6bb5\u672c\u8eab\u53ef\u80fd\u5c31\u662f\u4e2a\u6d41\u6c34\u7ebf\u7cfb\u7edf<\/strong><br \/>\n&nbsp;<\/p>\n<hr \/>\n<h2>\u5e94\u7528\u9636\u6bb5\uff08\u6838\u7531\u5f00\u53d1\u8005\u8d1f\u8d23\uff09<\/h2>\n<p>\u5f00\u53d1\u8005\u4e3b\u8981\u4e09\u4e2a\u4efb\u52a1<br \/>\n1. \u51c6\u5907\u573a\u666f\u6570\u636e\uff1a\u4f8b\u5982\u76f8\u673a\u4f4d\u7f6e\u3001\u89c6\u9525\u4f53\u3001\u5149\u6e90\u4fe1\u606f<br \/>\n2. \u63d0\u5347\u6e32\u67d3\u6027\u80fd\uff1a\u4f8b\u5982\u7c97\u9897\u7c92\u5ea6\u5254\u9664\u3001\u4e0d\u53ef\u89c6\u7269\u5254\u9664<br \/>\n3. \u8bbe\u7f6e\u9762\u7247\u6e32\u67d3\u72b6\u6001\uff1a\u4f7f\u7528\u7684\u6750\u8d28\u3001\u7eb9\u7406\u3001shader<\/p>\n<p>\u8fd9\u4e00\u9636\u6bb5\u8f93\u51fa\u6e32\u67d3\u51e0\u4f55\u4fe1\u606f\u2014\u2014\u6e32\u67d3\u56fe\u5143\uff08\u53ef\u4ee5\u662f\u70b9\u7ebf\u9762\uff09<br \/>\n&nbsp;<\/p>\n<h2>\u51e0\u4f55\u9636\u6bb5<\/h2>\n<p>\u5904\u7406\u6240\u6709\u9700\u8981\u7ed8\u5236\u7684\u96c6\u5408\u4e8b\u4ef6\uff0c\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4<br \/>\n1. \u51b3\u5b9a\u9700\u8981\u7ed8\u5236\u7684\u56fe\u5143<br \/>\n2. \u600e\u6837\u7ed8\u5236\uff1f\u5728\u54ea\u513f\u7ed8\u5236\uff1f<\/p>\n<p>\u901a\u5e38\u5728GPU\u4e0a\u8fdb\u884c\u4efb\u52a1\uff0c\u6838\u5fc3\u4efb\u52a1\u662f\u5c06\u9876\u70b9\u5750\u6807\u6362\u7b97\u5230\u5c4f\u5e55\u7a7a\u95f4\u5750\u6807\u4e2d\u3002<br \/>\n\u8f93\u51fa\u5c4f\u5e55\u7a7a\u95f4\u4e2d\u7684\u4e8c\u7ef4\u9876\u70b9\u5750\u6807\uff0c\u6bcf\u4e2a\u9876\u70b9\u5bf9\u5e94\u7684\u6df1\u5ea6\u503c\u3001\u7740\u8272\u7b49\u76f8\u5173\u4fe1\u606f\u3002<br \/>\n&nbsp;<\/p>\n<h2>\u5149\u6805\u5316\u9636\u6bb5<\/h2>\n<p>\u4f9d\u8d56\u51e0\u4f55\u9636\u6bb5\u6570\u636e\uff0c\u4ea7\u751f\u5c4f\u5e55\u50cf\u7d20\u3002\u51b3\u5b9a\u54ea\u4e9b\u50cf\u7d20\u88ab\u7ed8\u5236\uff0c\u5982\u4f55\u7ed8\u5236\uff08\u7eb9\u7406\u5750\u6807\uff0c\u9876\u70b9\u989c\u8272\uff0c\u8ba1\u7b97\u63d2\u503c\uff09<br \/>\n&nbsp;<\/p>\n<p><strong>\uff01\uff01\u4ee5\u4e0a\u4e09\u4e2a\u9636\u6bb5\u4e3a\u6982\u5ff5\u6d41\u6c34\uff0c\u4e0e\u771f\u5b9e\u7684GPU\u6d41\u6c34\u8ba1\u7b97\u4e0d\u540c<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eba\u603b\u8981\u6709\u70b9\u68a6\u60f3\uff0c\u60f3\u8981\u505a\u70b9\u4e1c\u897f\uff0c\u5c31\u5f97\u5b66\u70b9\u5de5\u5177&#8230;.<\/p>\n","protected":false},"author":2,"featured_media":191,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,17],"tags":[12,11,16],"class_list":["post-184","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-other","category-renedermath","tag-unity","tag-11","tag-16"],"_links":{"self":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":6,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/media\/191"}],"wp:attachment":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}