code: def rasterize_triangles(vertices, triangles, h, w):
      """
      Args:
          vertices: [nver, 3]
          triangles: [ntri, 3]
          h: height
          w: width
      Returns:
          depth_buffer: [h, w] saves the depth, here, the bigger the z, the fronter the point.
          triangle_buffer: [h, w] saves the tri id(-1 for no triangle).
          barycentric_weight: [h, w, 3] saves corresponding barycentric weight.
  
      # Each triangle has 3 vertices & Each vertex has 3 coordinates x, y, z.
      # h, w is the size of rendering
      """
  
      # initial
      depth_buffer = (
          np.zeros([h, w]) - 999999.0
      )  # set the initial z to the farest position
      triangle_buffer = (
          np.zeros([h, w], dtype=np.int32) - 1
      )  # if tri id = -1, the pixel has no triangle correspondance
      barycentric_weight = np.zeros([h, w, 3], dtype=np.float32)  #
  
      vertices = vertices.astype(np.float32).copy()
      triangles = triangles.astype(np.int32).copy()
  
      mesh_core_cython.rasterize_triangles_core(
          vertices,
          triangles,
          depth_buffer,
          triangle_buffer,
          barycentric_weight,
          vertices.shape[0],
          triangles.shape[0],
          h,
          w,
      )
  
file_path: insightface/python-package/insightface/thirdparty/face3d/mesh/render.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from time import time
  from .cython import mesh_core_cython
label_desc: Use image node_id 1 for calling a global function with example usage: rasterize_triangles(vertices, triangles, h, w) without return types