{"id":2706,"date":"2020-09-28T21:57:32","date_gmt":"2020-09-28T13:57:32","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=2706"},"modified":"2020-09-29T10:17:05","modified_gmt":"2020-09-29T02:17:05","slug":"3d%e7%be%8e%e6%9c%af%e5%ae%9e%e6%97%b6%e6%b8%b2%e6%9f%93%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b57%ef%bc%9a%e6%9d%90%e8%b4%a8%e4%b8%8eshader","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=2706","title":{"rendered":"3D\u7f8e\u672f\u5b9e\u65f6\u6e32\u67d3\u6700\u4f73\u5b9e\u8df5(7)\uff1a\u6750\u8d28\u4e0eShader"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">7.1 Shader\u548c\u6750\u8d28\u7b80\u4ecb &#8211; (\u7565)<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">7.2 \u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\u4f7f\u7528\u4f18\u5316\u7684Shader<\/h2>\n\n\n\n<p>Unity\u63d0\u4f9b\u4e86\u4e00\u7ec4Mobile\u7684Shader\uff0c\u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\u5c3d\u91cf\u4f7f\u7528\u5b83\u4eec<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7.3 \u4f18\u5316\u7eb9\u7406<\/h2>\n\n\n\n<p>\u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\u5c3d\u53ef\u80fd\u5c11\u7528\u7eb9\u7406\uff0c\u7eb9\u7406\u91c7\u6837\u4f1a\u5bfc\u81f4\u66f4\u9ad8\u7684\u5e26\u5bbd\u66f4\u5927\u7684\u529f\u8017\uff0c\u5f71\u54cd\u8bbe\u5907\u7684\u7535\u6c60\u5bff\u547d\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u8003\u8651\u5c06\u591a\u4e2a\u7eb9\u7406\u6253\u5305\u5230\u4e00\u5f20\u7eb9\u7406\u4e2d\uff0c\u800c\u4e0d\u662f\u5c06\u4e00\u4e2a\u7eb9\u7406\u7528\u4e8e\u7c97\u7cd9\u5ea6\uff0c\u4e00\u4e2a\u7eb9\u7406\u7528\u4e8e\u91d1\u5c5e\u5ea6\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"513\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-46.png\" alt=\"\" class=\"wp-image-2708\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-46.png 665w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-46-300x231.png 300w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-46-65x50.png 65w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><figcaption>\u7eb9\u7406\u6253\u5305\u793a\u4f8b<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">7.4 \u5bf9\u6bd4\u5149\u7167Shader\u548c\u65e0\u5149\u7167Shader<\/h2>\n\n\n\n<p>\u53ef\u4ee5\u9009\u62e9Lit \u548c Unlit\uff0c\u5f53\u7136Unlit\u7684\u6027\u80fd\u66f4\u597d\uff0c\u4e5f\u53ef\u4ee5\u628a\u9634\u5f71\u753b\u5728\u4e0a\u9762\uff0c\u6b64\u5904\u7565\u8fc7<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7.5  \u5c0f\u5fc3\u4f7f\u7528\u900f\u660e\u6750\u8d28  <\/h2>\n\n\n\n<p>\u5c3d\u53ef\u80fd\u4f7f\u7528\u4e0d\u900f\u660e\u6750\u8d28\uff0c\u5728\u79fb\u52a8\u5e73\u53f0\uff0c\u9664\u975e\u5fc5\u8981\uff0c\u4e0d\u8981\u4f7f\u7528\u900f\u660e\u6750\u8d28\u3002<\/p>\n\n\n\n<p>\u900f\u660e\u6750\u8d28\u603b\u662f\u6bd4\u4e0d\u900f\u660e\u6750\u8d28\u66f4\u6d88\u8017GPU\uff0c\u4f7f\u7528\u8bb8\u591a\u900f\u660e\u6750\u8d28\u4f1a\u5f71\u54cd\u6027\u80fd\uff0c\u5c24\u5176\u662f\u8bb8\u591a\u900f\u660e\u5bf9\u8c61\u53e0\u5728\u4e00\u8d77\u65f6\u3002\u5f53\u4e00\u4e2a\u50cf\u7d20\u5728\u5c4f\u5e55\u4e0a\u591a\u6b21\u91cd\u590d\u7ed8\u5236\uff0c\u79f0\u4e3aOverdraw\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u79fb\u52a8\u5e73\u53f0\uff0cOverdraw\u4e25\u91cd\u5f71\u54cd\u6027\u80fd\u3002\u6240\u4ee5\u6e38\u620f\u573a\u666f\u5185\u5c3d\u53ef\u80fd\u8ba9Overdraw\u4fdd\u6301\u6700\u5c0f\uff0c\u5728Unity\u4e2d\u53ef\u4ee5\u5728Scene\u4e2d\u6253\u5f00Overdraw\u7684\u89c2\u5bdf\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"401\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-47.png\" alt=\"\" class=\"wp-image-2712\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-47.png 708w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-47-300x170.png 300w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-47-70x40.png 70w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">7.7 \u5206\u6790\u548c\u5bf9\u6bd4\u900f\u660e\u6750\u8d28\u7684\u5b9e\u73b0\u65b9\u5f0f<\/h2>\n\n\n\n<p>\u67092\u79cd\u5b9e\u73b0\u900f\u660e\u6750\u8d28\u7684\u65b9\u6cd5\uff1aAlphaBlend\u548cAlphaTest<\/p>\n\n\n\n<p>\u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528ARM\u7684Streamline\u6765\u6536\u96c6\u6027\u80fd\u6570\u636e\uff1b<br><br>AlphaTest\u7684\u6750\u8d28\u8981\u4e48100%\u900f\u660e\u8981\u4e48100%\u4e0d\u900f\u660e\uff0c\u53ef\u4ee5\u8bbe\u5b9a\u9608\u503c\uff0c\u5728Unity\u4e2d\u79f0\u4e3aCutout\u3002<br>\u6ce8\uff1a\u5728Shader\u4e2dcg\u5bf9\u5e94\u7684\u6307\u4ee4\u4e3aclip(v);<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"690\" height=\"261\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-48.png\" alt=\"\" class=\"wp-image-2715\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-48.png 690w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-48-300x113.png 300w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-48-70x26.png 70w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><figcaption>AlphaBlend\u548cAlphaTest<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>AlphaTest<\/strong><\/h3>\n\n\n\n<p>\u5982\u679c\u60f3\u5728\u6e38\u620f\u4e2d\u4f7f\u7528AlphaTest\uff0c\u6709\u4ee5\u4e0b\u5efa\u8bae\uff1a<\/p>\n\n\n\n<p>1\u3001\u6700\u597d\u522b\u7528AlphaTest\uff0c\u9664\u975e\u5fc5\u9700<br>2\u3001AlphaTest\u610f\u5473\u7740\u8981\u4e48100%\u900f\u660e\uff0c\u8981\u4e48100%\u4e0d\u900f\u660e<br>3\u3001\u6ce8\u610f\uff1aAlphaTest\u4f1a\u7981\u7528\u4e86GPU\u7684\u4f18\u5316\u7279\u6027\uff0c\u6240\u4ee5\u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\u4ed4\u7ec6\u6d4b\u8bd5\u5b83\u7684\u6027\u80fd\uff0c\u5e76\u4e14\u548cAlphaBlend\u7684\u6027\u80fd\u505a\u5bf9\u6bd4<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>AlphaBlend<\/strong><\/h3>\n\n\n\n<p>\u5982\u679c\u60f3\u5728\u6e38\u620f\u4e2d\u4f7f\u7528AlphaBlend\uff0c\u6709\u4ee5\u4e0b\u5efa\u8bae\uff1a<\/p>\n\n\n\n<p>1\u3001\u79fb\u52a8\u5e73\u53f0\uff0cUnity\u5efa\u8baeAlphaBlend\u66ff\u4ee3AlphaTest\uff08\u8001\u5218\uff1a\u8fd9\u4e2a\u7ed3\u8bba\u53ef\u80fd\u662f\u9519\u7684\uff09\uff0c\u5b9e\u9645\u4e0a\uff0c\u8fd8\u5f97\u5206\u6790\u548c\u5bf9\u6bd4\u4e24\u8005\u7684\u6027\u80fd\u5dee\u5f02\uff0c\u56e0\u4e3a\u5b83\u548c\u6e32\u67d3\u7684\u5185\u5bb9\u76f8\u5173<br>2\u3001\u79fb\u52a8\u5e73\u53f0\u5c3d\u91cf\u4e0d\u8981\u7528AlphaBlend<br>3\u3001\u5982\u679c\u4e00\u5b9a\u8981\u7528Alpha\uff0c\u8ba9\u5b83\u7684\u6e32\u67d3\u9762\u79ef\u5c3d\u53ef\u80fd\u5c0f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5728\u6811\u53f6\u4e0a\u4f7f\u7528AlphaTest<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"389\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-49.png\" alt=\"\" class=\"wp-image-2724\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-49.png 680w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-49-300x172.png 300w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2020\/09\/image-49-70x40.png 70w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure>\n\n\n\n<p>\u5728\u9759\u6001\u4e0b\uff0c\u4e0a\u56fe\u6ca1\u5565\u95ee\u9898\uff0c\u4f46\u662f\u5728\u8fd0\u52a8\u65f6\uff0c\u4f7f\u7528AlphaBlend\u770b\u8d77\u6765\u662f\u9519\u7684\uff0c\u6811\u53f6\u7684 \u6e32\u67d3\u6b21\u5e8f\u662f\u9519\u7684\u3002\u800cAlphaTest\u53ef\u4ee5\u6b63\u786e\u7684\u5904\u7406\u6b21\u5e8f\uff0c\u4e0d\u8fc7\u4e0eAlphaBlend\u76f8\u6bd4\uff0c\u5b83\u7684\u8fb9\u7f18\u7c97\u7cd9\uff0c\u6709\u952f\u9f7f\u3002\u4e00\u822c\u6765\u8bf4AlphaTest\u8868\u73b0\u4e0a\u8fd8\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\uff0c\u53ea\u8981\u952f\u9f7f\u7684\u8fb9\u7f18\u5728\u8fd0\u52a8\u4e2d\u4e0d\u90a3\u4e48\u660e\u663e\uff0c\u4f46\u662f\u5f53\u53f6\u5b50\u548c\u6811\u679d\u56e0\u4e3aAlphaBlend\u800c\u524d\u540e\u8df3\u52a8\u65f6\uff0c\u8fd9\u79cd\u8868\u73b0\u5c31\u4e0d\u884c\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7.7 \u66f4\u591a\u597d\u7684\u6750\u8d28\u548cShader\u5b9e\u8df5<\/h2>\n\n\n\n<p>1\u3001\u4f7f\u7528\u7b80\u5355Shader<br>2\u3001\u7528Unity\u7cfb\u7edf\u81ea\u5e26\u7684\u7c92\u5b50\u7cfb\u7edf<br>3\u3001\u51cf\u5c11Overdraw\uff0c\u51cf\u5c11\u7c92\u5b50\u6570\u91cf<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5206\u6790Shader\u590d\u6742\u6027<\/strong><\/h3>\n\n\n\n<p>\u6570\u91cf\u591a\u7684\u7eb9\u7406\u91c7\u6837\u548cAlphaBend\u53ca\u5176\u5b83\u529f\u80fd\u4f1a\u8ba9Shader\u66f4\u52a0\u590d\u6742\uff0c\u5f71\u54cd\u6e32\u67d3\u6027\u80fd\u3002\u5efa\u8bae\u7ecf\u5e38\u5256\u6790Shader\u3002<\/p>\n\n\n\n<p>ARM\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5de5\u5177\uff0c\u50cfMail Offline Shader Compiler \u548c Steamline\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u4e86\u89e3\u66f4\u591aGPU\u7684\u5de5\u4f5c\u5185\u5e55\uff0c\u5f53\u524d\u4e5f\u9700\u8981\u66f4\u9ad8\u7ea7\u7684\u56fe\u5f62\u5b66\u77e5\u8bc6\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5c06PS\u5185\u5bb9\u524d\u7f6e\u5230VS\u4e2d<\/strong><\/h3>\n\n\n\n<p>\u56e0\u4e3a\u901a\u5e38\u50cf\u7d20\u6bd4\u9876\u70b9\u8981\u591a\uff0c\u6216\u8005\u8bf4PS\u6bd4VS\u8fd0\u884c\u66f4\u9891\u7e41\uff0c\u5c06PS\u5185\u5bb9\u524d\u7f6e\u5230VS\u4e2d\uff1b<br>\u4f7f\u7528Varyings\u53d8\u91cf\uff08\u5373PS\u8f93\u51fa\u5e76\u63d2\u503c\u540e\u7684\u6570\u636e\uff09\uff0c<\/p>\n\n\n\n<p>\u4f46\u662f\u5f97\u6ce8\u610ftiler\u9632\u6b62\u5b83\u6210\u4e3a\u74f6\u9888\uff08Tiler?)\uff0c\u5b8c\u6210\u540e\u8fd8\u5f97\u8fdb\u4e00\u6b65\u5206\u6790\u6027\u80fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u907f\u514d\u4f7f\u7528\u590d\u6742\u7684\u51fd\u6570<\/strong><\/h3>\n\n\n\n<p>\u50cfsin, pow, cos, divide, noise \u51fd\u6570\u6027\u80fd\u8f83\u5dee\uff0c\u63a8\u8350\u57fa\u672c\u64cd\u4f5c\u50cf\u52a0\u6cd5\uff0c\u4e58\u6cd5\uff0c\u901f\u5ea6\u8f83\u5feb\uff1b\u5728\u8001\u7684\u50cfOpenGL2\u7684\u8bbe\u5907\u4e0a\uff0c\u5c3d\u91cf\u5c11\u7528\u590d\u6742\u7684\u51fd\u6570<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7ecf\u5e38\u5256\u6790\u6027\u80fd(\u7565\uff09<\/strong><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>7.1 Shader\u548c\u6750\u8d28\u7b80\u4ecb &#8211; (\u7565) 7.2 \u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\u4f7f\u7528\u4f18\u5316\u7684Shader Unity [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2706"}],"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=2706"}],"version-history":[{"count":16,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2706\/revisions"}],"predecessor-version":[{"id":2732,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2706\/revisions\/2732"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}