public override void Prepare(GameObject model)
    {
        // OC camera and rendertexture
        octex = new RenderTexture(OC_RESOLUTION, OC_RESOLUTION, 16, RenderTextureFormat.ARGB32);
        octex.enableRandomWrite = true;
        octex.Create();
        occam = new GameObject("OC CAM").AddComponent <Camera>();
        occam.targetTexture = octex;
        occam.enabled       = false;

        // Collect the mesh and attribute buffers
        List <Mesh>       meshes     = new List <Mesh>();
        List <OtherAttrs> otherattrs = new List <OtherAttrs>();

        foreach (var r in model.GetComponentsInChildren <Renderer>())
        {
            MeshFilter mf = r.GetComponent <MeshFilter>();
            meshes.Add(mf.sharedMesh);
            otherattrs.Add(new OtherAttrs()
            {
                matrix = r.transform.localToWorldMatrix,
                color  = r.sharedMaterial.color
            });
        }

        // Triangle buffers
        ImportStructuredBufferMesh.ImportAllAndUnpack(meshes.ToArray(), ref attrbuff);
        otherbuff = new ComputeBuffer(otherattrs.Count, Marshal.SizeOf(typeof(OtherAttrs)), ComputeBufferType.Default);
        otherbuff.SetData(otherattrs.ToArray());

        // Compute Shader Buffers
        idaccum   = new ComputeBuffer(attrbuff.count / 3, Marshal.SizeOf(typeof(bool)));
        triappend = new ComputeBuffer(MAX_TRIANGLES, Marshal.SizeOf(typeof(uint)), ComputeBufferType.Append);

        // Compute Shader & Buffers
        compute = Resources.Load <ComputeShader>("Shaders/compute/countTris");

        compute.SetBuffer(ACCUM_KERNEL, "_idaccum", idaccum);
        compute.SetTexture(ACCUM_KERNEL, "_idTex", octex);

        compute.SetBuffer(MAP_KERNEL, "_idaccum", idaccum);
        compute.SetBuffer(MAP_KERNEL, "_triappend", triappend);

        // Material
        mat = new Material(Shader.Find("Indirect Shader Single Call"));
        mat.SetBuffer("other", otherbuff);
        mat.SetBuffer("points", attrbuff);
        mat.SetBuffer("triappend", triappend);

        idmat = new Material(Shader.Find("Indirect Shader Single Call Ids"));
        idmat.SetBuffer("other", otherbuff);
        idmat.SetBuffer("points", attrbuff);
    }
 protected override void GetBuffers(Mesh mesh, ref ComputeBuffer idxbuff, ref ComputeBuffer attrbuff, ref int count)
 {
     idxbuff = null;
     ImportStructuredBufferMesh.ImportAndUnpack(mesh, ref attrbuff);
     count = attrbuff.count;
 }
 protected virtual void GetBuffers(Mesh mesh, ref ComputeBuffer idxbuff, ref ComputeBuffer attrbuff, ref int count)
 {
     ImportStructuredBufferMesh.Import(mesh, ref idxbuff, ref attrbuff);
     count = idxbuff.count;
 }