{"id":475570,"date":"2026-04-12T05:18:28","date_gmt":"2026-04-12T05:18:28","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=475570"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=475570","title":{"rendered":"\u0418\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 Outline \u0432 Unity 6: \u041f\u0438\u0448\u0435\u043c \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u0439 URP Render Graph"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u043e Unity 6 (\u0438\u043b\u0438 URP 17+) \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0438 \u0441\u0442\u0430\u0440\u044b\u0435 \u043f\u043e\u0441\u0442-\u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u044e \u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445.<\/p>\n<p>\u0421\u0442\u0430\u0440\u044b\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 (Outline) \u0447\u0435\u0440\u0435\u0437 <code>ScriptableRendererFeature<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;. Unity \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u0432\u043d\u0435\u0434\u0440\u0438\u0432 <strong>Render Graph<\/strong>. \u0421\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>Execute<\/code> \u043a\u0430\u043d\u0443\u043b \u0432 \u041b\u0435\u0442\u0443, \u0430 <code>fullscreenMesh<\/code> \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u043d\u0430 <code>Blitter<\/code>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 Outline \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0438 Unity 6. \u041c\u044b \u0440\u0435\u0448\u0438\u043c <strong>\u0434\u0432\u0435 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/strong> \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u0443\u043c\u0430\u043b\u0447\u0438\u0432\u0430\u044e\u0442 \u0432 \u0433\u0430\u0439\u0434\u0430\u0445:<\/p>\n<ol>\n<li>\n<p><strong>\u0420\u0430\u0437\u043e\u0440\u0432\u0430\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b:<\/strong> \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u043e\u0441\u0442\u0440\u044b\u0445 \u043a\u0440\u0430\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043e\u0431\u0432\u043e\u0434\u043a\u0430 \u043d\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/strong> \u043a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0438 \u043d\u0430 Full HD \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0435, \u0438 \u043d\u0430 4K-\u044d\u043a\u0440\u0430\u043d\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4de\/da2\/23c\/4deda223c33cf37675b4be09be5ca5ca.gif\" alt=\"\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\" title=\"\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\" width=\"640\" height=\"337\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4de\/da2\/23c\/4deda223c33cf37675b4be09be5ca5ca.gif 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4de\/da2\/23c\/4deda223c33cf37675b4be09be5ca5ca.gif 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/figcaption><\/div>\n<\/figure>\n<h4>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/h4>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0434\u0432\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 (\u0431\u0435\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f, \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u0445\u0430\u0440\u0434-\u044d\u0434\u0436 \u043a\u043e\u043d\u0442\u0443\u0440):<\/p>\n<ol>\n<li>\n<p><strong>\u041c\u0430\u0441\u043a\u0430:<\/strong> \u0420\u0438\u0441\u0443\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043f\u043b\u043e\u0448\u043d\u044b\u043c \u0431\u0435\u043b\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u0432 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u043e\u043d\u0442\u0443\u0440:<\/strong> \u041f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0443 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443. \u0415\u0441\u043b\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0431\u0435\u043b\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0438 \u043f\u0443\u0441\u0442\u043e\u0442\u044b &#8212; \u0440\u0438\u0441\u0443\u0435\u043c \u0442\u0430\u043c \u0446\u0432\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u0432\u043e\u0434\u043a\u0443.<\/p>\n<\/li>\n<\/ol>\n<hr\/>\n<h4>\u0428\u0430\u0433 1. \u0428\u0435\u0439\u0434\u0435\u0440 \u0441\u0438\u043b\u0443\u044d\u0442\u0430 (\u041c\u0430\u0441\u043a\u0430)<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043b\u044c\u0435\u0442 \u043d\u0430\u0448\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043f\u043b\u043e\u0448\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u0432 \u043c\u0430\u0441\u043a\u0443. \u041d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f, \u0442\u0435\u043d\u0435\u0439 \u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0432\u0435\u0442.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>Silhouette.shader<\/strong>:<\/p>\n<p>High-level shader language<\/p>\n<pre><code class=\"cs\">Shader \"Hidden\/OutlineSilhouette\"{    SubShader    {        Tags { \"RenderType\"=\"Opaque\" \"RenderPipeline\"=\"UniversalPipeline\" }        Pass        {            ZWrite On            ZTest LEqual            Cull Back            HLSLPROGRAM            #pragma vertex Vert            #pragma fragment Frag            #include \"Packages\/com.unity.render-pipelines.universal\/ShaderLibrary\/Core.hlsl\"            struct Attributes {                float4 positionOS : POSITION;            };            struct Varyings {                float4 positionCS : SV_POSITION;            };            Varyings Vert(Attributes input) {                Varyings output;                output.positionCS = TransformObjectToHClip(input.positionOS.xyz);                return output;            }            half4 Frag(Varyings input) : SV_Target {                return half4(1, 1, 1, 1);            }            ENDHLSL        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h4>\u0428\u0430\u0433 2. \u0423\u043c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 (\u0420\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443\u0433\u043b\u043e\u0432 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f)<\/h4>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u0445 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0433\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 4 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u044f (\u0432\u0435\u0440\u0445, \u043d\u0438\u0437, \u043b\u0435\u0432\u043e, \u043f\u0440\u0430\u0432\u043e). \u042d\u0442\u043e \u0434\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 \u043f\u0440\u044f\u043c\u044b\u0445 \u043b\u0438\u043d\u0438\u044f\u0445, \u043d\u043e \u043d\u0430 \u043e\u0441\u0442\u0440\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0443\u0433\u043b\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0432\u043e\u0434\u043a\u0430 &#171;\u0440\u0432\u0435\u0442\u0441\u044f&#187;.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/243\/903\/8f4\/2439038f4f21eaea4ce9936c4c6231ae.png\" alt=\"\u0414\u043e\/\u041f\u043e\u0441\u043b\u0435\" title=\"\u0414\u043e\/\u041f\u043e\u0441\u043b\u0435\" width=\"612\" height=\"562\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/243\/903\/8f4\/2439038f4f21eaea4ce9936c4c6231ae.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/243\/903\/8f4\/2439038f4f21eaea4ce9936c4c6231ae.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0414\u043e\/\u041f\u043e\u0441\u043b\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u0445\u043d\u0438\u043a\u0443 <strong>Dilation (\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435)<\/strong>: \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c 8 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438) \u0438 &#171;\u0432\u044b\u0440\u0430\u0449\u0438\u0432\u0430\u0442\u044c&#187; \u043c\u0430\u0441\u043a\u0443 \u043d\u0430\u0440\u0443\u0436\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0447\u0442\u0435\u043c \u0438\u0437 \u043d\u0435\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043b\u0443\u044d\u0442.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041c\u044b \u043f\u0440\u0438\u0432\u044f\u0436\u0435\u043c \u0442\u043e\u043b\u0449\u0438\u043d\u0443 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 \u043a \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u043a\u0440\u0430\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 1080p), \u0447\u0442\u043e\u0431\u044b \u043d\u0430 4K-\u044d\u043a\u0440\u0430\u043d\u0430\u0445 \u043a\u043e\u043d\u0442\u0443\u0440 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0441\u044f \u0432 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0443\u044e \u043d\u0438\u0442\u043e\u0447\u043a\u0443.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>HardOutline.shader<\/strong>:<\/p>\n<p>High-level shader language<\/p>\n<pre><code class=\"cs\">Shader \"Custom\/HardOutline\"{    Properties    {        _OutlineColor (\"Outline Color\", Color) = (1, 0, 0, 1)        _Thickness (\"Outline Thickness\", Range(1, 10)) = 1.0    }    SubShader    {        Tags { \"RenderType\"=\"Opaque\" \"RenderPipeline\"=\"UniversalPipeline\" }        Pass        {            Blend SrcAlpha OneMinusSrcAlpha            ZWrite Off ZTest Always Cull Off            HLSLPROGRAM            #pragma vertex Vert             #pragma fragment Frag            #include \"Packages\/com.unity.render-pipelines.universal\/ShaderLibrary\/Core.hlsl\"            #include \"Packages\/com.unity.render-pipelines.core\/Runtime\/Utilities\/Blit.hlsl\"            TEXTURE2D_X(_OutlineRenderTexture);            SAMPLER(sampler_OutlineRenderTexture);            float4 _OutlineColor;            float _Thickness;            half4 Frag(Varyings input) : SV_Target {                float2 uv = input.texcoord;                half centerAlpha = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv).a;                float2 texelSize = float2(1.0 \/ _ScreenParams.x, 1.0 \/ _ScreenParams.y);                float referenceHeight = 1080.0;                float scaleFactor = _ScreenParams.y \/ referenceHeight;                float scaledThickness = _Thickness * scaleFactor;                float2 offset = texelSize * scaledThickness;                half up = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(0, offset.y)).a;                half down = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(0, -offset.y)).a;                half left = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(-offset.x, 0)).a;                half right = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(offset.x, 0)).a;                half topLeft = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(-offset.x, offset.y)).a;                half topRight = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(offset.x, offset.y)).a;                half bottomLeft = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(-offset.x, -offset.y)).a;                half bottomRight = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(offset.x, -offset.y)).a;                half maxNeighbors = max(max(up, down), max(left, right));                half maxDiagonals = max(max(topLeft, topRight), max(bottomLeft, bottomRight));                half dilated = max(centerAlpha, max(maxNeighbors, maxDiagonals));                half edge = saturate(dilated - centerAlpha);                return half4(_OutlineColor.rgb, edge * _OutlineColor.a);            }            ENDHLSL        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h4>\u0428\u0430\u0433 3. C# \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u043c\u0430\u0433\u0438\u044f Render Graph<\/h4>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435. \u0412 Unity 6 \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 (<code>RecordRenderGraph<\/code>), \u0430 \u0434\u0432\u0438\u0436\u043e\u043a \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <code>TextureDesc<\/code> (\u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0441\u0442\u0430\u0440\u044b\u0439 <code>GetTemporaryRT<\/code>) \u0438 <code>Blitter.BlitTexture<\/code> (\u043f\u0440\u0438\u0448\u0435\u043b \u043d\u0430 \u0441\u043c\u0435\u043d\u0443 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u0435\u0448\u0443).<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 <strong>OutlineFeature.cs<\/strong>:<\/p>\n<p>C#<\/p>\n<pre><code class=\"cs\">using System;using UnityEngine;using UnityEngine.Rendering;using UnityEngine.Rendering.Universal;using UnityEngine.Rendering.RenderGraphModule;using UnityEngine.Experimental.Rendering;public class OutlineFeature : ScriptableRendererFeature{    [Serializable]    public class OutlineSettings    {        public LayerMask LayerMask;        public Material SilhouetteMaterial;        public Material OutlineMaterial;    }    public OutlineSettings settings = new OutlineSettings();    class RenderSilhouettePass : ScriptableRenderPass    {        private Material silhouetteMaterial;        private FilteringSettings filteringSettings;        private static readonly int SilhouetteTextureID = Shader.PropertyToID(\"_OutlineRenderTexture\");        public RenderSilhouettePass(LayerMask layerMask, Material mat)        {            silhouetteMaterial = mat;            filteringSettings = new FilteringSettings(RenderQueueRange.opaque, layerMask);        }        private class PassData        {            public RendererListHandle rendererList;        }        public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)        {            if (silhouetteMaterial == null) return;            UniversalCameraData cameraData = frameData.Get&lt;UniversalCameraData&gt;();            UniversalRenderingData renderingData = frameData.Get&lt;UniversalRenderingData&gt;();            UniversalLightData lightData = frameData.Get&lt;UniversalLightData&gt;();            TextureDesc texDesc = new TextureDesc(cameraData.cameraTargetDescriptor.width, cameraData.cameraTargetDescriptor.height)            {                colorFormat = GraphicsFormat.R8G8B8A8_UNorm,                clearBuffer = true,                clearColor = Color.clear,                name = \"_OutlineRenderTexture\"            };            TextureHandle silhouetteTexture = renderGraph.CreateTexture(texDesc);            using (var builder = renderGraph.AddRasterRenderPass&lt;PassData&gt;(\"Render Silhouette\", out var passData))            {                var sortingCriteria = cameraData.defaultOpaqueSortFlags;                var drawingSettings = CreateDrawingSettings(new ShaderTagId(\"UniversalForward\"), renderingData, cameraData, lightData, sortingCriteria);                drawingSettings.overrideMaterial = silhouetteMaterial;                RendererListParams listParams = new RendererListParams(renderingData.cullResults, drawingSettings, filteringSettings);                passData.rendererList = renderGraph.CreateRendererList(listParams);                builder.UseRendererList(passData.rendererList);                builder.SetRenderAttachment(silhouetteTexture, 0, AccessFlags.Write);                builder.AllowPassCulling(false);                builder.SetGlobalTextureAfterPass(silhouetteTexture, SilhouetteTextureID);                builder.SetRenderFunc((PassData data, RasterGraphContext context) =&gt;                {                    context.cmd.DrawRendererList(data.rendererList);                });            }        }    }    class DrawOutlinePass : ScriptableRenderPass    {        private Material outlineMaterial;        public DrawOutlinePass(Material mat)        {            outlineMaterial = mat;            requiresIntermediateTexture = true;         }        private class PassData        {            public Material material;        }        public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)        {            if (outlineMaterial == null) return;            UniversalResourceData resourceData = frameData.Get&lt;UniversalResourceData&gt;();            TextureHandle activeColorTexture = resourceData.activeColorTexture;            using (var builder = renderGraph.AddRasterRenderPass&lt;PassData&gt;(\"Draw Outline\", out var passData))            {                passData.material = outlineMaterial;                builder.SetRenderAttachment(activeColorTexture, 0);                builder.AllowPassCulling(false);                builder.SetRenderFunc((PassData data, RasterGraphContext context) =&gt;                {                    Blitter.BlitTexture(context.cmd, new Vector2(1, 1), data.material, 0);                });            }        }    }    private RenderSilhouettePass silhouettePass;    private DrawOutlinePass outlinePass;    public override void Create()    {        silhouettePass = new RenderSilhouettePass(settings.LayerMask, settings.SilhouetteMaterial)        {            renderPassEvent = RenderPassEvent.AfterRenderingOpaques        };        outlinePass = new DrawOutlinePass(settings.OutlineMaterial)        {            renderPassEvent = RenderPassEvent.AfterRenderingSkybox        };    }    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)    {        if (settings.SilhouetteMaterial != null &amp;&amp; settings.OutlineMaterial != null)        {            renderer.EnqueuePass(silhouettePass);            renderer.EnqueuePass(outlinePass);        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432 Unity<\/h4>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0432\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430:<\/p>\n<ul>\n<li>\n<p><strong>Mat_Silhouette<\/strong> (\u0448\u0435\u0439\u0434\u0435\u0440: <code>Hidden\/OutlineSilhouette<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>Mat_HardOutline<\/strong> (\u0448\u0435\u0439\u0434\u0435\u0440: <code>Custom\/HardOutline<\/code>)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0432\u0430\u0448 \u0444\u0430\u0439\u043b <code>UniversalRendererData<\/code> (\u043b\u0435\u0436\u0438\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a URP).<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u0443 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>Add Renderer Feature<\/strong> \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>Outline Feature<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0444\u0438\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>\u0423\u043a\u0430\u0436\u0438\u0442\u0435 <strong>Layer Mask<\/strong> (\u0441\u043b\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0432\u043e\u0434\u0438\u0442\u044c). \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0436\u0435 \u0441\u043b\u043e\u0439 \u0432\u0430\u0448\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043d\u0430 \u0441\u0446\u0435\u043d\u0435!<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0432 \u0441\u043b\u043e\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043d\u0430 Main Camera \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0433\u0430\u043b\u043e\u0447\u043a\u0430 <strong>Post Processing<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/68d\/a7d\/4e1\/68da7d4e16225a60bd5a7439be66304a.png\" width=\"432\" height=\"189\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/68d\/a7d\/4e1\/68da7d4e16225a60bd5a7439be66304a.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/68d\/a7d\/4e1\/68da7d4e16225a60bd5a7439be66304a.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 \u0441 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0433\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<p><a href=\"https:\/\/github.com\/AlexeyNazariev\/Unity6-URP-RenderGraph-Outline\" rel=\"noopener noreferrer nofollow\"><strong>\u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u043c\u043e\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 GitHub<\/strong><\/a>\ud83d\udc49 <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0432\u0430\u043c \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u0434\u0435\u0431\u0430\u0433\u0433\u0438\u043d\u0433\u0430 \u0432 \u043d\u043e\u0432\u043e\u043c Unity 6. \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043a\u0430\u043a \u043f\u0440\u043e\u0448\u0435\u043b \u0432\u0430\u0448 \u043f\u0435\u0440\u0435\u0435\u0437\u0434 \u043d\u0430 Render Graph!<\/p>\n<\/div>\n<p>\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\/articles\/1022412\/\">https:\/\/habr.com\/ru\/articles\/1022412\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u043e Unity 6 (\u0438\u043b\u0438 URP 17+) \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0438 \u0441\u0442\u0430\u0440\u044b\u0435 \u043f\u043e\u0441\u0442-\u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u044e \u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445.\u0421\u0442\u0430\u0440\u044b\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 (Outline) \u0447\u0435\u0440\u0435\u0437 ScriptableRendererFeature \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;. Unity \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u0432\u043d\u0435\u0434\u0440\u0438\u0432 Render Graph. \u0421\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 Execute \u043a\u0430\u043d\u0443\u043b \u0432 \u041b\u0435\u0442\u0443, \u0430 fullscreenMesh \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u043d\u0430 Blitter.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 Outline \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0438 Unity 6. \u041c\u044b \u0440\u0435\u0448\u0438\u043c \u0434\u0432\u0435 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u0443\u043c\u0430\u043b\u0447\u0438\u0432\u0430\u044e\u0442 \u0432 \u0433\u0430\u0439\u0434\u0430\u0445:\u0420\u0430\u0437\u043e\u0440\u0432\u0430\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u043e\u0441\u0442\u0440\u044b\u0445 \u043a\u0440\u0430\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043e\u0431\u0432\u043e\u0434\u043a\u0430 \u043d\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c.\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f: \u043a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0438 \u043d\u0430 Full HD \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0435, \u0438 \u043d\u0430 4K-\u044d\u043a\u0440\u0430\u043d\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0434\u0432\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 (\u0431\u0435\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f, \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u0445\u0430\u0440\u0434-\u044d\u0434\u0436 \u043a\u043e\u043d\u0442\u0443\u0440):\u041c\u0430\u0441\u043a\u0430: \u0420\u0438\u0441\u0443\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043f\u043b\u043e\u0448\u043d\u044b\u043c \u0431\u0435\u043b\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u0432 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443.\u041a\u043e\u043d\u0442\u0443\u0440: \u041f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0443 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443. \u0415\u0441\u043b\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0431\u0435\u043b\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0438 \u043f\u0443\u0441\u0442\u043e\u0442\u044b &#8212; \u0440\u0438\u0441\u0443\u0435\u043c \u0442\u0430\u043c \u0446\u0432\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u0432\u043e\u0434\u043a\u0443.\u0428\u0430\u0433 1. \u0428\u0435\u0439\u0434\u0435\u0440 \u0441\u0438\u043b\u0443\u044d\u0442\u0430 (\u041c\u0430\u0441\u043a\u0430)\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043b\u044c\u0435\u0442 \u043d\u0430\u0448\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043f\u043b\u043e\u0448\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u0432 \u043c\u0430\u0441\u043a\u0443. \u041d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f, \u0442\u0435\u043d\u0435\u0439 \u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0432\u0435\u0442.\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b Silhouette.shader:High-level shader languageShader &#171;Hidden\/OutlineSilhouette&#187;{    SubShader    {        Tags { &#171;RenderType&#187;=&#187;Opaque&#187; &#171;RenderPipeline&#187;=&#187;UniversalPipeline&#187; }        Pass        {            ZWrite On            ZTest LEqual            Cull Back            HLSLPROGRAM            #pragma vertex Vert            #pragma fragment Frag            #include &#171;Packages\/com.unity.render-pipelines.universal\/ShaderLibrary\/Core.hlsl&#187;            struct Attributes {                float4 positionOS : POSITION;            };            struct Varyings {                float4 positionCS : SV_POSITION;            };            Varyings Vert(Attributes input) {                Varyings output;                output.positionCS = TransformObjectToHClip(input.positionOS.xyz);                return output;            }            half4 Frag(Varyings input) : SV_Target {                return half4(1, 1, 1, 1);            }            ENDHLSL        }    }}\u0428\u0430\u0433 2. \u0423\u043c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 (\u0420\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443\u0433\u043b\u043e\u0432 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f)\u041e\u0431\u044b\u0447\u043d\u043e \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u0445 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0433\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 4 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u044f (\u0432\u0435\u0440\u0445, \u043d\u0438\u0437, \u043b\u0435\u0432\u043e, \u043f\u0440\u0430\u0432\u043e). \u042d\u0442\u043e \u0434\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 \u043f\u0440\u044f\u043c\u044b\u0445 \u043b\u0438\u043d\u0438\u044f\u0445, \u043d\u043e \u043d\u0430 \u043e\u0441\u0442\u0440\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0443\u0433\u043b\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0432\u043e\u0434\u043a\u0430 &#171;\u0440\u0432\u0435\u0442\u0441\u044f&#187;.\u0414\u043e\/\u041f\u043e\u0441\u043b\u0435\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u0445\u043d\u0438\u043a\u0443 Dilation (\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435): \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c 8 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438) \u0438 &#171;\u0432\u044b\u0440\u0430\u0449\u0438\u0432\u0430\u0442\u044c&#187; \u043c\u0430\u0441\u043a\u0443 \u043d\u0430\u0440\u0443\u0436\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0447\u0442\u0435\u043c \u0438\u0437 \u043d\u0435\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043b\u0443\u044d\u0442.\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041c\u044b \u043f\u0440\u0438\u0432\u044f\u0436\u0435\u043c \u0442\u043e\u043b\u0449\u0438\u043d\u0443 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 \u043a \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u043a\u0440\u0430\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 1080p), \u0447\u0442\u043e\u0431\u044b \u043d\u0430 4K-\u044d\u043a\u0440\u0430\u043d\u0430\u0445 \u043a\u043e\u043d\u0442\u0443\u0440 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0441\u044f \u0432 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0443\u044e \u043d\u0438\u0442\u043e\u0447\u043a\u0443.\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b HardOutline.shader:High-level shader languageShader &#171;Custom\/HardOutline&#187;{    Properties    {        _OutlineColor (&#171;Outline Color&#187;, Color) = (1, 0, 0, 1)        _Thickness (&#171;Outline Thickness&#187;, Range(1, 10)) = 1.0    }    SubShader    {        Tags { &#171;RenderType&#187;=&#187;Opaque&#187; &#171;RenderPipeline&#187;=&#187;UniversalPipeline&#187; }        Pass        {            Blend SrcAlpha OneMinusSrcAlpha            ZWrite Off ZTest Always Cull Off            HLSLPROGRAM            #pragma vertex Vert             #pragma fragment Frag            #include &#171;Packages\/com.unity.render-pipelines.universal\/ShaderLibrary\/Core.hlsl&#187;            #include &#171;Packages\/com.unity.render-pipelines.core\/Runtime\/Utilities\/Blit.hlsl&#187;            TEXTURE2D_X(_OutlineRenderTexture);            SAMPLER(sampler_OutlineRenderTexture);            float4 _OutlineColor;            float _Thickness;            half4 Frag(Varyings input) : SV_Target {                float2 uv = input.texcoord;                half centerAlpha = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv).a;                float2 texelSize = float2(1.0 \/ _ScreenParams.x, 1.0 \/ _ScreenParams.y);                float referenceHeight = 1080.0;                float scaleFactor = _ScreenParams.y \/ referenceHeight;                float scaledThickness = _Thickness * scaleFactor;                float2 offset = texelSize * scaledThickness;                half up = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(0, offset.y)).a;                half down = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(0, -offset.y)).a;                half left = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(-offset.x, 0)).a;                half right = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(offset.x, 0)).a;                half topLeft = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(-offset.x, offset.y)).a;                half topRight = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(offset.x, offset.y)).a;                half bottomLeft = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(-offset.x, -offset.y)).a;                half bottomRight = SAMPLE_TEXTURE2D_X(_OutlineRenderTexture, sampler_OutlineRenderTexture, uv + float2(offset.x, -offset.y)).a;                half maxNeighbors = max(max(up, down), max(left, right));                half maxDiagonals = max(max(topLeft, topRight), max(bottomLeft, bottomRight));                half dilated = max(centerAlpha, max(maxNeighbors, maxDiagonals));                half edge = saturate(dilated &#8212; centerAlpha);                return half4(_OutlineColor.rgb, edge * _OutlineColor.a);            }            ENDHLSL        }    }}\u0428\u0430\u0433 3. C# \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u043c\u0430\u0433\u0438\u044f Render Graph\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435. \u0412 Unity 6 \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0433\u0440\u0430\u0444 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 (RecordRenderGraph), \u0430 \u0434\u0432\u0438\u0436\u043e\u043a \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 TextureDesc (\u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0441\u0442\u0430\u0440\u044b\u0439 GetTemporaryRT) \u0438 Blitter.BlitTexture (\u043f\u0440\u0438\u0448\u0435\u043b \u043d\u0430 \u0441\u043c\u0435\u043d\u0443 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u0435\u0448\u0443).\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 OutlineFeature.cs:C#using System;using UnityEngine;using UnityEngine.Rendering;using UnityEngine.Rendering.Universal;using UnityEngine.Rendering.RenderGraphModule;using UnityEngine.Experimental.Rendering;public class OutlineFeature : ScriptableRendererFeature{    [Serializable]    public class OutlineSettings    {        public LayerMask LayerMask;        public Material SilhouetteMaterial;        public Material OutlineMaterial;    }    public OutlineSettings settings = new OutlineSettings();    class RenderSilhouettePass : ScriptableRenderPass    {        private Material silhouetteMaterial;        private FilteringSettings filteringSettings;        private static readonly int SilhouetteTextureID = Shader.PropertyToID(&#171;_OutlineRenderTexture&#187;);        public RenderSilhouettePass(LayerMask layerMask, Material mat)        {            silhouetteMaterial = mat;            filteringSettings = new FilteringSettings(RenderQueueRange.opaque, layerMask);        }        private class PassData        {            public RendererListHandle rendererList;        }        public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)        {            if (silhouetteMaterial == null) return;            UniversalCameraData cameraData = frameData.Get&lt;UniversalCameraData&gt;();            UniversalRenderingData renderingData = frameData.Get&lt;UniversalRenderingData&gt;();            UniversalLightData lightData = frameData.Get&lt;UniversalLightData&gt;();            TextureDesc texDesc = new TextureDesc(cameraData.cameraTargetDescriptor.width, cameraData.cameraTargetDescriptor.height)            {                colorFormat = GraphicsFormat.R8G8B8A8_UNorm,                clearBuffer = true,                clearColor = Color.clear,                name = &#171;_OutlineRenderTexture&#187;            };            TextureHandle silhouetteTexture = renderGraph.CreateTexture(texDesc);            using (var builder = renderGraph.AddRasterRenderPass&lt;PassData&gt;(&#171;Render Silhouette&#187;, out var passData))            {                var sortingCriteria = cameraData.defaultOpaqueSortFlags;                var drawingSettings = CreateDrawingSettings(new ShaderTagId(&#171;UniversalForward&#187;), renderingData, cameraData, lightData, sortingCriteria);                drawingSettings.overrideMaterial = silhouetteMaterial;                RendererListParams listParams = new RendererListParams(renderingData.cullResults, drawingSettings, filteringSettings);                passData.rendererList = renderGraph.CreateRendererList(listParams);                builder.UseRendererList(passData.rendererList);                builder.SetRenderAttachment(silhouetteTexture, 0, AccessFlags.Write);                builder.AllowPassCulling(false);                builder.SetGlobalTextureAfterPass(silhouetteTexture, SilhouetteTextureID);                builder.SetRenderFunc((PassData data, RasterGraphContext context) =&gt;                {                    context.cmd.DrawRendererList(data.rendererList);                });            }        }    }    class DrawOutlinePass : ScriptableRenderPass    {        private Material outlineMaterial;        public DrawOutlinePass(Material mat)        {            outlineMaterial = mat;            requiresIntermediateTexture = true;         }        private class PassData        {            public Material material;        }        public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)        {            if (outlineMaterial == null) return;            UniversalResourceData resourceData = frameData.Get&lt;UniversalResourceData&gt;();            TextureHandle activeColorTexture = resourceData.activeColorTexture;            using (var&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-475570","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475570","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=475570"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475570\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=475570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=475570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=475570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}