Beispiel #1
0
    public void Create(int chunkSize, int id, Vector2 pos)
    {
        this.pos       = pos;
        this.chunkSize = chunkSize;
        this.id        = id;

        mesh = new MeshGen(transform.position, chunkSize, 1);
        mesh.CalculateUV(100);
        mesh.CalculateNormals();

        coll = gameObject.AddComponent <MeshCollider>();

        buffer   = new ComputeBuffer(((chunkSize - 1) * (chunkSize - 1) * 6), 32);
        vertices = new ComputeBuffer(chunkSize * chunkSize, 12);

        buffer.SetData(mesh.triangles);
        vertices.SetData(mesh.vertices);

        material.SetBuffer("buffer", buffer);

        kernel_2 = compute.FindKernel("DeformVertex");
        compute.SetBuffer(kernel_2, "vertices", vertices);

        kernel = compute.FindKernel("Deform");
        compute.SetBuffer(kernel, "buffer", buffer);
    }