public void UpdateInstanceDataBuffers(int instances, NativeArray <float4> colors, NativeArray <float4> matrixs, NativeArray <int> uvIndexs)
 {
     if (args[1] != instances)
     {
         args[1] = Users;
         ArgsBuffer.SetData(args);
     }
     if (UvIndexBuffer == null || UvIndexBuffer.count != uvIndexs.Length)
     {
         UvIndexBuffer?.Release();
         UvIndexBuffer = new ComputeBuffer(uvIndexs.Length, sizeof(int));
     }
     if (ColorsBuffer == null || ColorsBuffer.count != colors.Length)
     {
         ColorsBuffer?.Release();
         ColorsBuffer = new ComputeBuffer(colors.Length, 16);
     }
     if (MatrixsBuffer == null || MatrixsBuffer.count != matrixs.Length)
     {
         MatrixsBuffer?.Release();
         MatrixsBuffer = new ComputeBuffer(matrixs.Length, 16);
     }
     MatrixsBuffer.SetData(matrixs);
     ColorsBuffer.SetData(colors);
     UvIndexBuffer.SetData(uvIndexs);
     Material.SetBuffer("bufferIndexBuffer", UvIndexBuffer);
     Material.SetBuffer("colorsBuffer", ColorsBuffer);
     Material.SetBuffer("transformBuffer", MatrixsBuffer);
 }
예제 #2
0
    public Octree(Bounds bounds, int maxDepth = 5)
    {
        indirectArgs = new ArgsBuffer();

        int maxNodes = 0;

        for (int i = 1; i <= maxDepth; i++)
        {
            int res = 1 << i;
            maxNodes += res * res * res;
        }
        nodes = new CounterBuffer <Node>(maxNodes, 1);
        nodes.SetData(new Node[maxNodes]);

        this.bounds   = bounds;
        this.maxDepth = maxDepth;
    }
예제 #3
0
 public void CopyCount(ArgsBuffer other, int itemOffset = 0)
 {
     ComputeBuffer.CopyCount(Buffer, other.Buffer, itemOffset * other.Buffer.stride);
 }