{"id":301822,"date":"2020-04-14T09:00:56","date_gmt":"2020-04-14T09:00:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301822"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301822","title":{"rendered":"\u041c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u043f\u0440\u0438 120 \u0441 \u043b\u0438\u0448\u043d\u0438\u043c fps"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/496826\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/867\/3ce\/d0a\/8673ced0a9e85041d6dac0d3cee54858.png\" alt=\"image\"><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0431\u0440\u043e\u0434\u0438\u0442\u0435 \u043f\u043e <a rel=\"nofollow\" href=\"https:\/\/forum.unity.com\/forums\/data-oriented-technology-stack.147\/\">\u0444\u043e\u0440\u0443\u043c\u0443<\/a> DOTS, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0442\u0430\u043c <a rel=\"nofollow\" href=\"https:\/\/forum.unity.com\/threads\/1-million-animated-sprites-at-60-fps.811116\/#post-5669068\">\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u044b<\/a> \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 60fps. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 <a rel=\"nofollow\" href=\"https:\/\/coffeebraingames.wordpress.com\/2018\/09\/30\/adding-pure-ecs-to-a-monobehaviour-based-project-a-true-story\/\">\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 DOTS<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 <a rel=\"nofollow\" href=\"https:\/\/store.steampowered.com\/app\/672630\/Academia__School_Simulator\/\">\u0438\u0433\u0440\u044b<\/a>, \u043d\u043e \u043e\u043d \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c. \u041c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0444\u043e\u0440\u043a\u043d\u0443\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 Academia. \u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441 \u043d\u0438\u043c, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b, \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u043e\u0434\u0438\u043d \u0441\u043f\u0440\u0430\u0439\u0442, \u0441\u043e\u0442\u043d\u044e, \u0437\u0430\u0442\u0435\u043c \u0442\u044b\u0441\u044f\u0447\u0438. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u0435. \u0412 \u043d\u0451\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0441\u0437\u0430\u0434\u0438 \u0432\u043f\u0435\u0440\u0451\u0434. \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0430\u043a \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u043e\u0433\u0434\u0430 \u044f \u0447\u0438\u0442\u0430\u043b \u043a\u043e\u0434, \u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041c\u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0441\u043f\u0440\u0430\u0439\u0442\u044b, \u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u044f \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0421\u0430\u043c\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u044b<\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u044f \u0445\u043e\u0447\u0443 \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u0442\u0443 \u0442\u0435\u0445\u043d\u0438\u043a\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0439\u0442. \u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f ComputeBuffers. \u041e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 GPU \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432. \u042f \u043d\u0435 \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0447\u0442\u043e-\u0442\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u041c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0447\u0438\u0441\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u043c, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u0430\u043a \u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u043c\u0430\u0441\u0448\u0442\u0430\u0431, uv-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0446\u0432\u0435\u0442\u0430 \u2014 \u0432\u0441\u0451, \u0447\u0442\u043e \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u0442\u0435. \u041d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0448\u0435\u0439\u0434\u0435\u0440, \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">  Shader &quot;Instanced\/ComputeBufferSprite&quot; {     Properties {         _MainTex (&quot;Albedo (RGB)&quot;, 2D) = &quot;white&quot; {}     }          SubShader {         Tags{             &quot;Queue&quot;=&quot;Transparent&quot;             &quot;IgnoreProjector&quot;=&quot;True&quot;             &quot;RenderType&quot;=&quot;Transparent&quot;         }         Cull Back         Lighting Off         ZWrite On         Blend One OneMinusSrcAlpha         Pass {             CGPROGRAM             \/\/ Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it uses non-square matrices             #pragma exclude_renderers gles              #pragma vertex vert             #pragma fragment frag             #pragma target 4.5              #include &quot;UnityCG.cginc&quot;              sampler2D _MainTex;              \/\/ xy for position, z for rotation, and w for scale             StructuredBuffer&lt;float4&gt; transformBuffer;              \/\/ xy is the uv size, zw is the uv offset\/coordinate             StructuredBuffer&lt;float4&gt; uvBuffer;   \t        StructuredBuffer&lt;float4&gt; colorsBuffer;              struct v2f{                 float4 pos : SV_POSITION;                 float2 uv: TEXCOORD0; \t\t        fixed4 color : COLOR0;             };              float4x4 rotationZMatrix(float zRotRadians) {                 float c = cos(zRotRadians);                 float s = sin(zRotRadians);                 float4x4 ZMatrix  =                      float4x4(                         c,  -s, 0,  0,a                        s,  c,  0,  0,                        0,  0,  1,  0,                        0,  0,  0,  1);                 return ZMatrix;             }              v2f vert (appdata_full v, uint instanceID : SV_InstanceID) {                 float4 transform = transformBuffer[instanceID];                 float4 uv = uvBuffer[instanceID];                                  \/\/rotate the vertex                 v.vertex = mul(v.vertex - float4(0.5, 0.5, 0,0), rotationZMatrix(transform.z));                                  \/\/scale it                 float3 worldPosition = float3(transform.x, transform.y, -transform.y\/10) + (v.vertex.xyz * transform.w);                                  v2f o;                 o.pos = UnityObjectToClipPos(float4(worldPosition, 1.0f));                                  \/\/ XY here is the dimension (width, height).                  \/\/ ZW is the offset in the texture (the actual UV coordinates)                 o.uv =  v.texcoord * uv.xy + uv.zw;                  \t\t        o.color = colorsBuffer[instanceID];                 return o;             }              fixed4 frag (v2f i) : SV_Target{                 fixed4 col = tex2D(_MainTex, i.uv) * i.color; \t\t\t\tclip(col.a - 1.0 \/ 255.0);                 col.rgb *= col.a;  \t\t\t\treturn col;             }              ENDCG         }     } }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 variables transformBuffer, uvBuffer \u0438 colorsBuffer \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u00ab\u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 ComputeBuffers. \u042d\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e (\u043f\u043e\u043a\u0430) \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 MonoBehaviour \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430:<\/p>\n<pre><code class=\"cs\">public class ComputeBufferBasic : MonoBehaviour {     [SerializeField]     private Material material;      private Mesh mesh;          \/\/ Transform here is a compressed transform information     \/\/ xy is the position, z is rotation, w is the scale     private ComputeBuffer transformBuffer;          \/\/ uvBuffer contains float4 values in which xy is the uv dimension and zw is the texture offset     private ComputeBuffer uvBuffer;     private ComputeBuffer colorBuffer;      private readonly uint[] args = {         6, 1, 0, 0, 0     };          private ComputeBuffer argsBuffer;      private void Awake() {         this.mesh = CreateQuad();                  this.transformBuffer = new ComputeBuffer(1, 16);         float scale = 0.2f;         this.transformBuffer.SetData(new float4[]{ new float4(0, 0, 0, scale) });         int matrixBufferId = Shader.PropertyToID(&quot;transformBuffer&quot;);         this.material.SetBuffer(matrixBufferId, this.transformBuffer);                  this.uvBuffer = new ComputeBuffer(1, 16);         this.uvBuffer.SetData(new float4[]{ new float4(0.25f, 0.25f, 0, 0) });         int uvBufferId = Shader.PropertyToID(&quot;uvBuffer&quot;);         this.material.SetBuffer(uvBufferId, this.uvBuffer);                  this.colorBuffer = new ComputeBuffer(1, 16);         this.colorBuffer.SetData(new float4[]{ new float4(1, 1, 1, 1) });         int colorsBufferId = Shader.PropertyToID(&quot;colorsBuffer&quot;);         this.material.SetBuffer(colorsBufferId, this.colorBuffer);          this.argsBuffer = new ComputeBuffer(1, this.args.Length * sizeof(uint), ComputeBufferType.IndirectArguments);         this.argsBuffer.SetData(this.args);     }      private static readonly Bounds BOUNDS = new Bounds(Vector2.zero, Vector3.one);      private void Update() {            \/\/ Draw         Graphics.DrawMeshInstancedIndirect(this.mesh, 0, this.material, BOUNDS, this.argsBuffer);     }          \/\/ This can be refactored to a utility class     \/\/ Just added it here for the article     private static Mesh CreateQuad() {         Mesh mesh = new Mesh();         Vector3[] vertices = new Vector3[4];         vertices[0] = new Vector3(0, 0, 0);         vertices[1] = new Vector3(1, 0, 0);         vertices[2] = new Vector3(0, 1, 0);         vertices[3] = new Vector3(1, 1, 0);         mesh.vertices = vertices;          int[] tri = new int[6];         tri[0] = 0;         tri[1] = 2;         tri[2] = 1;         tri[3] = 2;         tri[4] = 3;         tri[5] = 1;         mesh.triangles = tri;          Vector3[] normals = new Vector3[4];         normals[0] = -Vector3.forward;         normals[1] = -Vector3.forward;         normals[2] = -Vector3.forward;         normals[3] = -Vector3.forward;         mesh.normals = normals;          Vector2[] uv = new Vector2[4];         uv[0] = new Vector2(0, 0);         uv[1] = new Vector2(1, 0);         uv[2] = new Vector2(0, 1);         uv[3] = new Vector2(1, 1);         mesh.uv = uv;          return mesh;     } }<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u0414\u043b\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0448\u0435\u0439\u0434\u0435\u0440. \u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0435\u043c\u0443 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443\/\u0441\u043f\u0440\u0430\u0439\u0442\u0448\u0438\u0442. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043f\u0440\u0430\u0439\u0442\u0448\u0438\u0442 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u043e\u0439 \u0438\u043a\u043e\u043d\u043a\u0438 \u044d\u043c\u043e\u0434\u0437\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 4\u00d74 \u0441\u043f\u0440\u0430\u0439\u0442\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d63\/5a4\/533\/d635a4533eb5868518829ce674b91463.png\"><\/div>\n<p>  \u041c\u0435\u0448 \u0437\u0434\u0435\u0441\u044c \u2014 \u044d\u0442\u043e \u043c\u0435\u0448, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 CreateQuad(). \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432. \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0443\u0442 \u0442\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 ComputeBuffer, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u043e\u0437\u0436\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b. \u042f \u043d\u0430\u0437\u0432\u0430\u043b \u0438\u0445 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 StructuredBuffer \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435. \u042d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0442\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u0435\u0435.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 args \u0438 argsBuffer \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 Graphics.DrawMeshInstancedIndirect(). \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a rel=\"noreferrer noopener\" href=\"\/InstalledPrograms\/Unity\/2019.3.6f1\/Editor\/Data\/Documentation\/en\/ScriptReference\/Graphics.DrawMeshInstancedIndirect.html\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u0443\u0444\u0435\u0440 \u0441 \u043f\u044f\u0442\u044c\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 uint. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430. \u041f\u0435\u0440\u0432\u043e\u0435 \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u044d\u0442\u043e 6. \u0412\u0442\u043e\u0440\u043e\u0435 \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e 1. \u042f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0435\u0433\u043e \u0435\u0449\u0451 \u0438 \u043a\u0430\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f StructuredBuffer. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">for(int i = 0; i &lt; count; ++i) {     CallShaderUsingThisIndexForBuffers(i); }<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 Awake() \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 ComputeBuffers \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430. \u041c\u044b \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u0441\u043f\u0440\u0430\u0439\u0442 \u0432 \u0442\u043e\u0447\u043a\u0435 (0, 0) \u0441 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u043c 0.2f \u0438 \u0431\u0435\u0437 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430. \u0414\u043b\u044f UV \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043f\u0440\u0430\u0439\u0442 \u0432 \u043b\u0435\u0432\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0433\u043b\u0443 (\u044d\u043c\u043e\u0434\u0437\u0438 \u043f\u043e\u0446\u0435\u043b\u0443\u044f). \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0431\u0435\u043b\u044b\u0439 \u0446\u0432\u0435\u0442. \u041c\u0430\u0441\u0441\u0438\u0432\u0443 args \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 argsBuffer.<\/p>\n<p>  \u0412 Update() \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c Graphics.DrawMeshInstancedIndirect(). (\u042f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u044e \u043f\u043e\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0434\u0435\u0441\u044c BOUNDS \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.)<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 \u0448\u0430\u0433\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u0446\u0435\u043d\u044b \u0441 \u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0430\u043c\u0435\u0440\u043e\u0439. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d GameObject \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 ComputeBufferBasic. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6ad\/09e\/0ef\/6ad09e0efabcc7c1556094947fa6b12b.png\"><\/div>\n<p>  <i>\u0422\u0430-\u0434\u0430\u0430\u0430! \u0421\u043f\u0440\u0430\u0439\u0442, \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ComputeBuffer.<\/i><\/p>\n<h2>\u0415\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u0438\u043d, \u043c\u043e\u0436\u043d\u043e \u0438 \u043c\u043d\u043e\u0433\u043e<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ComputeBuffers \u043e\u0434\u0438\u043d \u0441\u043f\u0440\u0430\u0439\u0442, \u0441\u043c\u043e\u0436\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e. \u0412\u043e\u0442 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u044f\u0449\u0438\u0439 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u043c, \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u043c \u0438 \u0446\u0432\u0435\u0442\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public class ComputeBufferMultipleSprites : MonoBehaviour {     [SerializeField]     private Material material;          [SerializeField]     private float minScale = 0.15f;          [SerializeField]     private float maxScale = 0.2f;        [SerializeField]     private int count;      private Mesh mesh;          \/\/ Matrix here is a compressed transform information     \/\/ xy is the position, z is rotation, w is the scale     private ComputeBuffer transformBuffer;          \/\/ uvBuffer contains float4 values in which xy is the uv dimension and zw is the texture offset     private ComputeBuffer uvBuffer;     private ComputeBuffer colorBuffer;      private uint[] args;          private ComputeBuffer argsBuffer;      private void Awake() {         QualitySettings.vSyncCount = 0;         Application.targetFrameRate = -1;                  this.mesh = CreateQuad();                  \/\/ Prepare values         float4[] transforms = new float4[this.count];         float4[] uvs = new float4[this.count];         float4[] colors = new float4[this.count];          const float maxRotation = Mathf.PI * 2;         for (int i = 0; i &lt; this.count; ++i) {             \/\/ transform             float x = UnityEngine.Random.Range(-8f, 8f);             float y = UnityEngine.Random.Range(-4.0f, 4.0f);             float rotation = UnityEngine.Random.Range(0, maxRotation);             float scale = UnityEngine.Random.Range(this.minScale, this.maxScale);             transforms[i] = new float4(x, y, rotation, scale);                          \/\/ UV             float u = UnityEngine.Random.Range(0, 4) * 0.25f;             float v = UnityEngine.Random.Range(0, 4) * 0.25f;             uvs[i] = new float4(0.25f, 0.25f, u, v);                          \/\/ color             float r = UnityEngine.Random.Range(0f, 1.0f);             float g = UnityEngine.Random.Range(0f, 1.0f);             float b = UnityEngine.Random.Range(0f, 1.0f);             colors[i] = new float4(r, g, b, 1.0f);         }                  this.transformBuffer = new ComputeBuffer(this.count, 16);         this.transformBuffer.SetData(transforms);         int matrixBufferId = Shader.PropertyToID(&quot;transformBuffer&quot;);         this.material.SetBuffer(matrixBufferId, this.transformBuffer);                  this.uvBuffer = new ComputeBuffer(this.count, 16);         this.uvBuffer.SetData(uvs);         int uvBufferId = Shader.PropertyToID(&quot;uvBuffer&quot;);         this.material.SetBuffer(uvBufferId, this.uvBuffer);                  this.colorBuffer = new ComputeBuffer(this.count, 16);         this.colorBuffer.SetData(colors);         int colorsBufferId = Shader.PropertyToID(&quot;colorsBuffer&quot;);         this.material.SetBuffer(colorsBufferId, this.colorBuffer);          this.args = new uint[] {             6, (uint)this.count, 0, 0, 0         };         this.argsBuffer = new ComputeBuffer(1, this.args.Length * sizeof(uint), ComputeBufferType.IndirectArguments);         this.argsBuffer.SetData(this.args);     }      private static readonly Bounds BOUNDS = new Bounds(Vector2.zero, Vector3.one);      private void Update() {            \/\/ Draw         Graphics.DrawMeshInstancedIndirect(this.mesh, 0, this.material, BOUNDS, this.argsBuffer);     }      private static Mesh CreateQuad() {         \/\/ Just the same as previous code. I told you this can be refactored.     } }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u043e\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 X \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong>count<\/strong>. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u0432\u0442\u043e\u0440\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 args, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044f \u0435\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>count<\/strong>.<\/p>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c count \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u043e\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0438\u0445 \u0432\u0441\u0435\u0433\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/867\/3ce\/d0a\/8673ced0a9e85041d6dac0d3cee54858.png\"><\/div>\n<p>  <i>\u0412\u043e\u0442 10 000 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432.<\/i><\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 minScale \u0438 maxScale \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438? \u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043e\u0434 \u0441 600 000 \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0443\u043f\u0430\u043b\u0430 \u043d\u0438\u0436\u0435 60fps. \u0415\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u043d\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f?<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dd4\/cc3\/e49\/dd4cc3e49da54e6719fbbae76f89df0c.png\"><\/div>\n<p>  <i>\u042d\u0442\u043e 600 000 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/i><\/p>\n<p>  \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043b, \u0447\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0438\u0437-\u0437\u0430 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u0434\u0435\u043b\u0430\u043b minScale \u0438 maxScale \u0441\u0435\u0440\u0438\u0430\u0437\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0437\u0430\u0434\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0442\u0438\u043f\u0430 0.01 \u0438 0.02. \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u044f \u0441\u043c\u043e\u0433 \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u043f\u0440\u0438 \u0431\u043e\u043b\u0435\u0435 60fps (\u0441\u0443\u0434\u044f \u043f\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0443 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u0434 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u043d\u043e \u043a\u043e\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432? \u0412 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a45\/a64\/c8c\/a45a64c8c1879767c9f7e082010ed102.png\"><\/div>\n<p>  <i>\u041c\u0438\u043b\u043b\u0438\u043e\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432.<\/i><\/p>\n<h2>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0449\u0438\u043a<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u044f \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435. \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b: 3,7 \u0413\u0413\u0446 (4 \u044f\u0434\u0440\u0430), 16 \u0413\u0411 \u041e\u0417\u0423, Radeon RX 460. \u0412\u043e\u0442 \u0447\u0442\u043e \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/545\/b87\/a2e\/545b87a2ec0774f7dc725c77c0c2e73d.png\"><\/div>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432\u0441\u0451 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e. \u0412\u044b\u0437\u043e\u0432 Graphics.DrawMeshInstancedIndirect() \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 0 \u043c\u0441. \u0425\u043e\u0442\u044f \u044f \u043d\u0435 \u0442\u0430\u043a \u0443\u0432\u0435\u0440\u0435\u043d, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e Gfx.PresentFrame.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bb3\/e43\/929\/bb3e43929f9d19e72daeda524863bbaf.png\"><\/div>\n<p>  <\/p>\n<h2>\u041d\u0435 \u0442\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e<\/h2>\n<p>  \u0425\u043e\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u0435\u0442, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0433\u0440\u0435 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u0430\u043a. \u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432. \u0418 \u044d\u0442\u043e \u0437\u0430\u0439\u043c\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 CPU. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u044b\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 ComputeBuffers \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435. \u041f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u042f \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u044e, \u0447\u0442\u043e \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u044f \u0434\u043e\u0431\u044c\u044e\u0441\u044c \u0447\u0435\u0433\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 300 000 \u043c\u0435\u043d\u0435\u0435 \u0447\u0435\u043c \u0437\u0430 2 \u043c\u0441, \u0442\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. DOTS \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/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\/post\/496826\/\"> https:\/\/habr.com\/ru\/post\/496826\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/496826\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/867\/3ce\/d0a\/8673ced0a9e85041d6dac0d3cee54858.png\" alt=\"image\"><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0431\u0440\u043e\u0434\u0438\u0442\u0435 \u043f\u043e <a rel=\"nofollow\" href=\"https:\/\/forum.unity.com\/forums\/data-oriented-technology-stack.147\/\">\u0444\u043e\u0440\u0443\u043c\u0443<\/a> DOTS, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0442\u0430\u043c <a rel=\"nofollow\" href=\"https:\/\/forum.unity.com\/threads\/1-million-animated-sprites-at-60-fps.811116\/#post-5669068\">\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u044b<\/a> \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 60fps. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 <a rel=\"nofollow\" href=\"https:\/\/coffeebraingames.wordpress.com\/2018\/09\/30\/adding-pure-ecs-to-a-monobehaviour-based-project-a-true-story\/\">\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 DOTS<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 <a rel=\"nofollow\" href=\"https:\/\/store.steampowered.com\/app\/672630\/Academia__School_Simulator\/\">\u0438\u0433\u0440\u044b<\/a>, \u043d\u043e \u043e\u043d \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c. \u041c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0444\u043e\u0440\u043a\u043d\u0443\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 Academia. \u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441 \u043d\u0438\u043c, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b, \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u043e\u0434\u0438\u043d \u0441\u043f\u0440\u0430\u0439\u0442, \u0441\u043e\u0442\u043d\u044e, \u0437\u0430\u0442\u0435\u043c \u0442\u044b\u0441\u044f\u0447\u0438. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u0435. \u0412 \u043d\u0451\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0441\u0437\u0430\u0434\u0438 \u0432\u043f\u0435\u0440\u0451\u0434. \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0430\u043a \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u043e\u0433\u0434\u0430 \u044f \u0447\u0438\u0442\u0430\u043b \u043a\u043e\u0434, \u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041c\u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0441\u043f\u0440\u0430\u0439\u0442\u044b, \u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u044f \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b.  <\/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-301822","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301822","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=301822"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301822\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}