{"id":165563,"date":"2013-01-12T16:51:03","date_gmt":"2013-01-12T12:51:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=165563"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=165563","title":{"rendered":"<span class=\"post_title\">\u0418\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0447\u043d\u043e\u0435 \u0437\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432 3D-\u0438\u0433\u0440\u0435<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u0442\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 DirectX.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u0442\u0435\u043c\u043d\u043e\u0442\u0435 \u0437\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0435\u0442\u043a\u0430\u043c\u0438-\u043f\u0430\u043b\u043e\u0447\u043a\u0430\u043c\u0438 \u0441\u0435\u0442\u0447\u0430\u0442\u043a\u0438, \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u0438 \u0446\u0432\u0435\u0442\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0441\u0442\u0440\u043e\u0442\u044b \u0437\u0440\u0435\u043d\u0438\u044f (\u0445\u043e\u0442\u044f \u043f\u0430\u043b\u043e\u0447\u0435\u043a \u0432 \u0441\u0435\u0442\u0447\u0430\u0442\u043a\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u043e\u043d\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u00ab\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u00bb \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435).<\/p>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u043e\u0442\u043e\u0440\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0438 \u0432\u044b\u0439\u0434\u044f \u043d\u043e\u0447\u044c\u044e \u043d\u0430 \u0443\u043b\u0438\u0446\u0443.<\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e (<em>\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u0435\u0441\u044c \u044d\u043a\u0440\u0430\u043d!<\/em>):<\/p>\n<p>  <em>\u0414\u043e: \u0443\u043d\u044b\u043b\u044b\u0439 \u043f\u043e\u043b\u044c\u0441\u043a\u0438\u0439 \u0448\u0443\u0442\u0435\u0440<\/em><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/2ef\/fd5\/f41\/2effd5f410de2a6e4039a59eb77dde04.png\"\/><\/p>\n<p>  <em>\u041f\u043e\u0441\u043b\u0435: \u0444\u0438\u043d\u0430\u043b\u0438\u0441\u0442 IGF \u0438 \u043b\u0430\u0443\u0440\u0435\u0430\u0442 \u0432\u0441\u0435\u0445 \u043d\u0430\u0433\u0440\u0430\u0434 E3<\/em><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/093\/e4f\/2a3\/093e4f2a33eba607422f125e0fba5c9a.png\"\/><br \/>  <a name=\"habracut\"><\/a><\/p>\n<h1>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h1>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0441\u0442\u0438\u0447\u044c. \u042f \u0440\u0430\u0437\u0431\u0438\u043b \u0432\u0441\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438:  <\/p>\n<ul>\n<li>\u041f\u043e\u0442\u0435\u0440\u044f \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f \u0432 \u0437\u043e\u043d\u0430\u0445 \u043d\u0438\u0437\u043a\u043e\u0439 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/li>\n<li>\u041f\u043e\u0442\u0435\u0440\u044f \u0447\u0435\u0442\u043a\u043e\u0441\u0442\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0442\u0430\u043c \u0436\u0435<\/li>\n<li>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0448\u0443\u043c (\u0442\u0430\u043c \u0436\u0435)<\/li>\n<li>\u041f\u043e\u0442\u0435\u0440\u044f \u0447\u0435\u0442\u043a\u043e\u0441\u0442\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u0440\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<h1>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h1>\n<p>  \u041f\u0438\u0441\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434 Unity3D Pro, \u0432 \u0432\u0438\u0434\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0448\u0435\u0439\u0434\u0435\u0440\u0443, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0433\u043e\u043d\u043a\u0443 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440:<\/p>\n<pre><code class=\"cs\">using UnityEngine;  [ExecuteInEditMode] public class HumanEye : MonoBehaviour { \tpublic Shader Shader; \tpublic float LuminanceThreshold; \tpublic Texture Noise; \tpublic float NoiseAmount = 0.5f, NoiseScale = 2;  \tprivate Camera mainCam; \tprivate Material material;  \tprivate const int PASS_MAIN = 0;  \tvoid Start () \t{ \t\tmainCam = camera; \t\tmainCam.depthTextureMode |= DepthTextureMode.DepthNormals; \t\tmaterial = new Material (Shader); \t}  \tvoid OnRenderImage (RenderTexture source, RenderTexture destination) \t{ \t\tmaterial.SetFloat(&quot;_LuminanceThreshold&quot;, LuminanceThreshold); \t\tmaterial.SetFloat (&quot;_BlurDistance&quot;, 0.01f); \t\tmaterial.SetFloat (&quot;_CamDepth&quot;, mainCam.far); \t\tmaterial.SetTexture (&quot;_NoiseTex&quot;, Noise); \t\tmaterial.SetFloat (&quot;_Noise&quot;, NoiseAmount); \t\tmaterial.SetFloat (&quot;_NoiseScale&quot;, NoiseScale); \t\tmaterial.SetVector(&quot;_Randomness&quot;, Random.insideUnitSphere); \t\tGraphics.Blit (source, destination, material, PASS_MAIN); \t}\t\t } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0448 \u0448\u0435\u0439\u0434\u0435\u0440.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u0435\u043b\u043e\u043c.<\/p>\n<p>  \u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442:  <\/p>\n<pre><code class=\"cpp\">sampler2D _CameraDepthNormalsTexture; float4 _CameraDepthNormalsTexture_ST;  sampler2D _MainTex; float4 _MainTex_ST;  sampler2D _NoiseTex; float4 _NoiseTex_ST; float4 _Randomness;  uniform float _BlurDistance, _LuminanceThreshold, _CamDepth, _Noise, _NoiseScale;  #define DEPTH_BLUR_START 3 #define FAR_BLUR_START 40 #define FAR_BLUR_LENGTH 20<\/code><\/pre>\n<p>  \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439. \u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u0438 \u0432 \u0434\u043e\u0431\u0430\u0432\u043a\u0443 \u043a \u043d\u0435\u043c\u0443 \u2014 \u00ab\u0440\u0430\u0437\u043c\u044b\u0442\u043e\u0435\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u044f:  <\/p>\n<pre><code class=\"cpp\">struct v2f { \tfloat4 pos : POSITION; \tfloat2 uv : TEXCOORD0; \tfloat2 uv_depth : TEXCOORD1; };  half4 main_frag (v2f i) : COLOR { \thalf4 cColor = tex2D(_MainTex, i.uv); \thalf4 cBlurred = blur(_MainTex, i.uv, _BlurDistance);<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u00ab\u0440\u0430\u0437\u043c\u044b\u0442\u043e\u0433\u043e\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 blur(), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443 \u0441 \u043d\u0430\u0448\u0438\u043c \u0438 \u0443\u0441\u0440\u0435\u0434\u043d\u044f\u0435\u0442 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">inline half4 blur (sampler2D tex, float2 uv, float dist) { \t#define BLUR_SAMPLE_COUNT 16         \/\/ \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u0431\u0440\u043e\u0441\u043a\u043e\u043c float-\u043a\u043e\u0441\u0442\u0438! \tconst float3 RAND_SAMPLES[16] = { \t\t\tfloat3(0.2196607,0.9032637,0.2254677),                         .... \u0435\u0449\u0435 14 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 .... \t\t\tfloat3(0.2448421,-0.1610962,0.1289366), \t};  \thalf4 result = 0; \tfor (int s = 0; s &lt; BLUR_SAMPLE_COUNT; ++s) \t\tresult += tex2D(tex, uv + RAND_SAMPLES[s].xy * dist); \tresult \/= BLUR_SAMPLE_COUNT; \treturn result; }<\/code><\/pre>\n<p>  \u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043d\u0435\u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u044f\u0440\u043a\u043e\u0441\u0442\u0438 \u043f\u043e \u0442\u0440\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0430\u043c. \u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043e\u0442\u0441\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u044f\u0440\u043a\u043e\u0441\u0442\u0438 (LuminanceThreshold), \u0442.\u0435. \u0432\u0441\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0441\u0432\u0435\u0442\u043b\u0435\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u00ab\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044f\u0440\u043a\u0438\u043c\u0438\u00bb, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cpp\">half kLum = (cColor.r + cColor.g + cColor.b) \/ 3; kLum = 1 - clamp(kLum \/ _LuminanceThreshold, 0, 1);<\/code><\/pre>\n<p>  \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c kLum \u043e\u0442 \u044f\u0440\u043a\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0dd\/889\/d18\/0dd889d186d36147e914e20357691b28.png\"\/><\/p>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f kLum \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u0446\u0435\u043d\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a (\u0431\u0435\u043b\u044b\u0439 \u2014 1, \u0447\u0435\u0440\u043d\u044b\u0439 \u2014 0):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/54d\/802\/fbf\/54d802fbf699deb7e389100a00e358c7.png\"\/><\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044f\u0440\u043a\u0438\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 (\u0433\u0430\u043b\u043e \u0444\u043e\u043d\u0430\u0440\u0435\u0439 \u0438 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u0430\u044f \u0442\u0440\u0430\u0432\u0430) \u0438\u043c\u0435\u044e\u0442 kLum \u0440\u0430\u0432\u043d\u044b\u0439 \u043d\u0443\u043b\u044e \u0438 \u043d\u0430\u0448 \u044d\u0444\u0444\u0435\u043a\u0442 \u043a \u043d\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u0430 \u0434\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0432 \u043c\u0435\u0442\u0440\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 <em>\u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0433\u043b\u0443\u0431\u0438\u043d\u044b <\/em>(depth texture, Z-buffer), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u0440\u0438 deferred-\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435.<\/p>\n<pre><code class=\"cpp\">float depth; float3 normal; DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, i.uv_depth), depth, normal); depth *= _CamDepth; \/\/ depth in meters&lt;\/pre&gt; \u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 kDepth \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u0432\u0431\u043b\u0438\u0437\u0438, \u0430 kFarBlur - \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0434\u0430\u043b\u0438: &lt;pre class=&quot;lang:c decode:true&quot;&gt;#define DEPTH_BLUR_START 3 #define FAR_BLUR_START 40 #define FAR_BLUR_LENGTH 20 half kDepth = clamp(depth - DEPTH_BLUR_START, 0, 1); half kFarBlur = clamp((depth - FAR_BLUR_START) \/ FAR_BLUR_LENGTH, 0, 1);<\/code><\/pre>\n<p>  \u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u043e\u0431\u043e\u0438\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0433\u043e \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ffc\/f73\/874\/ffcf7387426333ae221b6fac884f630f.png\"\/><br \/>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f kFarBlur:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a70\/309\/144\/a703091444e170e488d5cc68d4e886f0.png\"\/><\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u2014 \u043c\u0430\u0433\u0438\u044f! \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0442\u0440\u0435\u0445:<\/p>\n<pre><code class=\"cpp\">half kBlur = clamp(kLum * kDepth + kFarBlur, 0, 1);<\/code><\/pre>\n<p>  \u0422\u0435\u043c\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0440\u043e\u0432 (DEPTH_BLUR_START), \u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u2014 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/8d9\/ea9\/db8\/8d9ea9db857e10528e49ab95c1a51318.png\"\/><\/p>\n<p>  \u0421\u0442\u0435\u043f\u0435\u043d\u044c \u043f\u043e\u0442\u0435\u0440\u0438 \u0446\u0432\u0435\u0442\u0430 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u0430 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u00ab\u043d\u0435\u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438\u00bb (half kDesaturate = kLum).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043c\u0435\u0448\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439, \u0440\u0430\u0437\u043c\u044b\u0442\u044b\u0439 \u0438 \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438 \u0440\u0430\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442:  <\/p>\n<pre><code class=\"cpp\">half kDesaturate = kLum;  half4 result = cColor; result = (1 - kBlur) * result + kBlur * cBlurred;  half resultValue = result; result = (1 - kDesaturate) * result + kDesaturate * resultValue; return result;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/7b1\/01b\/4b2\/7b101b4b2f7dc779bee04f090eb21852.png\"\/><\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0435 \u2014 \u0442\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442. \u0427\u0435\u0433\u043e? \u0428\u0443\u043c\u043e\u0432!<\/p>\n<pre><code class=\"cpp\">half noiseValue = tex2D(_NoiseTex, i.uv * _NoiseScale + _Randomness.xy); half kNoise = kLum * _Noise;<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b _NoiseTex (\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0443\u044e \u0413\u0430\u0443\u0441\u0441\u043e\u0432\u044b\u043c \u0448\u0443\u043c\u043e\u043c \u0438\u0437 \u0444\u043e\u0442\u043e\u0448\u043e\u043f\u0430), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440 _Randomness, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0438\u043a\u0441\u0435\u043b\u044c:<\/p>\n<pre><code class=\"cpp\">result *= (1 - kNoise + noiseValue * kNoise);<\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u043d\u0443\u0441\u0430 \u2014 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0438\u0434\u0435\u043e \u0438 <a href=\"https:\/\/gist.github.com\/4517834\">\u0441\u0430\u043c \u0448\u0435\u0439\u0434\u0435\u0440<\/a>:<\/p>\n<p>  <iframe loading=\"lazy\" width=\"560\" height=\"349\" src=\"http:\/\/www.youtube.com\/embed\/4G2E8Ea3Rks\" frameborder=\"0\" allowfullscreen><\/iframe>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/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=\"http:\/\/habrahabr.ru\/post\/165563\/\"> http:\/\/habrahabr.ru\/post\/165563\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u0442\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 DirectX.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u0442\u0435\u043c\u043d\u043e\u0442\u0435 \u0437\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0435\u0442\u043a\u0430\u043c\u0438-\u043f\u0430\u043b\u043e\u0447\u043a\u0430\u043c\u0438 \u0441\u0435\u0442\u0447\u0430\u0442\u043a\u0438, \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u0438 \u0446\u0432\u0435\u0442\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0441\u0442\u0440\u043e\u0442\u044b \u0437\u0440\u0435\u043d\u0438\u044f (\u0445\u043e\u0442\u044f \u043f\u0430\u043b\u043e\u0447\u0435\u043a \u0432 \u0441\u0435\u0442\u0447\u0430\u0442\u043a\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u043e\u043d\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u00ab\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u00bb \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435).<\/p>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u043e\u0442\u043e\u0440\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0438 \u0432\u044b\u0439\u0434\u044f \u043d\u043e\u0447\u044c\u044e \u043d\u0430 \u0443\u043b\u0438\u0446\u0443.<\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e (<em>\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u0435\u0441\u044c \u044d\u043a\u0440\u0430\u043d!<\/em>):<\/p>\n<p>  <em>\u0414\u043e: \u0443\u043d\u044b\u043b\u044b\u0439 \u043f\u043e\u043b\u044c\u0441\u043a\u0438\u0439 \u0448\u0443\u0442\u0435\u0440<\/em><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/2ef\/fd5\/f41\/2effd5f410de2a6e4039a59eb77dde04.png\"\/><\/p>\n<p>  <em>\u041f\u043e\u0441\u043b\u0435: \u0444\u0438\u043d\u0430\u043b\u0438\u0441\u0442 IGF \u0438 \u043b\u0430\u0443\u0440\u0435\u0430\u0442 \u0432\u0441\u0435\u0445 \u043d\u0430\u0433\u0440\u0430\u0434 E3<\/em><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/093\/e4f\/2a3\/093e4f2a33eba607422f125e0fba5c9a.png\"\/>  <\/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-165563","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165563","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=165563"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165563\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}