{"id":291189,"date":"2018-10-22T20:15:02","date_gmt":"2018-10-22T16:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291189"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291189","title":{"rendered":"\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0432 Unity. GrabPass, PerRendererData"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0432 Unity. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 (Displacement\/Refraction) \u0432 2D, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f (GrabPass, PerRendererData), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0435\u043b\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442.<\/p>\n<p>  \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0435\u043c, \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u0445 \u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u043d\u043e \u043c\u0430\u043b\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Unity, \u0438 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0434\u0441\u0442\u0443\u043f\u0438\u0442\u044c\u0441\u044f. \u0417\u0430\u0433\u043b\u044f\u043d\u0438\u0442\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7p\/cy\/pr\/7pcyprnckvacvecylqvlu-8g68m.gif\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/u5\/wo\/ll\/u5woll2fo6nibjmd0lrgvszxvxk.gif\" alt=\"image\"\/><\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0448\u0435\u0439\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0439\u0442. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448\u0435\u0439 \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439. \u0427\u0442\u043e-\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u043d\u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f. \u041e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u201cSprites-Default\u201d \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0435\u0433\u043e\u0432 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441\u043f\u0440\u0430\u0439\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>Shader &quot;Displacement\/Displacement_Wave&quot; {     Properties     {         [PerRendererData]         _MainTex (&quot;Main Texture&quot;, 2D) = &quot;white&quot; {}         _Color (&quot;Color&quot; , Color) = (1,1,1,1)     }      SubShader     {         Tags         {             &quot;RenderType&quot; = &quot;Transparent&quot;             &quot;Queue&quot; = &quot;Transparent&quot;         }          Cull Off         Blend SrcAlpha OneMinusSrcAlpha                  Pass         {             CGPROGRAM             #pragma vertex vert             #pragma fragment frag                      #include &quot;UnityCG.cginc&quot;              struct appdata             {                 float4 vertex : POSITION;                 float2 uv : TEXCOORD0;                 float4 color : COLOR;             };              struct v2f             {                 float4 vertex : SV_POSITION;                 float2 uv : TEXCOORD0;                 float4 color : COLOR;             };              fixed4 _Color;             sampler2D _MainTex;                          v2f vert (appdata v)             {                 v2f o;                 o.uv = v.uv;                 o.color = v.color;                 o.vertex = UnityObjectToClipPos(v.vertex);                 return o;             }                          fixed4 frag (v2f i) : SV_Target             {                                            fixed4 texColor = tex2D(_MainTex, i.uv)*i.color;                                                 return texColor;             }             ENDCG         }     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043f\u0440\u0430\u0439\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\u0424\u043e\u043d \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439, \u0437\u0430\u0442\u0435\u043c\u043d\u0438\u043b \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7l\/yu\/in\/7lyuingedtk8frmquebh2m0kgdy.jpeg\" alt=\"image\"\/>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0430\u044f\u0441\u044f \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yl\/ir\/9i\/ylir9i7bz4ibkkbhag61q8v95ak.jpeg\" alt=\"image\"\/><\/p>\n<h2>GrabPass<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0418 \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434 <i>GrabPass<\/i>. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0445\u043e\u0434 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 <i>_GrabTexture<\/i>. \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043e \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u043e\u0442 \u0448\u0435\u0439\u0434\u0435\u0440, \u043f\u043e\u0448\u0451\u043b \u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0441\u0430\u043c\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u043d\u0435\u0435 \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b. \u042d\u0442\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0435 \u043d\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1) \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043a\u0430\u043c\u0435\u0440\u044b (\u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438).<\/p>\n<pre><code>struct v2f {     float4 vertex : SV_POSITION;     float2 uv :      float4 color : COLOR;     float4 grabPos : TEXCOORD1; };<\/code><\/pre>\n<p>  \u0410 \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u0445.<\/p>\n<pre><code>o.grabPos = ComputeGrabScreenPos (o.vertex);<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u0438\u0437 <i>_GrabTexture<\/i>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0435 \u043d\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b<\/p>\n<pre><code>tex2Dproj(_GrabTexture, i.grabPos)<\/code><\/pre>\n<p>  \u041d\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0438 \u043d\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0441\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0442.\u0435. \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0432 \u043d\u0430 w-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435.<\/p>\n<pre><code>tex2D(_GrabTexture, i.grabPos.xy\/i.grabPos.w)<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">w-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 w-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b, \u0432 \u043e\u0440\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043e\u043d\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u0430 1. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 <b>w<\/b> \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0442\u043e\u0447\u043a\u0438 \u0434\u043e \u043a\u0430\u043c\u0435\u0440\u044b. \u041d\u043e \u043e\u043d\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 \u2014 <b>z<\/b>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0442 0 \u0434\u043e 1. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u043c\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443.<\/div>\n<\/div>\n<p>  \u041f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435, \u0430 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code>v2f vert (appdata v) { \tv2f o; \to.uv = v.uv; \to.color = v.color; \to.vertex = UnityObjectToClipPos(v.vertex);\t \to.grabPos = ComputeScreenPos (o.vertex); \to.grabPos \/= o.grabPos.w; \treturn o; }<\/code><\/pre>\n<p>  \u0414\u043e\u043f\u0438\u0448\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.<\/p>\n<pre><code>fixed4 frag (v2f i) : SV_Target {                    \tfixed4 = grabColor = tex2d(_GrabTexture, i.grabPos.xy);         \tfixed4 texColor = tex2D(_MainTex, i.uv)*i.color;                                 \treturn grabColor; }<\/code><\/pre>\n<p>  \u041e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c\u0430 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f, \u0442.\u043a. \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code>\/\/Blend SrcAlpha OneMinusSrcAlpha Blend Off <\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b <i>GrabPass<\/i>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mh\/ex\/b_\/mhexb_lek_zyrgsto6p0ki4rmoi.jpeg\" alt=\"image\"\/><\/p>\n<p>  \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0432\u043d\u0435\u0441\u0451\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0434\u0432\u0438\u0433, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0427\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <i>_DisplacementPower<\/i>.<\/p>\n<pre><code>Properties \t{ \t\t[PerRendererData] \t\t_MainTex (&quot;Main Texture&quot;, 2D) = &quot;white&quot; {} \t\t_Color (&quot;Color&quot; , Color) = (1,1,1,1) \t\t_DisplacementPower (&quot;Displacement Power&quot; , Float) = 0 \t} SubShader \t{ \t\tPass \t\t{ \t\t\t... \t\t\tfloat _DisplacementPower; \t\t\t... \t\t} \t}<\/code><\/pre>\n<p>  \u0418 \u0441\u043d\u043e\u0432\u0430 \u0432\u043d\u0435\u0441\u0451\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.<\/p>\n<pre><code>fixed4  grabColor = tex2d(_GrabTexture, i.grabPos.xy + _DisplaccementPower);       <\/code><\/pre>\n<p>  \u041e\u043f \u0445\u043e\u043f \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442! \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0441\u043e \u0441\u0434\u0432\u0438\u0433\u043e\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ky\/yl\/9w\/kyyl9w51dqeap4_wvxws1nod4fg.jpeg\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044e. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0438\u043b\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435. \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u043e\u0441\u0438 x, \u0430 \u0437\u0435\u043b\u0451\u043d\u044b\u0439 \u043f\u043e \u043e\u0441\u0438 y. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b,\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0f\/fu\/-e\/0ffu-ezmyhr9lb3qofn9d99ese8.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ld\/mf\/no\/ldmfnoicn2b7e7cmsbpeml716hs.png\"\/>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b.<\/p>\n<pre><code>_DisplacementTex (&quot;Displacement Texture&quot;, 2D) = &quot;white&quot; {}<\/code><\/pre>\n<p>  \u0418 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<pre><code>sampler2D _DisplacementTex;<\/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\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u043a \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c.<\/p>\n<pre><code>fixed4 displPos = tex2D(_DisplacementTex, i.uv); float2 offset = (displPos.xy*2 - 1) * _DisplacementPower * displPos.a; fixed4 grabColor = tex2D (_GrabTexture, i.grabPos.xy + offset); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <i>_DisplacementPower<\/i>, \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u0449\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0430 \u0438\u0441\u043a\u0430\u0436\u0430\u0435\u043c \u0435\u0433\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tu\/pu\/w3\/tupuw3jqxaztn2jl19mdyhtvzwi.gif\"\/><\/p>\n<h3>Overlay<\/h3>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430, \u0430 \u0441\u043f\u0440\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u0412\u0435\u0440\u043d\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u043c\u0435\u0441\u0442\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0446\u0432\u0435\u0442\u043e\u0432. \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0443\u0433\u043e\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u0436\u0438\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f overlay. \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0432\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wd\/qr\/z7\/wdqrz7rv0skaotpofwwu4owvyxy.jpeg\"\/><\/p>\n<p>  \u0433\u0434\u0435 S \u2014 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0421 \u2014 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0448 \u0441\u043f\u0440\u0430\u0439\u0442, R \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u043c \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0432 \u043d\u0430\u0448 \u0448\u0435\u0439\u0434\u0435\u0440.<\/p>\n<pre><code>fixed4 color = grabColor &lt; 0.5 ? 2*grabColor*texColor  : 1-2*(1-texColor)*(1-grabColor); <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u043c\u0430. \u041c\u043d\u043e\u0433\u043e\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 API \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0438. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u0430\u043f\u0430\u0441\u043d\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439<\/p>\n<pre><code>c = step ( y, x); r = c * a + (1 - c) * b; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f step<\/b><\/p>\n<div class=\"spoiler_text\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f step \u0432\u0435\u0440\u043d\u0451\u0442 1, \u0435\u0441\u043b\u0438 <b>x<\/b> \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e <b>y<\/b>. \u0418 0, \u0435\u0441\u043b\u0438 <b>x<\/b> \u043c\u0435\u043d\u044c\u0448\u0435 <b>y<\/b>.<\/p>\n<p>  \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0435\u0441\u043b\u0438 <b>x<\/b> = 1, \u0430 <b>y<\/b> = 0.5, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <b>c<\/b> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 1. \u0418 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434<br \/>  r = 1 * a + 0 * b<br \/>  \u0422.\u043a. \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 0 \u0434\u0430\u0451\u0442 0, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <b>\u0430<\/b>.<br \/>  \u0412 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 <b>\u0441<\/b> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 0,<br \/>  r = 0 * a + 1 * b<br \/>  \u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 <b>b<\/b>.  <\/div>\n<\/div>\n<p>  \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 <i>overlay<\/i>.<\/p>\n<pre><code>fixed s = step(grabColor, 0.5); fixed4 color = s * (2 * grabColor * texColor) +              (1 - s) * (1 - 2 * (1 - texColor) * (1 - grabColor));<\/code><\/pre>\n<p>  \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u0445 \u0446\u0432\u0435\u0442\u043e\u0432.<\/p>\n<pre><code>color = lerp(grabColor, color ,texColor.a);<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code>fixed4 frag (v2f i) : SV_Target {                                    \tfixed4 displPos = tex2D(_DisplacementTex, i.uv); \tfloat2 offset = (displPos.xy*2 - 1) * _DisplacementPower * displPos.a;  \tfixed4 texColor = tex2D(_MainTex, i.uv + offset)*i.color; \tfixed4 grabColor = tex2D (_GrabTexture, i.grabPos.xy + offset);   \tfixed s = step(grabColor, 0.5); \tfixed4 color = s * (2 * grabColor * texColor) + \t\t     (1 - s) * (1 - 2 * (1 - texColor) * (1 - grabColor)); \tcolor = lerp(grabColor, color ,texColor.a);          \treturn color; }<\/code><\/pre>\n<p>  \u0418 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ea\/au\/xy\/eaauxypqmxxrbcjrkl4swnctjeg.gif\"\/><\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c GrabPass<\/h3>\n<p>  \u0412\u044b\u0448\u0435 \u0431\u044b\u043b\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434 <i>GrabPass {}<\/i> \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 <i>_GrabTexture <\/i>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f. <br \/>  \u041f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u044d\u043a\u0440\u0430\u043d\u0430.  <\/p>\n<pre><code>GrabPass{&quot;_DisplacementGrabTexture&quot;}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 GrabPass \u0437\u0430 \u043a\u0430\u0434\u0440. \u042d\u0442\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 <i>GrabPass{}<\/i>\u043c\u043d\u043e\u0433\u043e. \u041d\u043e \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u044b \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GrabPass{&quot;_DisplacementGrabTexture&quot;}.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9n\/uv\/n9\/9nuvn9st0v_t9l7rwxspbmy8iww.jpeg\"\/><\/p>\n<p>  \u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GrabPass{}.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sl\/ai\/4a\/slai4akjk0suyfp43gptuyp3pfw.jpeg\"\/><\/p>\n<h2>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u044d\u0444\u0444\u0435\u043a\u0442. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043b\u0430\u0432\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u0441\u0438\u043b\u0443 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f \u0432\u0437\u0440\u044b\u0432\u043d\u043e\u0439 \u0432\u043e\u043b\u043d\u044b, \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u044f \u0435\u0451 \u0443\u0433\u0430\u0441\u0430\u043d\u0438\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">public class Wave : MonoBehaviour {     private float _elapsedTime;     private SpriteRenderer _renderer;      public float Duration;     [Space]     public AnimationCurve ScaleProgress;     public Vector3 ScalePower;     [Space]     public AnimationCurve PropertyProgress;     public float PropertyPower;     [Space]     public AnimationCurve AlphaProgress;      private void Start()     {         _renderer = GetComponent&lt;SpriteRenderer&gt;();         }      private void OnEnable()     {         _elapsedTime = 0f;     }      void Update()     {         if (_elapsedTime &lt; Duration)         {             var progress = _elapsedTime \/ Duration;              var scale = ScaleProgress.Evaluate(progress) * ScalePower;             var property = PropertyProgress.Evaluate(progress) * PropertyPower;             var alpha = AlphaProgress.Evaluate(progress);              transform.localScale = scale;             _renderer.material.SetFloat(&quot;_DisplacementPower&quot;, property);             var color = _renderer.color;             color.a = alpha;             _renderer.color = color;              _elapsedTime += Time.deltaTime;         }         else         {             _elapsedTime = 0;         }     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cs\/sm\/9f\/cssm9fqvoequsovfl8wlff72rxu.jpeg\"\/>  <\/div>\n<\/div>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/5j\/sm\/ic\/5jsmicvf7jepmp-adecch-jlwb8.gif\"\/><\/p>\n<h2>PerRendererData<\/h2>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"cs\">_renderer.material.SetFloat(&quot;_DisplacementPower&quot;, property);<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u043d\u044f\u0435\u043c \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430, \u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043f\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 (\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430) \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0443\u0436\u0435 \u0441 \u043d\u0435\u0439. \u0412\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u043e \u0435\u0441\u043b\u0438 \u043d\u0430 \u0441\u0446\u0435\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u044b\u0441\u044f\u0447\u0430, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u043e\u043f\u0438\u0439 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443. \u0415\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043b\u0443\u0447\u0448\u0435 \u2014 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0448\u0435\u0439\u0434\u0435\u0440 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <i>[PerRendererData]<\/i>, \u0430 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <i>MaterialPropertyBlock<\/i>. <\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <i>_DisplacementPower<\/i>.<\/p>\n<pre><code>[PerRendererData] _DisplacementPower (&quot;Displacement Power&quot; , Range(-.1,.1)) = 0<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0435, \u0442.\u043a. \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u043e \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ni\/g4\/zu\/nig4zujdlflr1xjm_ry-cwulane.jpeg\"\/><\/p>\n<p>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u0438 \u0432\u043d\u0435\u0441\u0451\u043c \u0432 \u043d\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">private MaterialPropertyBlock _propertyBlock;  private void Start() {     _renderer = GetComponent&lt;SpriteRenderer&gt;();     _propertyBlock = new MaterialPropertyBlock(); } void Update() {     ...     \/\/_renderer.material.SetFloat(&quot;_DisplacementPower&quot;, property);     _renderer.GetPropertyBlock(_propertyBlock);     _propertyBlock.SetFloat(&quot;_DisplacementPower&quot;, property);     _renderer.SetPropertyBlock(_propertyBlock);     ... }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c <i>MaterialPropertyBlock <\/i>\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043a\u043e\u043f\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e SpriteRenderer<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435.<\/p>\n<pre><code>[PerRendererData] _MainTex (&quot;Main Texture&quot;, 2D) = &quot;white&quot; {}<\/code><\/pre>\n<p>  <i>SpriteRenderer <\/i>\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438. \u041e\u043d \u0441\u0430\u043c \u0437\u0430\u0434\u0430\u0451\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <i>_MainTex <\/i>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <i>MaterialPropertyBlock<\/i>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0435 \u0443 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <i>_MainTex<\/i>, \u0430 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <i>SpriteRenderer <\/i>\u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u0441\u0446\u0435\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u043d\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0434\u043b\u044f \u0438\u0445 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d (\u0435\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0441\u0430\u043c\u0438).  <\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c PerRendererData<\/h3>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <i>MaterialPropertyBlock <\/i>\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u0443 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 <i>SpriteRenderer<\/i>, <i>ParticleRenderer<\/i>, <i>MeshRenderer <\/i>\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 <i>Renderer<\/i>. \u041d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u044d\u0442\u043e <i>CanvasRenderer<\/i>. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c 2D \u0438\u0433\u0440\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c UI-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0442\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0435\u0441\u044c \u0441 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432.<\/p>\n<h2>\u0412\u0440\u0430\u0449\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u0440\u0443\u0433\u043b\u043e\u0439 \u0432\u043e\u043b\u043d\u044b \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e.<\/p>\n<p>  \u041f\u0440\u0430\u0432\u0430\u044f \u0432\u043e\u043b\u043d\u0430 \u043f\u0440\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0435 (90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432) \u0434\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0435 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ns\/gy\/2e\/nsgy2effgwcv8d0kavaltwd2ofi.jpeg\"\/><\/p>\n<p>  \u041a\u0440\u0430\u0441\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u043e\u0447\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u043d\u043e\u043c \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0435 \u044d\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u0435\u043c \u0436\u0435 \u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f <i>unity_ObjectToWorld<\/i>. \u041e\u043d\u0430 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430\u0448 \u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u043c\u0438\u0440\u043e\u0432\u044b\u0435.<\/p>\n<pre><code>float2 offset = (displPos.xy*2 - 1) * _DisplacementPower * displPos.a; offset = mul( unity_ObjectToWorld, offset);<\/code><\/pre>\n<p>  \u041d\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u0441\u0438\u043b\u044b \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"cs\">_propertyBlock.SetFloat(&quot;_DisplacementPower&quot;, property\/transform.localScale.x);<\/code><\/pre>\n<p>  \u041f\u0440\u0430\u0432\u0430\u044f \u0432\u043e\u043b\u043d\u0430 \u0432\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0430 \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u043d\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0440\u043d\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g4\/hc\/gu\/g4hcguat4nxvgm0b2jyylrqvlze.jpeg\"\/><\/p>\n<h2>Clip<\/h2>\n<p>  \u041d\u0430\u0448\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u0438\u043f \u043c\u0435\u0448\u0430 <i>Rect<\/i>). \u0428\u0435\u0439\u0434\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0445, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <i>clip(\u0445)<\/i>. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0443\u043b\u044f, \u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f. \u041d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u044c\u0444\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 0, \u0442\u043e \u043c\u044b \u0432\u044b\u0447\u0442\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0415\u0433\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (<i>Cutout<\/i>) \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0438\u0441\u043b\u043e <b>0,01<\/b>.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code>fixed4 frag (v2f i) : SV_Target {\t\t\t\t\t\t\t\t\t \tfixed4 displPos = tex2D(_DisplacementTex, i.uv); \tfloat2 offset = (displPos.xy * 2 - 1) * _DisplacementPower * displPos.a; \toffset = mul( unity_ObjectToWorld,offset); \tfixed4 texColor = tex2D(_MainTex, i.uv + offset)*i.color;  \tclip(texColor.a - 0.01);  \tfixed4 grabColor = tex2D (_GrabTexture, i.grabPos.xy + offset);  \tfixed s = step(grabColor, 0.5);\t\t\t\t \tfixed4 color = s * 2 * grabColor * texColor +     \t \t     (1 - s) * (1 - 2 * (1 - texColor) * (1 - grabColor)); \tcolor = lerp(grabColor, color ,texColor.a);\t\t\t \treturn color;\t\t\t }<\/code><\/pre>\n<p>  P.S.: \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u2014 <a href=\"https:\/\/gitlab.com\/Dimonik333\/Displacement_Example_2D\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 git<\/a>. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0434\u043b\u044f \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f. \u041a\u0440\u0438\u0441\u0442\u0430\u043b\u043b \u0441 \u043f\u043e\u0441\u0442\u0430\u043c\u0435\u043d\u0442\u043e\u043c \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u0438\u0437 \u0430\u0441\u0441\u0435\u0442\u0430 \u2014 2D Game Kit.<\/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\/post\/427357\/\"> https:\/\/habr.com\/post\/427357\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0432 Unity. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 (Displacement\/Refraction) \u0432 2D, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f (GrabPass, PerRendererData), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0435\u043b\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442.<\/p>\n<p>  \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0435\u043c, \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u0445 \u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u043d\u043e \u043c\u0430\u043b\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Unity, \u0438 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0434\u0441\u0442\u0443\u043f\u0438\u0442\u044c\u0441\u044f. \u0417\u0430\u0433\u043b\u044f\u043d\u0438\u0442\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7p\/cy\/pr\/7pcyprnckvacvecylqvlu-8g68m.gif\"\/>  <\/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-291189","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291189","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=291189"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291189\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}