public override Material CloneMaterial(Material src, int nth)
        {
            var instance_texture = m_world.GetInstanceTexture();

            Material m = new Material(src);

            m.SetInt("g_batch_begin", nth * m_instances_par_batch);
            m.SetTexture("g_instance_data", instance_texture);

            Vector4 ts = new Vector4(
                1.0f / instance_texture.width,
                1.0f / instance_texture.height,
                instance_texture.width,
                instance_texture.height);

            m.SetVector("g_instance_data_size", ts);

            if (m_hdr)
            {
                m.SetInt("_SrcBlend", (int)BlendMode.One);
                m.SetInt("_DstBlend", (int)BlendMode.One);
            }
            else
            {
                m.SetInt("_SrcBlend", (int)BlendMode.DstColor);
                m.SetInt("_DstBlend", (int)BlendMode.Zero);
            }

            if (m_enable_shadow)
            {
                m.EnableKeyword("ENABLE_SHADOW");
                switch (m_sample)
                {
                case Sample.Fast:
                    m.EnableKeyword("QUALITY_FAST");
                    m.DisableKeyword("QUALITY_MEDIUM");
                    m.DisableKeyword("QUALITY_HIGH");
                    break;

                case Sample.Medium:
                    m.DisableKeyword("QUALITY_FAST");
                    m.EnableKeyword("QUALITY_MEDIUM");
                    m.DisableKeyword("QUALITY_HIGH");
                    break;

                case Sample.High:
                    m.DisableKeyword("QUALITY_FAST");
                    m.DisableKeyword("QUALITY_MEDIUM");
                    m.EnableKeyword("QUALITY_HIGH");
                    break;
                }
            }
            else
            {
                m.DisableKeyword("ENABLE_SHADOW");
            }

            return(m);
        }
        public override Material CloneMaterial(Material src, int nth)
        {
            var instance_texture = m_world.GetInstanceTexture();

            Material m = new Material(src);

            m.SetInt("g_batch_begin", nth * m_instances_par_batch);
            m.SetTexture("g_instance_data", instance_texture);

            Vector4 ts = new Vector4(
                1.0f / instance_texture.width,
                1.0f / instance_texture.height,
                instance_texture.width,
                instance_texture.height);

            m.SetVector("g_instance_data_size", ts);

            // fix rendering order for transparent objects
            if (m.renderQueue >= 3000)
            {
                m.renderQueue = m.renderQueue + (nth + 1);
            }
            return(m);
        }