GPU instanced objects not rendering material

I’m having trouble with GPU instanced objects. I use this script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GPUInstancing : MonoBehaviour
{
    public Mesh mesh; // Mesh to be instanced
    public Material material; // Material supporting instancing
    public int instanceCount = 500; // Number of instances
    public Vector3 areaSize = new Vector3(10, 0, 10); // Spread of instances

    private List<Matrix4x4> matrices; // Transformation matrices for instances

    void Start()
    {
        // Initialize transformation matrices
        matrices = new List<Matrix4x4>(instanceCount);
        for (int i = 0; i < instanceCount; i++)
        {
            // Random position within the specified area
            Vector3 position = new Vector3(
                Random.Range(-areaSize.x / 2, areaSize.x / 2),
                Random.Range(-areaSize.y / 2, areaSize.y / 2),
                Random.Range(-areaSize.z / 2, areaSize.z / 2)
            );

            // Random rotation and scale
            Quaternion rotation = Quaternion.Euler(0, Random.Range(0, 360), 0);
            Vector3 scale = Vector3.one;

            // Create transformation matrix
            Matrix4x4 matrix = Matrix4x4.TRS(position, rotation, scale);
            matrices.Add(matrix);
        }
        
    }

    void Update()
    {
        // Draw instances
        Graphics.DrawMeshInstanced(mesh, 0, material, matrices);
    }
}

The instanced objects does not show material. Only solid color which changes (white->gray->red->etc…) based on the viewing angle. Any ideas why it behaves like this?
ezgif-1-496afef6fd

got it working. needed to switch Graphics.RenderMeshInstanced instead of obsolete Graphics.DrawMeshInstanced

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GPUInstancing : MonoBehaviour
{
 public Mesh mesh; // The mesh to instance
    public Material material; // Material with GPU instancing enabled
    public int instanceCount = 1000; // Number of instances
    public Vector3 areaSize = new Vector3(10, 0, 10); // Spread of instances

    private Matrix4x4[] matrices; // Transformation matrices
    private Vector4[] colors; // Instance-specific colors (optional)
    private MaterialPropertyBlock propertyBlock; // Material properties for instancing

    void Start()
    {
        // Initialize transformation matrices
        matrices = new Matrix4x4[instanceCount];
        colors = new Vector4[instanceCount];
        propertyBlock = new MaterialPropertyBlock();

        for (int i = 0; i < instanceCount; i++)
        {
            // Random position within area bounds
            Vector3 position = new Vector3(
                Random.Range(-areaSize.x / 2, areaSize.x / 2),
                Random.Range(-areaSize.y / 2, areaSize.y / 2),
                Random.Range(-areaSize.z / 2, areaSize.z / 2)
            );

            // Random rotation and scale
            Quaternion rotation = Quaternion.Euler(0, Random.Range(0, 360), 0);
            Vector3 scale = Vector3.one * Random.Range(0.8f, 1.2f);

            // Generate transformation matrix
            matrices[i] = Matrix4x4.TRS(position, rotation, scale);

            // Random instance-specific color
            colors[i] = new Vector4(Random.value, Random.value, Random.value, 1.0f);
        }

        // Assign instance-specific colors to the MaterialPropertyBlock
        propertyBlock.SetVectorArray("_Color", colors);
    }

    void Update()
    {
        // Draw all instances using Graphics.RenderMeshInstanced
        RenderParams rp = new RenderParams(material);
        Graphics.RenderMeshInstanced(rp, mesh, 0, matrices);
    }
}