{"id":198,"date":"2024-03-16T22:59:44","date_gmt":"2024-03-17T06:59:44","guid":{"rendered":"https:\/\/karasu.tech\/?p=198"},"modified":"2024-09-23T12:04:48","modified_gmt":"2024-09-23T20:04:48","slug":"unity-shader-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e5%85%a5%e5%9c%9f%e5%ad%a6%e4%b9%a0%e9%9a%8f%e7%ac%94%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/karasu.tech\/?p=198","title":{"rendered":"Unity Shader \u4ece\u5165\u95e8\u5230\u5165\u571f\u5b66\u4e60\u968f\u7b14\uff08\u4e8c\uff09"},"content":{"rendered":"<p><strong>\u6e32\u67d3\u6d41\u6c34\u7ebf\u7684\u8d77\u70b9\u662fCPU\uff0c\u53ef\u7b49\u540c\u4e8e\u5e94\u7528\u9636\u6bb5<\/strong><br \/>\n1. \u6570\u636e\u52a0\u8f7d\u81f3\u663e\u5b58\u4e2d<\/p>\n<table>\n<thead>\n<tr>\n<th>CPU\u6570\u636e\u6d41\u8f6c<\/th>\n<th>GPU\u6570\u636e\u6d41\u8f6c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u786c\u76d8.HDD \u2192 \u7cfb\u7edf\u5185\u5b58.RAM \u2192<\/td>\n<td>\u663e\u5b58.VRAM<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>2.\u8bbe\u7f6e\u6e32\u67d3\u72b6\u6001<br \/>\n\u5b9a\u4e49\u7f51\u683c\u4f7f\u7528\u4e86\u54ea\u4e2aShader\u3001\u5149\u6e90\u5c5e\u6027\u3001\u6750\u8d28<br \/>\n&nbsp;<br \/>\n3. \u8c03\u7528DrawCall<br \/>\nCPU\u901a\u77e5GPU\u53ef\u4ee5\u663e\u5b58\u4ece\u83b7\u53d6\u6e32\u67d3\u5143\u5f00\u59cb\u6e32\u67d3\u5de5\u4f5c\u4e86<\/p>\n<hr \/>\n<p>cpu\u6d41\u6c34\u7ebf\uff08\u6838\u5fc3\u6570\u636e\u5904\u7406\uff09<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>\u51e0\u4f55\u9636\u6bb5<\/th>\n<th>\u5149\u6805\u5316\u9636\u6bb5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u9876\u70b9\u6570\u636e \u2192<\/td>\n<td><strong>\u9876\u70b9\u7740\u8272\u5668<\/strong> \u2192 <em>\u66f2\u9762\u7ec6\u5206\u7740\u8272\u5668<\/em> \u2192 <em>\u51e0\u4f55\u7740\u8272\u5668<\/em> \u2192 \u88c1\u526a \u2192 \u5c4f\u5e55\u6620\u5c04 \u2192<\/td>\n<td>\u4e09\u89d2\u5f62\u8bbe\u7f6e \u2192 \u4e09\u89d2\u5f62\u904d\u5386 \u2192 <em>\u7247\u5143\u7740\u8272\u5668<\/em> \u2192 \u9010\u7247\u5143\u64cd\u4f5c \u2192 \u5c4f\u5e55\u56fe\u50cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u9876\u70b9Shader \u8ba1\u7b97\u9876\u70b9\u7a7a\u95f4\u53d8\u6362\uff0c\u9010\u9876\u70b9\u5149\u7167<\/li>\n<li>\u66f2\u9762\u7ec6\u5206Shader \u7528\u4e8e\u7ec6\u5206\u56fe\u5143<\/li>\n<li>\u51e0\u4f55Shader \u7528\u4e8e\u8ba1\u7b97\u6267\u884c\u9010\u56fe\u5143\u6216\u4ea7\u751f\u66f4\u591a\u7684\u56fe\u5143<\/li>\n<li>\u7247\u5143Shader \u7528\u4e8e\u5b9e\u73b0\u9010\u7247\u5143\u7740\u8272\u64cd\u4f5c<\/li>\n<li>\u9010\u7247\u5143\u64cd\u4f5c \u4e0d\u53ef\u7f16\u7a0b\uff0c\u63d0\u4f9b\u914d\u7f6e\uff08\u9ad8\u914d\u7f6e\uff09\u4fee\u6539\u989c\u8272\uff0c\u6df1\u5ea6\u7f13\u51b2\uff0c\u8fdb\u884c\u6df7\u5408<\/li>\n<\/ul>\n<hr \/>\n<h2>\u9876\u70b9Shader<\/h2>\n<p>\u5fc5\u9009\u5b8c\u6210\u5de5\u4f5c\u628a\u9876\u70b9\u5750\u6807\u4ece\u6a21\u578b\u7a7a\u95f4\u8f6c\u6362\u5230\u9f50\u6b21\u88c1\u526a\u7a7a\u95f4<\/p>\n<ul>\n<li>o.pos = mwl(UNITY_MVP, V.position);<\/li>\n<\/ul>\n<p>\u5728\u8fdb\u884c\u4e09\u89d2\u5f62\u904d\u5386\u65f6\uff0c\u88ab\u4e00\u4e2a\u4e09\u89d2\u7f51\u683c\u6240\u8986\u76d6\uff0c\u5c31\u4f1a\u5f62\u6210\u4e00\u4e2a\u7247\u5143\u3002\u7247\u5143\u72b6\u6001\u5bf9\u9876\u70b9\u7684\u4fe1\u606f\u8fdb\u884c\u63d2\u503c\u8ba1\u7b97\u5f97\u5230<\/p>\n<hr \/>\n<h2>\u7247\u5143Shader<\/h2>\n<p>\u6839\u636e\u7247\u5143\u72b6\u6001\u4fe1\u606f\uff0c\u8ba1\u7b97\u7247\u5143\u8f93\u51fa\u989c\u8272<br \/>\n\u5c40\u9650\u4ec5\u53ef\u4ee5\u5f71\u54cd\u5355\u4e2a\u7247\u5143<\/p>\n<hr \/>\n<h2>\u9010\u7247\u5143\u64cd\u4f5c<\/h2>\n<p>\u53c8\u79f0\u4f5c\u8f93\u51fa\u5408\u5e76\u9636\u6bb5\uff08output &#8211; mergan\uff09<br \/>\n1. \u901a\u8fc7\u6df1\u5ea6\u3001\u6a21\u677f\u7b49\u6d4b\u8bd5\u7247\u5143\u7684\u53ef\u89c1\u6027<br \/>\n2. \u901a\u8fc7\u6d4b\u8bd5\u7684\u7247\u5143\u8272\u503c\u8fdb\u884c\u5408\u5e76\u6df7\u5408<\/p>\n<p>\u7247\u5143 \u2192 \u6a21\u677f\u6d4b\u8bd5 \u2192 \u6df1\u5ea6\u6d4b\u8bd5 \u2192 \u6df7\u5408 \u2192 \u989c\u8272\u7f13\u51b2\u533a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u771f\u5b9e\u7684GPU\u6e32\u67d3\u6d41\u6c34\u7ebf\u662f\u5982\u4f55\u7684\uff1f<\/p>\n","protected":false},"author":2,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[18,11,16],"class_list":["post-198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-renedermath","tag-gpu","tag-11","tag-16"],"_links":{"self":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/198","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=198"}],"version-history":[{"count":5,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions\/204"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}