{"id":291699,"date":"2019-07-05T14:37:07","date_gmt":"2019-07-05T14:37:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291699"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291699","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0442\u0440\u0430\u0432\u044b \u0432 \u0434\u0432\u0438\u0436\u043a\u0435 Unity"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/dangerousimmensecanadagoose\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0432\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u0435\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0448\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b.<\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0442\u0440\u0430\u0432\u044b \u0432 Unity. \u0428\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0435\u0448, \u0438 \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043c\u0435\u0448\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3d11\/geometry-shader-stage\">\u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/a> \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443. \u0420\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043c\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c <strong>\u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b<\/strong> \u0438 <strong>\u043f\u043e\u0432\u043e\u0440\u043e\u0442<\/strong>, \u0430 \u0435\u0449\u0451 \u043d\u0430 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c <strong>\u0432\u0435\u0442\u0435\u0440<\/strong>. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3d11\/direct3d-11-advanced-stages-tessellation\">\u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e<\/a> \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0448\u0430. \u0422\u0440\u0430\u0432\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438 <strong>\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c<\/strong>, \u0438 <strong>\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c<\/strong> \u0442\u0435\u043d\u0438.<\/p>\n<p>  <strong>\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/strong> \u0432\u044b\u043b\u043e\u0436\u0435\u043d \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0449\u0438\u0445 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0434\u0432\u0438\u0436\u043a\u0435 Unity \u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432.<\/p>\n<p>  <a href=\"https:\/\/github.com\/IronWarrior\/UnityGrassGeometryShader\/archive\/skeleton.zip\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (.zip)<\/a>.<\/p>\n<h2>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0440\u0430\u0431\u043e\u0442\u0435<\/h2>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0435\u0433\u043e \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 Unity. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0441\u0446\u0435\u043d\u0443 <code>Main<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0432 \u0441\u0432\u043e\u0451\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u0434\u0430 \u0448\u0435\u0439\u0434\u0435\u0440 <code>Grass<\/code>.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0448\u0435\u0439\u0434\u0435\u0440, \u0432\u044b\u0434\u0430\u044e\u0449\u0438\u0439 \u0431\u0435\u043b\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435. \u0412\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u0431\u043b\u043e\u043a <code>CGINCLUDE<\/code>, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 <em>\u0441\u043d\u0430\u0440\u0443\u0436\u0438<\/em> <code>SubShader<\/code>. \u041a\u043e\u0434, \u0440\u0430\u0437\u043c\u0435\u0449\u0451\u043d\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u043c \u0431\u043b\u043e\u043a\u0435, \u0431\u0443\u0434\u0435\u0442 <strong>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0451\u043d \u0432\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044b<\/strong> \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435; \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432.<\/p>\n<p>  \u041c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f <strong>\u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/strong>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0448\u0430.<\/p>\n<h2>1. \u0413\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b<\/h2>\n<p>  \u0413\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u2014 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430. \u041e\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f <strong>\u043f\u043e\u0441\u043b\u0435<\/strong> \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 (\u0438\u043b\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044f) \u0438 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ef7\/c01\/458\/ef7c01458cadf7cd0cf46695d7114f96.jpg\"><\/div>\n<p>  <i>\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 Direct3D 11. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u043c (pixel shader)<\/em>.<\/i><\/p>\n<p>  \u0413\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 <a href=\"https:\/\/www.khronos.org\/opengl\/wiki\/Primitive\">\u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432<\/a> \u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u043b\u044c, \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432. \u041c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 <strong>\u0432\u0435\u0440\u0448\u0438\u043d\u0443<\/strong> (\u0438\u043b\u0438 <em>\u0442\u043e\u0447\u043a\u0443<\/em>), \u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u044e\u0449\u0438\u0439 <strong>\u043e\u0434\u0438\u043d \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a<\/strong>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443.<\/p>\n<pre><code class=\"cpp\">\/\/ Add inside the CGINCLUDE block. struct geometryOutput { \tfloat4 pos : SV_POSITION; };  [maxvertexcount(3)] void geo(triangle float4 IN[3] : SV_POSITION, inout TriangleStream&lt;geometryOutput&gt; triStream) { }  \u2026  \/\/ Add inside the SubShader Pass, just below the #pragma fragment frag line. #pragma geometry geo<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>geo<\/code> \u0441 \u0434\u0432\u0443\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438. \u041f\u0435\u0440\u0432\u044b\u0439, <code>triangle float4 IN[3]<\/code>, \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0432\u043e\u0434\u0430 \u043e\u0434\u0438\u043d \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a (\u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0442\u0440\u0451\u0445 \u0442\u043e\u0447\u0435\u043a). \u0412\u0442\u043e\u0440\u043e\u0439, \u0442\u0438\u043f\u0430 <code>TriangleStream<\/code>, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>geometryOutput<\/code>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u044b\u0448\u0435 \u043c\u044b \u0441\u043a\u0430\u0437\u0430\u043b\u0438, \u0447\u0442\u043e \u0448\u0435\u0439\u0434\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443. \u041f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u043c\u044b \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a?<\/b><\/p>\n<div class=\"spoiler_text\">\u041c\u0435\u043d\u0435\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0432\u043e\u0434\u0430 <code>\u0442\u043e\u0447\u043a\u0443<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"cpp\">void geo(point vertexOutput IN[1], inout TriangleStream&lt;geometryOutput&gt; triStream)<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0435\u0448 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code>GrassPlane10x10<\/code>, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 <code>Mesh<\/code>) \u0438\u043c\u0435\u0435\u0442 <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/MeshTopology.Triangles.html\">\u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044e \u043c\u0435\u0448\u0430 \u0438\u0437 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432<\/a>, \u044d\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0435\u0439 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0448\u0430 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u043c \u0432\u0432\u043e\u0434\u0430. \u0425\u043e\u0442\u044c \u044d\u0442\u043e \u0438 <strong>\u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f<\/strong> \u0432 DirectX HLSL, \u043d\u043e \u043d\u0435 <a href=\"https:\/\/www.khronos.org\/opengl\/wiki\/Geometry_Shader#Primitive_in.2Fout_specification\">\u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 OpenGL<\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430.<\/div>\n<\/div>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043d\u0430\u0434 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <code>[maxvertexcount(3)]<\/code>. \u041e\u043d \u0433\u043e\u0432\u043e\u0440\u0438\u0442 GPU, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c (\u043d\u043e \u043d\u0435 <strong>\u043e\u0431\u044f\u0437\u0430\u043d\u044b<\/strong> \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c) <em>\u043d\u0435 \u0431\u043e\u043b\u0435\u0435<\/em> 3 \u0432\u0435\u0440\u0448\u0438\u043d. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b <code>SubShader<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u043e\u0431\u044a\u044f\u0432\u0438\u0432 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 <code>Pass<\/code>.<\/p>\n<p>  \u041d\u0430\u0448 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442; \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u043d\u0443\u0442\u0440\u044c \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"cpp\">geometryOutput o;  o.pos = float4(0.5, 0, 0, 1); triStream.Append(o);  o.pos = float4(-0.5, 0, 0, 1); triStream.Append(o);  o.pos = float4(0, 1, 0, 1); triStream.Append(o);<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0db\/534\/ac1\/0db534ac10c125955829fd53b9923cd7.gif\"><\/div>\n<p>  \u042d\u0442\u043e \u0434\u0430\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u043a\u0430\u043c\u0435\u0440\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u0432 <strong>\u044d\u043a\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435<\/strong>. \u042d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d, \u043e\u043d \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432 <strong>\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0443\u0441\u0435\u0447\u0435\u043d\u0438\u044f<\/strong>. \u041c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e.<\/p>\n<pre><code class=\"cpp\">\/\/ Update the return call in the vertex shader. \/\/return UnityObjectToClipPos(vertex); return vertex;  \u2026  \/\/ Update each assignment of o.pos in the geometry shader. o.pos = UnityObjectToClipPos(float4(0.5, 0, 0, 1));  \u2026  o.pos = UnityObjectToClipPos(float4(-0.5, 0, 0, 1));  \u2026  o.pos = UnityObjectToClipPos(float4(0, 1, 0, 1));<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/221\/912\/b3e\/221912b3e6bc0581126a0f415b6e79c5.png\"><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u0432 \u043c\u0438\u0440\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0445\u043e\u0436\u0435, \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0443 <em>\u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f<\/em> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0448\u0430, \u043d\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430, <strong>\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b<\/strong> \u2014 \u043e\u043d\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>  \u041c\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e, \u0441\u0434\u0435\u043b\u0430\u0432 \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d <strong>\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f\u043c\u0438<\/strong> \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the top of the geometry shader. float3 pos = IN[0];  \u2026  \/\/ Update each assignment of o.pos. o.pos = UnityObjectToClipPos(pos + float3(0.5, 0, 0));  \u2026  o.pos = UnityObjectToClipPos(pos + float3(-0.5, 0, 0));  \u2026  o.pos = UnityObjectToClipPos(pos + float3(0, 1, 0));<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6b2\/ac4\/84c\/6b2ac484c5a033b18e88400e10191779.png\"><\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430?<\/b><\/p>\n<div class=\"spoiler_text\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cab\/447\/d9c\/cab447d9c4c82d8208a28e7cee2f7807.png\"><\/div>\n<p>  \u0425\u043e\u0442\u044c \u043c\u044b \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 \u0431\u0443\u0434\u0435\u0442 <strong>\u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u043c<\/strong>, \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 <strong>\u043e\u0434\u043d\u043e\u0439<\/strong> \u0438\u0437 \u0442\u043e\u0447\u0435\u043a \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430, \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0432\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0442\u0440\u0451\u0445 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0442\u043e\u0447\u0435\u043a, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043f\u043e\u0432\u0435\u0440\u0445 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<p>  \u0418\u043b\u0438 \u0436\u0435 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u0432\u0437\u044f\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043c\u0435\u0448\u0435\u0439 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043c\u0435\u0448\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u0442\u0438\u043f \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0438 <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/MeshTopology.Points.html\">Points<\/a>.<\/div>\n<\/div>\n<p>  \u0422\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e \u0432 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0435\u0439 \u0438\u0445 \u0432\u0435\u0440\u0448\u0438\u043d\u0435. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>GrassPlane<\/code> <strong>\u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c<\/strong> \u0432 \u0441\u0446\u0435\u043d\u0435, \u0430 \u043e\u0431\u044a\u0435\u043a\u0442 <code>GrassBall<\/code> \u0441\u0434\u0435\u043b\u0430\u0435\u043c <strong>\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c<\/strong>. \u041c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0430\u0432\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043d\u0430 \u043c\u0435\u0448\u0430\u0445 \u0440\u0430\u0437\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/19b\/f67\/8fb\/19bf678fbb6ce3c03956dbdf068004f0.png\"><\/div>\n<p>  \u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u0430 \u043d\u0435 \u043d\u0430\u0440\u0443\u0436\u0443 \u043e\u0442 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0441\u0444\u0435\u0440\u044b. \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432 <strong>\u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435<\/strong>.<\/p>\n<h2>2. \u041a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e<\/h2>\n<p>  \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043c\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043d\u0443\u044e \u0448\u0438\u0440\u0438\u043d\u0443, \u0432\u044b\u0441\u043e\u0442\u0443, \u043a\u0440\u0438\u0432\u0438\u0437\u043d\u0443 \u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0443\u0433\u043e\u043b \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0430. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043c\u044b \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, <strong>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043a \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0435\u0439 \u0435\u0451 \u0432\u0435\u0440\u0448\u0438\u043d\u0435<\/strong>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0435\u0451 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 <strong>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043a \u043c\u0435\u0448\u0443<\/strong>. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tangent_space\">\u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c<\/a>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/3fd\/8f7\/c39\/3fd8f7c394bf4eb18cb988aceafe342b.png\"><\/div>\n<p>  <i>\u0412 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043e\u0441\u0438 <strong>X<\/strong>, <strong>Y<\/strong> \u0438 <strong>Z<\/strong> \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b).<\/i><\/p>\n<p>  \u041a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0442\u0440\u0435\u043c\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438: <strong>right<\/strong>, <strong>forward<\/strong> \u0438 <strong>up<\/strong>. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u0438\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0438\u0437 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c <strong>right<\/strong> \u0438 <strong>up<\/strong>, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u043e\u0432\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the CGINCLUDE block. struct vertexInput { \tfloat4 vertex : POSITION; \tfloat3 normal : NORMAL; \tfloat4 tangent : TANGENT; };  struct vertexOutput { \tfloat4 vertex : SV_POSITION; \tfloat3 normal : NORMAL; \tfloat4 tangent : TANGENT; };  \u2026  \/\/ Modify the vertex shader. vertexOutput vert(vertexInput v) { \tvertexOutput o; \to.vertex = v.vertex; \to.normal = v.normal; \to.tangent = v.tangent; \treturn o; }  \u2026  \/\/ Modify the input for the geometry shader. Note that the SV_POSITION semantic is removed. void geo(triangle vertexOutput IN[3], inout TriangleStream&lt;geometryOutput&gt; triStream)  \u2026  \/\/ Modify the existing line declaring pos. float3 pos = IN[0].vertex;<\/code><\/pre>\n<p>  \u0422\u0440\u0435\u0442\u0438\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c, \u0432\u0437\u044f\u0432 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cross_product\">\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a> \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0434\u0440\u0443\u0433\u0438\u043c\u0438. \u0412\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440, <strong>\u043f\u0435\u0440\u043f\u0435\u043d\u0434\u0438\u043a\u0443\u043b\u044f\u0440\u043d\u044b\u0439<\/strong> \u043a \u0434\u0432\u0443\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c.<\/p>\n<pre><code class=\"cpp\">\/\/ Place in the geometry shader, below the line declaring float3 pos.\t\t float3 vNormal = IN[0].normal; float4 vTangent = IN[0].tangent; float3 vBinormal = cross(vNormal, vTangent) * vTangent.w;<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 w?<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0440\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435 \u043c\u0435\u0448\u0430 \u0438\u0437 3D-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u043e\u043d \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0431\u0438\u043d\u043e\u0440\u043c\u0430\u043b\u0438 (\u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 <em>\u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a \u0434\u0432\u0443\u043c \u0442\u043e\u0447\u043a\u0430\u043c<\/em>), \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0448\u0430. \u0412\u043c\u0435\u0441\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u044d\u0442\u0438\u0445 \u0431\u0438\u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439 Unity \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0438\u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0435 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 <strong>w<\/strong>. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u043d\u043e\u0440\u043c\u0430\u043b\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/forum.unity.com\/threads\/what-is-tangent-w-how-to-know-whether-its-1-or-1-tangent-w-vs-unity_worldtransformparams-w.468395\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/div>\n<\/div>\n<p>  \u0418\u043c\u0435\u044f \u0432\u0441\u0435 \u0442\u0440\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u043c\u0438. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043d\u0430 \u044d\u0442\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0432 <code>UnityObjectToClipPos<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the lines declaring the three vectors. float3x3 tangentToLocal = float3x3( \tvTangent.x, vBinormal.x, vNormal.x, \tvTangent.y, vBinormal.y, vNormal.y, \tvTangent.z, vBinormal.z, vNormal.z \t);<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u043c \u043a\u043e\u0434 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Don%27t_repeat_yourself\">\u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c DRY<\/a>, \u0438\u043b\u0438 <strong>don&#8217;t repeat yourself (\u00ab\u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0439\u0441\u044f\u00bb)<\/strong>.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the CGINCLUDE block. geometryOutput VertexOutput(float3 pos) { \tgeometryOutput o; \to.pos = UnityObjectToClipPos(pos); \treturn o; }  \u2026  \/\/ Remove the following from the geometry shader. \/\/geometryOutput o;  \/\/o.pos = UnityObjectToClipPos(pos + float3(0.5, 0, 0)); \/\/triStream.Append(o);  \/\/o.pos = UnityObjectToClipPos(pos + float3(-0.5, 0, 0)); \/\/triStream.Append(o);  \/\/o.pos = UnityObjectToClipPos(pos + float3(0, 1, 0)); \/\/triStream.Append(o);  \/\/ ...and replace it with the code below. triStream.Append(VertexOutput(pos + float3(0.5, 0, 0))); triStream.Append(VertexOutput(pos + float3(-0.5, 0, 0))); triStream.Append(VertexOutput(pos + float3(0, 1, 0)));<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0438\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <code>tangentToLocal<\/code>, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0432 \u0438\u0445 \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u044e \u0438\u0445 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"cpp\">triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(0.5, 0, 0)))); triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(-0.5, 0, 0)))); triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(0, 1, 0))));<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c95\/3f8\/286\/c953f828675a9d4e202c0c9349d37f9d.png\" alt=\"image\"><\/div>\n<p>  \u042d\u0442\u043e \u0443\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0432\u0435\u0440\u043d\u043e. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043b\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u00abup\u00bb (\u0432\u0432\u0435\u0440\u0445) \u043e\u0441\u0438 <strong>Y<\/strong>; \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u00ab\u0432\u0432\u0435\u0440\u0445\u00bb \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 <strong>Z<\/strong>. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0432\u043d\u0435\u0441\u0451\u043c \u044d\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cpp\">\/\/ Modify the position of the third vertex being emitted. triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(0, 0, 1))));<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0cf\/f51\/ddb\/0cff51ddbea12280cb78a1db9ada1786.png\"><\/div>\n<p>  <\/p>\n<h2>3. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0442\u0440\u0430\u0432\u044b<\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0434\u0438\u043b\u0438 \u043d\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0446\u0432\u0435\u0442\u043e\u0432 \u0438 \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u0447\u043d\u0451\u043c \u043c\u044b \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f <strong>\u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430<\/strong>, \u0438\u0434\u0443\u0449\u0435\u0433\u043e \u0441 \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0438 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432\u043d\u0438\u0437.<\/p>\n<h3>3.1 \u0426\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442<\/h3>\n<p>  \u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0445\u0443\u0434\u043e\u0436\u043d\u0438\u043a\u0443 \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0446\u0432\u0435\u0442\u0430 \u2014 \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0438 \u0438 \u043d\u0438\u0437\u0430, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u043e\u043d \u043a\u043e\u043d\u0447\u0438\u043a\u0430 \u0434\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438. \u042d\u0442\u0438 \u0446\u0432\u0435\u0442\u0430 \u0443\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043a\u0430\u043a <code>_TopColor<\/code> \u0438 <code>_BottomColor<\/code>. \u0414\u043b\u044f \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443 <strong>UV-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b<\/strong>.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the geometryOutput struct. float2 uv : TEXCOORD0;  \u2026  \/\/ Modify the VertexOutput function signature. geometryOutput VertexOutput(float3 pos, float2 uv)  \u2026  \/\/ Add to VertexOutput, just below the line assigning o.pos. o.uv = uv;  \u2026  \/\/ Modify the existing lines in the geometry shader. triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(0.5, 0, 0)), float2(0, 0))); triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(-0.5, 0, 0)), float2(1, 0))); triStream.Append(VertexOutput(pos + mul(tangentToLocal, float3(0, 0, 1)), float2(0.5, 1)));<\/code><\/pre>\n<p>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 UV-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432 \u0444\u043e\u0440\u043c\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430, \u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u0432\u043d\u0438\u0437\u0443, \u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043a\u043e\u043d\u0447\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0430 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u0432\u0432\u0435\u0440\u0445\u0443.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/165\/e39\/932\/165e399323aaa07e7c4cee728c0c9988.png\"><\/div>\n<p>  <i>UV-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0440\u0451\u0445 \u0432\u0435\u0440\u0448\u0438\u043d \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a. \u0425\u043e\u0442\u044f \u043c\u044b \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043e\u043c, \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0438 \u043d\u0438\u0436\u043d\u0438\u0439 \u0446\u0432\u0435\u0442\u0430 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 UV, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>lerp<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430, \u0441\u0434\u0435\u043b\u0430\u0432 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 <code>geometryOutput<\/code>, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044e <code>float4<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ Modify the function signature of the fragment shader. float4 frag (geometryOutput i, fixed facing : VFACE) : SV_Target  \u2026  \/\/ Replace the existing return call. return float4(1, 1, 1, 1);  return lerp(_BottomColor, _TopColor, i.uv.y);<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/596\/510\/51f\/59651051f474907a88740e83bc9d4532.png\"><\/div>\n<p>  <\/p>\n<h3>3.2 \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0438\u0434\u0430\u0442\u044c \u0442\u0440\u0430\u0432\u0435 \u0431\u043e\u043b\u0435\u0435 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u0438\u0434, \u043c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430, \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0449\u0443\u044e \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0432\u043e\u043a\u0440\u0443\u0433 \u0435\u0451 \u043e\u0441\u0438 <strong>up<\/strong>.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c: <code>rand<\/code>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438\u0437 \u0442\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430, \u0438 <code>AngleAxis3x3<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0443\u0433\u043e\u043b (\u0432 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Radian\">\u0440\u0430\u0434\u0438\u0430\u043d\u0430\u0445<\/a>) \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043d\u0430 \u044d\u0442\u0443 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0432\u043e\u043a\u0440\u0443\u0433 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043e\u0441\u0438. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f C# <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/Quaternion.AngleAxis.html\">Quaternion.AngleAxis<\/a> (\u0442\u043e\u043b\u044c\u043a\u043e <code>AngleAxis3x3<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0430 \u043d\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d).<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>rand<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 0&#8230;1; \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0438\u043c \u0435\u0433\u043e \u043d\u0430 <strong>2 Pi<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0443\u0433\u043b\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring the tangentToLocal matrix. float3x3 facingRotationMatrix = AngleAxis3x3(rand(pos) * UNITY_TWO_PI, float3(0, 0, 1));<\/code><\/pre>\n<p>  \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e <code>pos<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 seed \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435.<\/p>\n<p>  \u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0435, \u0443\u043c\u043d\u043e\u0436\u0438\u0432 \u0435\u0433\u043e \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <code>tangentToLocal<\/code>. \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 <strong>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f<\/strong> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Commutative_property\">\u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u043c<\/a>; \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u043e\u0432 <strong>\u0432\u0430\u0436\u0435\u043d<\/strong>.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring facingRotationMatrix. float3x3 transformationMatrix = mul(tangentToLocal, facingRotationMatrix);  \u2026  \/\/ Replace the multiplication matrix operand with our new transformationMatrix. triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(0.5, 0, 0)), float2(0, 0))); triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(-0.5, 0, 0)), float2(1, 0))); triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(0, 0, 1)), float2(0.5, 1)));<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/09f\/c2f\/e80\/09fc2fe8028b51f78989954e65812cd3.png\"><\/div>\n<p>  <\/p>\n<h3>3.3 \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0438\u0437\u0433\u0438\u0431 forward<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u043e\u0432\u043d\u043e, \u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u044f \u0443\u0445\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0442\u0440\u0430\u0432\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u0438\u0433\u0430\u0435\u043c\u043e\u0439 \u043b\u0443\u0436\u0430\u0439\u043a\u0435, \u043d\u043e \u0432 \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0442\u0440\u0430\u0432\u0430 \u0442\u0430\u043a \u043d\u0435 \u0440\u0430\u0441\u0442\u0451\u0442. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0442\u0440\u0430\u0432\u044b \u043f\u043e \u043e\u0441\u0438 <strong>X<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u043c \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u043c.<\/p>\n<pre><code class=\"cpp\">\/\/ Add as a new property. _BendRotationRandom(\"Bend Rotation Random\", Range(0, 1)) = 0.2  \u2026  \/\/ Add to the CGINCLUDE block. float _BendRotationRandom;  \u2026  \/\/ Add to the geometry shader, below the line declaring facingRotationMatrix. float3x3 bendRotationMatrix = AngleAxis3x3(rand(pos.zzx) * _BendRotationRandom * UNITY_PI * 0.5, float3(-1, 0, 0));<\/code><\/pre>\n<p>  \u0421\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e seed \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0435\u0451 <a href=\"https:\/\/www.khronos.org\/opengl\/wiki\/Data_Type_(GLSL)#Swizzling\">\u0441\u0432\u0438\u0437\u043b\u0438\u043d\u0433<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e seed. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0438\u043c <code>UNITY_PI<\/code> \u043d\u0430 <strong>0.5<\/strong>; \u044d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b 0&#8230;90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432.<\/p>\n<p>  \u041c\u044b \u043e\u043f\u044f\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u044d\u0442\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u0443\u043c\u043d\u043e\u0436\u0430\u044f \u0432\u0441\u0451 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<pre><code class=\"cpp\">\/\/ Modify the existing line. float3x3 transformationMatrix = mul(mul(tangentToLocal, facingRotationMatrix), bendRotationMatrix);<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/49c\/122\/534\/49c122534d7298c0f9c646501a708daa.gif\"><\/div>\n<p>  <\/p>\n<h3>3.4 \u0428\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430<\/h3>\n<p>  \u041f\u043e\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0448\u0438\u0440\u0438\u043d\u043e\u0439 \u0432 1 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u043e\u0439 \u0432 1 \u0435\u0434\u0438\u043d\u0438\u0446\u0443. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"cpp\">\/\/ Add as new properties. _BladeWidth(\"Blade Width\", Float) = 0.05 _BladeWidthRandom(\"Blade Width Random\", Float) = 0.02 _BladeHeight(\"Blade Height\", Float) = 0.5 _BladeHeightRandom(\"Blade Height Random\", Float) = 0.3  \u2026  \/\/ Add to the CGINCLUDE block. float _BladeHeight; float _BladeHeightRandom;\t float _BladeWidth; float _BladeWidthRandom;  \u2026  \/\/ Add to the geometry shader, above the triStream.Append calls. float height = (rand(pos.zyx) * 2 - 1) * _BladeHeightRandom + _BladeHeight; float width = (rand(pos.xzy) * 2 - 1) * _BladeWidthRandom + _BladeWidth;  \u2026  \/\/ Modify the existing positions with our new height and width. triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(width, 0, 0)), float2(0, 0))); triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(-width, 0, 0)), float2(1, 0))); triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(0, 0, height)), float2(0.5, 1)));<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/35b\/22e\/f34\/35b22ef34945a576100a152a0e25eec5.png\"><\/div>\n<p>  \u0422\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438, \u043d\u043e \u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e. \u0412\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u043c \u043c\u0435\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u0440\u0448\u0438\u043d, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435 \u0433\u0443\u0441\u0442\u043e \u0437\u0430\u0440\u043e\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u044f.<\/p>\n<p>  \u041e\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e, \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u043e\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0448\u0430 \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e C#, \u0438\u043b\u0438 \u0432 3D-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435. \u042d\u0442\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0435\u0448 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <strong>\u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u0438<\/strong>.<\/p>\n<h2>4. \u0422\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044f<\/h2>\n<p>  <strong>\u0422\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044f<\/strong> \u2014 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438 \u0434\u043e \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 (\u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c). \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432. \u0422\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u044d\u0442\u0430\u043f\u0430\u043c\u0438: <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3d11\/direct3d-11-advanced-stages-tessellation#hull-shader-stage\">\u043e\u0431\u043e\u043b\u043e\u0447\u0435\u0447\u043d\u044b\u043c (hull)<\/a> \u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3d11\/direct3d-11-advanced-stages-tessellation#domain-shader-stage\">domain<\/a>-\u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u044b\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0432 Unity \u0435\u0441\u0442\u044c <a href=\"https:\/\/docs.unity3d.com\/Manual\/SL-SurfaceShaderTessellation.html\">\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u0438<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b <strong>\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<\/strong> \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u043e\u043b\u043e\u0447\u0435\u0447\u043d\u044b\u0439 \u0438 domain-\u0448\u0435\u0439\u0434\u0435\u0440\u044b. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u0438, \u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u043c <code>CustomTessellation.cginc<\/code>. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0438\u0437 <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/advanced-rendering\/tessellation\/\">\u0441\u0442\u0430\u0442\u044c\u0438 Catlike Coding<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u0438 \u0432 Unity.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>TessellationExample<\/code> \u0432 \u0441\u0446\u0435\u043d\u0443, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <strong>Tessellation Uniform<\/strong> \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2d8\/8a7\/f01\/2d88a7f01e3a7462ffd0c8f20953b5ca.gif\"><\/div>\n<p>  \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0442\u0440\u0430\u0432\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b <code>CustomTessellation.cginc<\/code>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e \u043f\u043e \u0435\u0433\u043e <em>\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443<\/em> \u043f\u0443\u0442\u0438 \u043a \u0448\u0435\u0439\u0434\u0435\u0440\u0443.<\/p>\n<pre><code class=\"cpp\">\/\/ Add inside the CGINCLUDE block, below the other #include statements. #include \"Shaders\/CustomTessellation.cginc\"<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0435 <code>CustomTessellation.cginc<\/code>, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0432 \u043d\u0451\u043c \u0443\u0436\u0435 \u0437\u0430\u0434\u0430\u043d\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>vertexInput<\/code> \u0438 <code>vertexOutput<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0435\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0442\u0440\u0430\u0432\u044b; \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<pre><code class=\"cpp\">\/*struct vertexInput { \tfloat4 vertex : POSITION; \tfloat3 normal : NORMAL; \tfloat4 tangent : TANGENT; };  struct vertexOutput { \tfloat4 vertex : SV_POSITION; \tfloat3 normal : NORMAL; \tfloat4 tangent : TANGENT; };  vertexOutput vert(vertexInput v) { \tvertexOutput o; \to.vertex = v.vertex; \to.normal = v.normal; \to.tangent = v.tangent; \treturn o; }*\/<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 <code>vert<\/code> \u0432 <code>CustomTessellation.cginc<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0430 \u044d\u0442\u0430\u043f \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u0438; \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>vertexOutput<\/code> \u0431\u0435\u0440\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>tessVert<\/code>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0438 domain-\u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <strong>\u043e\u0431\u043e\u043b\u043e\u0447\u0435\u0447\u043d\u044b\u0439<\/strong> \u0438 <strong>domain<\/strong>-\u0448\u0435\u0439\u0434\u0435\u0440\u044b \u0432 \u0448\u0435\u0439\u0434\u0435\u0440 \u0442\u0440\u0430\u0432\u044b. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>_TessellationUniform<\/code> \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u2014 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u044d\u0442\u043e\u043c\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0443\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u0432 <code>CustomTessellation.cginc<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ Add as a new property.\t\t\t _TessellationUniform(\"Tessellation Uniform\", Range(1, 64)) = 1  \u2026  \/\/ Add below the other #pragma statements in the SubShader Pass. #pragma hull hull #pragma domain domain<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <strong>Tessellation Uniform<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b. \u042f \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <strong>5<\/strong>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/280\/d93\/c14\/280d93c1420a9744bd56f2d2496f96ab.gif\"><\/div>\n<p>  <\/p>\n<h2>5. \u0412\u0435\u0442\u0435\u0440<\/h2>\n<p>  \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0435\u0442\u0435\u0440 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c <strong>\u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f<\/strong>. \u042d\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Normal_mapping\">\u043a\u0430\u0440\u0442\u0443 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439<\/a>, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0435\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0451\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430. \u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0435\u0442\u0440\u0430 \u043f\u043e <strong>X<\/strong> \u0438 <strong>Y<\/strong>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a58\/aaa\/687\/a58aaa68742934ff1bddf1cbaf9564f5.png\"><\/div>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432\u0435\u0442\u0440\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c UV-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443. \u0412\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440, \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0448\u0443, \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432 \u043c\u0438\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0448\u0435\u0439 \u0441 \u0442\u0440\u0430\u0432\u043e\u0439, \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u0441\u044f \u0438\u043b\u043b\u044e\u0437\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0432\u0441\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u0435\u0442\u0440\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/docs.unity3d.com\/Manual\/SL-UnityShaderVariables.html\">\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/a> <code>_Time<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432\u0435\u0442\u0440\u0430 \u0432\u0434\u043e\u043b\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0430\u0432\u044b.<\/p>\n<pre><code class=\"cpp\">\/\/ Add as new properties. _WindDistortionMap(\"Wind Distortion Map\", 2D) = \"white\" {} _WindFrequency(\"Wind Frequency\", Vector) = (0.05, 0.05, 0, 0)  \u2026  \/\/ Add to the CGINCLUDE block. sampler2D _WindDistortionMap; float4 _WindDistortionMap_ST;  float2 _WindFrequency;  \u2026  \/\/ Add to the geometry shader, just above the line declaring the transformationMatrix. float2 uv = pos.xz * _WindDistortionMap_ST.xy + _WindDistortionMap_ST.zw + _WindFrequency * _Time.y;<\/code><\/pre>\n<p>  \u041c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043a \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <code>_WindDistortionMap<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0451 \u043d\u0430 <code>_Time.y<\/code>, \u043e\u0442\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 <code>_WindFrequency<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 UV \u0434\u043b\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u043b\u043e\u0439 \u0432\u0435\u0442\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">\/\/ Add as a new property. _WindStrength(\"Wind Strength\", Float) = 1  \u2026  \/\/ Add to the CGINCLUDE block. float _WindStrength;  \u2026  \/\/ Add below the line declaring float2 uv. float2 windSample = (tex2Dlod(_WindDistortionMap, float4(uv, 0, 0)).xy * 2 - 1) * _WindStrength;<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 0&#8230;1 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b -1&#8230;1. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0442\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring float2 windSample. float3 wind = normalize(float3(windSample.x, windSample.y, 0));<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0435\u0451 \u043d\u0430 \u043d\u0430\u0448\u0443 <code>transformationMatrix<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring float3 wind. float3x3 windRotation = AngleAxis3x3(UNITY_PI * windSample, wind);  \u2026  \/\/ Modify the existing line. float3x3 transformationMatrix = mul(mul(mul(tangentToLocal, windRotation), facingRotationMatrix), bendRotationMatrix);<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u043c \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 Unity \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 <code>Wind<\/code> (\u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0443\u044e\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430) \u0432 \u043f\u043e\u043b\u0435 <strong>Wind Distortion Map<\/strong> \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u0442\u0440\u0430\u0432\u044b. \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <strong>Tiling<\/strong> \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>0.01, 0.01<\/code>.<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/closedangryiridescentshark\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u0440\u0430\u0432\u0430 \u043d\u0435 \u0430\u043d\u0438\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u043a\u043d\u0435 <strong>Scene<\/strong>, \u0442\u043e \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <strong>Toggle skybox, fog, and various other effects<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b.<\/p>\n<p>  \u0418\u0437\u0434\u0430\u043b\u0435\u043a\u0430 \u0442\u0440\u0430\u0432\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432\u0431\u043b\u0438\u0437\u0438, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0430, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043e \u043a \u0437\u0435\u043c\u043b\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6e9\/148\/51e\/6e914851e888c448c30080a7abefae33.png\"><\/div>\n<p>  <i>\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043e \u043a \u0437\u0435\u043c\u043b\u0435, \u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u043d\u0435\u0439 (\u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e <strong>\u043a\u0440\u0430\u0441\u043d\u044b\u043c<\/strong>), \u0438 \u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u0434 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c\u044e \u0437\u0435\u043c\u043b\u0438 (\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0439 <strong>\u0437\u0435\u043b\u0451\u043d\u043e\u0439<\/strong> \u043b\u0438\u043d\u0438\u0435\u0439).<\/i><\/p>\n<p>  \u041c\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e, \u0437\u0430\u0434\u0430\u0432 \u0432\u0442\u043e\u0440\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0434\u0432\u0443\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u044d\u0442\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <strong>\u043d\u0435 \u0431\u0443\u0434\u0443\u0442<\/strong> \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043c\u0430\u0442\u0440\u0438\u0446\u044b <code>windRotation<\/code> \u0438 <code>bendRotationMatrix<\/code>, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043e \u043a \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring float3x3 transformationMatrix. float3x3 transformationMatrixFacing = mul(tangentToLocal, facingRotationMatrix);  \u2026  \/\/ Modify the existing lines outputting the base vertex positions. triStream.Append(VertexOutput(pos + mul(transformationMatrixFacing, float3(width, 0, 0)), float2(0, 0))); triStream.Append(VertexOutput(pos + mul(transformationMatrixFacing, float3(-width, 0, 0)), float2(1, 0)));<\/code><\/pre>\n<p>  <\/p>\n<h2>6. \u041a\u0440\u0438\u0432\u0438\u0437\u043d\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a<\/h2>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u043c. \u041d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u0445 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043d\u043e \u0432\u0431\u043b\u0438\u0437\u0438 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0447\u0435\u043d\u044c \u0436\u0451\u0441\u0442\u043a\u0438\u043c\u0438 \u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u043c\u0438, \u0430 \u043d\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438 \u0436\u0438\u0432\u044b\u043c\u0438. \u041c\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0438 \u0441\u043e\u0433\u043d\u0443\u0432 \u0438\u0445 \u0432\u0434\u043e\u043b\u044c <strong>\u043a\u0440\u0438\u0432\u043e\u0439<\/strong>.<\/p>\n<p>  \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <strong>\u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432<\/strong>. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u2014 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u0438\u043c \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u043c, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0447\u0438\u043a \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438.<\/p>\n<p>  \u041f\u043e\u043a\u0430 \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a. \u041a\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0435\u0440\u0448\u0438\u043d \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0443\u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438? \u041e\u0442\u0432\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Triangle_strip\">triangle strip<\/a>. \u041f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/871\/8ec\/676\/8718ec676d7efd819718bd25d5b27b54.gif\"><\/div>\n<p>  <i>\u041f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u0430\u044f \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u0432\u0438\u0434\u0435 triangle strip \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0437\u0430 \u0440\u0430\u0437. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u044b\u0445 \u0442\u0440\u0451\u0445 \u0432\u0435\u0440\u0448\u0438\u043d \u043a\u0430\u0436\u0434\u0430\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438.<\/i><\/p>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0441 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u0442\u043e \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0434\u043b\u044f <code>TriangleStream<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3dhlsl\/dx-graphics-hlsl-so-restartstrip\">RestartStrip<\/a>.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0437 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0440\u0448\u0438\u043d, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c <code>maxvertexcount<\/code>. \u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>#define<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0432\u0435\u0440\u0448\u0438\u043d.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the CGINCLUDE block. #define BLADE_SEGMENTS 3  \u2026  \/\/ Modify the existing line defining the maxvertexcount. [maxvertexcount(BLADE_SEGMENTS * 2 + 1)]<\/code><\/pre>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u044b\u043c <strong>3<\/strong> \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c <code>maxvertexcount<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0446\u0438\u043a\u043b <code>for<\/code>. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0438\u043a\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e <strong>\u0434\u0432\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b<\/strong>: <strong>\u043b\u0435\u0432\u0443\u044e<\/strong> \u0438 <strong>\u043f\u0440\u0430\u0432\u0443\u044e<\/strong>. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u043d\u0430 \u043a\u043e\u043d\u0447\u0438\u043a\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u043a\u043e\u0434\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0446\u0438\u043a\u043b\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0431\u043b\u043e\u043a <code>CGINCLUDE<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">geometryOutput GenerateGrassVertex(float3 vertexPosition, float width, float height, float2 uv, float3x3 transformMatrix) { \tfloat3 tangentPoint = float3(width, 0, height);  \tfloat3 localPosition = vertexPosition + mul(transformMatrix, tangentPoint); \treturn VertexOutput(localPosition, uv); }<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0442\u0435 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u043d\u0435\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 <code>VertexOutput<\/code> \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u0432\u044b\u0441\u043e\u0442\u0443 \u0438 \u0448\u0438\u0440\u0438\u043d\u0443, \u043e\u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0435\u0439 UV-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443. \u041c\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"cpp\">\/\/ Update the existing code outputting the vertices. triStream.Append(GenerateGrassVertex(pos, width, 0, float2(0, 0), transformationMatrixFacing)); triStream.Append(GenerateGrassVertex(pos, -width, 0, float2(1, 0), transformationMatrixFacing)); triStream.Append(GenerateGrassVertex(pos, 0, height, float2(0.5, 1), transformationMatrix));<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0438 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0446\u0438\u043a\u043b <code>for<\/code>. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 <code>float width<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">for (int i = 0; i &lt; BLADE_SEGMENTS; i++) { \tfloat t = i \/ (float)BLADE_SEGMENTS; }<\/code><\/pre>\n<p>  \u041c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u043e \u0440\u0430\u0437\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438. \u0412\u043d\u0443\u0442\u0440\u0438 \u0446\u0438\u043a\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>t<\/code>. \u042d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 0&#8230;1, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043c\u044b \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u043b\u0438\u0441\u044c \u043f\u043e \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0448\u0438\u0440\u0438\u043d\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring float t. float segmentHeight = height * t; float segmentWidth = width * (1 - t);<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u0432\u0432\u0435\u0440\u0445 \u043f\u043e \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0435 \u0432\u044b\u0441\u043e\u0442\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0430 \u0448\u0438\u0440\u0438\u043d\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442\u0441\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0446\u0438\u043a\u043b \u0432\u044b\u0437\u043e\u0432\u044b <code>GenerateGrassVertex<\/code>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043f\u043e\u0442\u043e\u043a \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432 <code>GenerateGrassVertex<\/code> \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u043a\u043e\u043d\u0447\u0438\u043a\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the line declaring float segmentWidth. float3x3 transformMatrix = i == 0 ? transformationMatrixFacing : transformationMatrix;  triStream.Append(GenerateGrassVertex(pos, segmentWidth, segmentHeight, float2(0, t), transformMatrix)); triStream.Append(GenerateGrassVertex(pos, -segmentWidth, segmentHeight, float2(1, t), transformMatrix));  \u2026  \/\/ Add just below the loop to insert the vertex at the tip of the blade. triStream.Append(GenerateGrassVertex(pos, 0, height, float2(0.5, 1), transformationMatrix));  \u2026  \/\/ Remove the existing calls to triStream.Append. \/\/triStream.Append(GenerateGrassVertex(pos, width, 0, float2(0, 0), transformationMatrixFacing)); \/\/triStream.Append(GenerateGrassVertex(pos, -width, 0, float2(1, 0), transformationMatrixFacing)); \/\/triStream.Append(GenerateGrassVertex(pos, 0, height, float2(0.5, 1), transformationMatrix));<\/code><\/pre>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>float3x3 transformMatrix<\/code> \u2014 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f: \u0431\u0435\u0440\u0451\u043c <code>transformationMatrixFacing<\/code> \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0438 <code>transformationMatrix<\/code> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/02b\/211\/61c\/02b21161cd4afc0cca35ae71ffe2570e.png\"><\/div>\n<p>  \u0422\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u043b\u043e\u0441\u043a\u0430\u044f \u2014 \u043d\u043e\u0432\u044b\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0435 \u043a\u0440\u0438\u0432\u0438\u0437\u043d\u044b, \u0441\u043c\u0435\u0441\u0442\u0438\u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432\u0435\u0440\u0448\u0438\u043d \u043f\u043e <strong>Y<\/strong>. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>GenerateGrassVertex<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e <strong>Y<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043d\u0430\u0437\u043e\u0432\u0451\u043c <code>forward<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ Update the function signature of GenerateGrassVertex. geometryOutput GenerateGrassVertex(float3 vertexPosition, float width, float height, float forward, float2 uv, float3x3 transformMatrix)  \u2026  \/\/ Modify the Y coordinate assignment of tangentPoint. float3 tangentPoint = float3(width, forward, height);<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043c\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>pow<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>t<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f <code>t<\/code> \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0435\u0451 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 forward \u0431\u0443\u0434\u0435\u0442 <em>\u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c<\/em> \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443 \u0432 \u043a\u0440\u0438\u0432\u0443\u044e.<\/p>\n<pre><code class=\"cpp\">\/\/ Add as new properties. _BladeForward(\"Blade Forward Amount\", Float) = 0.38 _BladeCurve(\"Blade Curvature Amount\", Range(1, 4)) = 2  \u2026  \/\/ Add to the CGINCLUDE block. float _BladeForward; float _BladeCurve;  \u2026  \/\/ Add inside the geometry shader, below the line declaring float width. float forward = rand(pos.yyz) * _BladeForward;  \u2026  \/\/ Add inside the loop, below the line declaring segmentWidth. float segmentForward = pow(t, _BladeCurve) * forward;  \u2026  \/\/ Modify the GenerateGrassVertex calls inside the loop. triStream.Append(GenerateGrassVertex(pos, segmentWidth, segmentHeight, segmentForward, float2(0, t), transformMatrix)); triStream.Append(GenerateGrassVertex(pos, -segmentWidth, segmentHeight, segmentForward, float2(1, t), transformMatrix));  \u2026  \/\/ Modify the GenerateGrassVertex calls outside the loop. triStream.Append(GenerateGrassVertex(pos, 0, height, forward, float2(0.5, 1), transformationMatrix));<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u043d\u043e \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0448\u0438\u0440\u0438\u043d\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438. \u041f\u0440\u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 <code>_BladeForward<\/code> \u0438 <code>_BladeCurve<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0443\u044e, \u0443\u0445\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u043b\u0443\u0436\u0430\u0439\u043a\u0443, \u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u0434\u0443\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c1f\/cbc\/e43\/c1fcbce43fa5e1c1be319dc1f5190f3d.png\"><\/div>\n<p>  <\/p>\n<h2>7. \u041e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u043d\u0438<\/h2>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u0442\u0430\u043f\u0430 \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c<\/strong> \u0438 <strong>\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c<\/strong> \u0442\u0435\u043d\u0438. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0435 \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u0435\u0442\u0430.<\/p>\n<h3>7.1 \u041e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043d\u0435\u0439<\/h3>\n<p>  \u0414\u043b\u044f \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043d\u0435\u0439 \u0432 Unity \u0432 \u0448\u0435\u0439\u0434\u0435\u0440 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0445\u043e\u0434. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u043d\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0441\u0446\u0435\u043d\u0435 \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0442\u0440\u0430\u0432\u044b \u0432 \u0438\u0445 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Shadow_mapping\">\u043a\u0430\u0440\u0442\u0443 \u0442\u0435\u043d\u0435\u0439<\/a>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u0432 \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0442\u0435\u043d\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043c\u043e\u0433\u043b\u0438 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043d\u0438.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 <code>CGINCLUDE<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u044b\u0445 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u0445 \u0444\u0430\u0439\u043b\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435 \u0436\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b, \u043a\u0430\u043a \u0438 \u043f\u0435\u0440\u0432\u044b\u0439, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u2014 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u043e\u0432\u044b\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"cpp\">\/\/ Add below the existing Pass. Pass { \tTags \t{ \t\t\"LightMode\" = \"ShadowCaster\" \t}  \tCGPROGRAM \t#pragma vertex vert \t#pragma geometry geo \t#pragma fragment frag \t#pragma hull hull \t#pragma domain domain \t#pragma target 4.6 \t#pragma multi_compile_shadowcaster  \tfloat4 frag(geometryOutput i) : SV_Target \t{ \t\tSHADOW_CASTER_FRAGMENT(i) \t}  \tENDCG }<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430, \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043f\u0430\u0440\u0430 \u0432\u0430\u0436\u043d\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439. \u041c\u0435\u0442\u043a\u0430 <code>LightMode<\/code> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>ShadowCaster<\/code>, \u0430 \u043d\u0435 <code>ForwardBase<\/code> \u2014 \u044d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 Unity, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043a\u0430\u0440\u0442\u044b \u0442\u0435\u043d\u0435\u0439. \u0422\u0430\u043a\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 <code>multi_compile_shadowcaster<\/code>. \u041e\u043d\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043d\u0435\u0439.<\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Fence<\/code> <strong>\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c<\/strong> \u0432 \u0441\u0446\u0435\u043d\u0435; \u0442\u0430\u043a \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0441\u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043d\u044c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c57\/640\/6cf\/c576406cf284fe41e4b04d8af264d96e.png\"><\/div>\n<p>  <\/p>\n<h3>7.2 \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043d\u0435\u0439<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Unity \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u043a\u0430\u0440\u0442\u0443 \u0442\u0435\u043d\u0435\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0442\u0435\u043d\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0441\u0432\u0435\u0442\u0430, \u043e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434, \u00ab\u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0449\u0438\u0439\u00bb \u0442\u0435\u043d\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 <strong>\u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/strong>. \u0414\u043b\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the geometryOutput struct. unityShadowCoord4 _ShadowCoord : TEXCOORD1;  \u2026  \/\/ Add to the VertexOutput function, just above the return call.\t o._ShadowCoord = ComputeScreenPos(o.pos);<\/code><\/pre>\n<p>  \u0412\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 <code>ForwardBase<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>float<\/code>, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0433\u043e, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u0435\u043d\u044f\u0445, \u0438\u043b\u0438 \u043d\u0435\u0442. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 0&#8230;1, \u0433\u0434\u0435 0 \u2014 \u043f\u043e\u043b\u043d\u043e\u0435 \u0437\u0430\u0442\u0435\u043d\u0435\u043d\u0438\u0435, 1 \u2014 \u043f\u043e\u043b\u043d\u0430\u044f \u043e\u0441\u0432\u0435\u0449\u0451\u043d\u043d\u043e\u0441\u0442\u044c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 UV-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f _ShadowCoord? \u042d\u0442\u043e \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\u041c\u043d\u043e\u0433\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b Unity \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 (\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u0436\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u0445 \u0441\u0430\u043c\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440). \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0438 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c\u0443 \u043d\u0438\u0436\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0443 <code>SHADOW_ATTENUATION<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0438\u0437 <code>Autolight.cginc<\/code>, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0435\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">#define SHADOW_ATTENUATION(a) unitySampleShadow(a._ShadowCoord)<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0431\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0438\u043c\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438\u043b\u0438 \u044d\u0442\u043e \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0430\u043c \u0431\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"cpp\">\/\/ Add to the ForwardBase pass's fragment shader, replacing the existing return call. return SHADOW_ATTENUATION(i);  \/\/return lerp(_BottomColor, _TopColor, i.uv.y);<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0448\u0435\u0439\u0434\u0435\u0440 \u0431\u044b\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043d\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043f\u0440\u043e\u0445\u043e\u0434\u0443 <code>ForwardBase<\/code> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the ForwardBase pass's preprocessor directives, below #pragma target 4.6. #pragma multi_compile_fwdbase<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/90a\/491\/468\/90a491468a1ad129d35bea03b0b51898.png\"><\/div>\n<p>  \u041f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0432 \u043a\u0430\u043c\u0435\u0440\u0443, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b; \u043e\u043d\u0438 \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442 \u0442\u0435\u043d\u0438 \u0441\u0430\u043c\u0438 \u043d\u0430 \u0441\u0435\u0431\u044f. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 <em>\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0441\u0434\u0432\u0438\u0433<\/em> \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0443\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0433\u043a\u0430 \u0432\u0434\u0430\u043b\u044c \u043e\u0442 \u044d\u043a\u0440\u0430\u043d\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043a\u0440\u043e\u0441 Unity \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>#if<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0442\u0435\u043d\u0435\u0439.<\/p>\n<pre><code class=\"cpp\">\/\/ Add at the end of the VertexOutput function, just above the return call. #if UNITY_PASS_SHADOWCASTER \t\/\/ Applying the bias prevents artifacts from appearing on the surface. \to.pos = UnityApplyLinearShadowBias(o.pos); #endif<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dca\/ec0\/d88\/dcaec0d88eea1893b6a07eb45724a0b6.gif\"><\/div>\n<p>  <i>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430 \u0442\u0435\u043d\u0435\u0439 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u0442\u0435\u043d\u0435\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u043b\u043e\u0441 \u0438\u0441\u0447\u0435\u0437\u0430\u044e\u0442 \u0441 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432.<\/i><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u0434\u043e\u043b\u044c \u043a\u0440\u0430\u0451\u0432 \u0437\u0430\u0442\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u0435\u0441\u0442\u044c \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b?<\/b><\/p>\n<div class=\"spoiler_text\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/08a\/12e\/af1\/08a12eaf1af17fc9b35de7d07a64afca.png\"><\/div>\n<p>  \u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u043c\u043d\u043e\u0433\u043e\u0441\u044d\u043c\u043f\u043b\u043e\u0432\u043e\u043c \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0438 (multisample anti-aliasing <strong>MSAA<\/strong>) Unity <em>\u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442<\/em> \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043a \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435 \u0433\u043b\u0443\u0431\u0438\u043d \u0441\u0446\u0435\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u044b \u0442\u0435\u043d\u0435\u0439 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u0441\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0441\u0446\u0435\u043d\u0430 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0441\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0442\u0435\u043d\u0435\u0439, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b.<\/p>\n<p>  \u041e\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0432 <a href=\"https:\/\/github.com\/Unity-Technologies\/PostProcessing\">\u043f\u0430\u043a\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Unity<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e); \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f <a href=\"https:\/\/forum.unity.com\/threads\/fixing-screen-space-directional-shadows-and-anti-aliasing.379902\/\">\u0432 \u044d\u0442\u043e\u043c \u0442\u0440\u0435\u0434\u0435 \u0444\u043e\u0440\u0443\u043c\u043e\u0432 Unity<\/a>.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>7.3 \u041e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0435\u044f\u043d\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/404\/3ae\/452\/4043ae452046c0b4b405aa88afe8d2b7.gif\"><\/div>\n<p>  \u2026 \u0433\u0434\u0435 <strong>N<\/strong> \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u044c \u043a \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438, <strong>L<\/strong> \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f, \u0430 <strong>I<\/strong> \u2014 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435. \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b <strong>\u043d\u0435 \u0431\u0443\u0434\u0435\u043c<\/strong> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0440\u0430\u0436\u0451\u043d\u043d\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u043d\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0438. \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d, \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u0432 <strong>\u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435<\/strong>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0438\u0445 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 <strong>Blade Curvature Amount<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>1<\/strong>, \u0432\u0441\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443: \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e \u043e\u0441\u0438 <strong>Y<\/strong>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u0440\u0438\u0432\u0438\u0437\u043d\u044b.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the GenerateGrassVertex function, belowing the line declaring tangentPoint. float3 tangentNormal = float3(0, -1, 0); float3 localNormal = mul(transformMatrix, tangentNormal);<\/code><\/pre>\n<p>  <code>tangentNormal<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043a\u0430\u043a \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u0430\u044f \u043e\u0441\u0438 <strong>Y<\/strong>, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0439 \u0436\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0451 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>VertexOutput<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>geometryOutput<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ Modify the return call in GenerateGrassVertex. return VertexOutput(localPosition, uv, localNormal);  \u2026  \/\/ Add to the geometryOutput struct. float3 normal : NORMAL;  \u2026  \/\/ Modify the existing function signature. geometryOutput VertexOutput(float3 pos, float2 uv, float3 normal)  \u2026  \/\/ Add to the VertexOutput function to pass the normal through to the fragment shader. o.normal = UnityObjectToWorldNormal(normal);<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c \u0432 <strong>\u043c\u0438\u0440\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e<\/strong>; Unity \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u0435\u0442\u0430 \u0432 \u043c\u0438\u0440\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 <code>ForwardBase<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the ForwardBase fragment shader. float3 normal = facing &gt; 0 ? i.normal : -i.normal;  return float4(normal * 0.5 + 0.5, 1);  \/\/ Remove the existing return call. \/\/return SHADOW_ATTENUATION(i);<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 <code>Cull<\/code> \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Off<\/code>, \u0440\u0435\u043d\u0434\u0435\u0440\u044f\u0442\u0441\u044f \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438. \u0427\u0442\u043e\u0431\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u044c \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>VFACE<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.<\/p>\n<p>  \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>fixed facing<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <strong>\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435<\/strong> \u0447\u0438\u0441\u043b\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438, \u0438 <strong>\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435<\/strong> \u0447\u0438\u0441\u043b\u043e, \u0435\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e \u0432 \u043a\u043e\u0434\u0435 \u0432\u044b\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e1b\/8ca\/965\/e1b8ca965ed8e80b539a9773d1adeb0c.png\"><\/div>\n<p>  \u041a\u043e\u0433\u0434\u0430 <strong>Blade Curvature Amount<\/strong> \u0431\u043e\u043b\u044c\u0448\u0435 1, \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f <strong>Z<\/strong> \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0431\u0443\u0434\u0435\u0442 \u0441\u043c\u0435\u0449\u0435\u043d\u0430 \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 <code>forward<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>GenerateGrassVertex<\/code>. \u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u0438 <strong>Z<\/strong> \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439.<\/p>\n<pre><code class=\"cpp\">\/\/ Modify the existing line in GenerateGrassVertex. float3 tangentNormal = normalize(float3(0, -1, forward));<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0442\u0435\u043d\u0438, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432 \u043c\u043e\u0451\u043c <a href=\"https:\/\/roystan.net\/articles\/toon-shader.html\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043f\u043e toon-\u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c<\/a>.<\/p>\n<pre><code class=\"cpp\">\/\/ Add to the ForwardBase fragment shader, below the line declaring float3 normal. float shadow = SHADOW_ATTENUATION(i); float NdotL = saturate(saturate(dot(normal, _WorldSpaceLightPos0)) + _TranslucentGain) * shadow;  float3 ambient = ShadeSH9(float4(normal, 1)); float4 lightIntensity = NdotL * _LightColor0 + float4(ambient, 1); float4 col = lerp(_BottomColor, _TopColor * lightIntensity, i.uv.y);  return col;  \/\/ Remove the existing return call. \/\/return float4(normal * 0.5 + 0.5, 1);<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c14\/894\/d14\/c14894d14edc336b770f4b94bedd3708.png\"><\/div>\n<p>  <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u0442\u0440\u0430\u0432\u0430 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 10&#215;10 \u0435\u0434\u0438\u043d\u0438\u0446. \u0427\u0442\u043e\u0431\u044b \u0448\u0435\u0439\u0434\u0435\u0440 \u043c\u043e\u0433 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0432\u0434\u0430\u043b\u0438 \u043e\u0442 \u043a\u0430\u043c\u0435\u0440\u044b \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430 \u0434\u0430\u043b\u044c\u043d\u0438\u0445 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u0445 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u0441 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043e\u0439.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5a7\/a05\/e86\/5a7a05e8690c152f9196bb3c94fada19.png\"><\/div>\n<p>  <i>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0442\u0440\u0430\u0432\u044b, \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u0430\u044f \u0432 \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/assetstore.unity.com\/packages\/essentials\/asset-packs\/standard-assets-32351\">Standard Assets<\/a> \u0434\u0432\u0438\u0436\u043a\u0430 Unity. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0432 \u0441\u0446\u0435\u043d\u0435.<\/i><\/p>\n<p>  \u0425\u043e\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043c\u044b \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u0441 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u044b\u043c\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438, \u0434\u043b\u044f \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0442\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f Unity \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c <a href=\"https:\/\/github.com\/keijiro\/StandardGeometryShader\">\u044d\u0442\u043e\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 GitHub<\/a>, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0438 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f G-\u0431\u0443\u0444\u0435\u0440\u043e\u0432.<\/p>\n<p>  <a href=\"https:\/\/github.com\/IronWarrior\/UnityGrassGeometryShader\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitHub <\/a><\/p>\n<h3>\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435: \u0432\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/h3>\n<p>  \u0411\u0435\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0438\u0433\u0440\u043e\u043a\u0430\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u0431\u0435\u0437\u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c\u0438. \u042d\u0442\u043e\u0442 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0443\u0436\u0435 \u0438 \u0442\u0430\u043a \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0441\u0442\u0430\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u0438\u0440\u0430 \u0441 \u0442\u0440\u0430\u0432\u043e\u0439.<\/p>\n<p>  \u041d\u0430\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0442\u0440\u0430\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0431\u044b \u0434\u0432\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: \u043d\u0435\u0447\u0442\u043e \u0432 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u043c\u0438\u0440\u0435, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0435 <strong>\u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435<\/strong> \u0432 \u0448\u0435\u0439\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u0435\u043c\u0443, \u0441 \u043a\u0430\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0438 \u043a\u043e\u0434 \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0434\u043b\u044f <strong>\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/strong> \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u043e\u0434\u043e\u0439, \u043f\u043e\u043a\u0430\u0437\u0430\u043d <a href=\"https:\/\/www.patreon.com\/posts\/24192529\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0440\u0430\u0432\u043e\u0439; \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0440\u044f\u0431\u0438 \u0432 \u043c\u0435\u0441\u0442\u0435, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0432\u043d\u0438\u0437 \u0434\u043b\u044f \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u0438 \u0432\u043e\u0437\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0448\u0430\u0433\u043e\u0432.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/458060\/\"> https:\/\/habr.com\/ru\/post\/458060\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/dangerousimmensecanadagoose\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0432\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u0435\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u0432\u0438\u043d\u043e\u043a \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0448\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b.<\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0442\u0440\u0430\u0432\u044b \u0432 Unity. \u0428\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0435\u0448, \u0438 \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043c\u0435\u0448\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3d11\/geometry-shader-stage\">\u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/a> \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0443. \u0420\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043c\u0430 \u0442\u0440\u0430\u0432\u0438\u043d\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c <strong>\u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b<\/strong> \u0438 <strong>\u043f\u043e\u0432\u043e\u0440\u043e\u0442<\/strong>, \u0430 \u0435\u0449\u0451 \u043d\u0430 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c <strong>\u0432\u0435\u0442\u0435\u0440<\/strong>. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0432\u044b, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/direct3d11\/direct3d-11-advanced-stages-tessellation\">\u0442\u0435\u0441\u0441\u0435\u043b\u044f\u0446\u0438\u044e<\/a> \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0448\u0430. \u0422\u0440\u0430\u0432\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438 <strong>\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c<\/strong>, \u0438 <strong>\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c<\/strong> \u0442\u0435\u043d\u0438.<\/p>\n<p>  <strong>\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/strong> \u0432\u044b\u043b\u043e\u0436\u0435\u043d \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0449\u0438\u0445 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-291699","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291699"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291699\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}