code: def get_triangle_buffer(vertices, triangles, h, w):
      """
      Args:
          vertices: 3 x nver
          triangles: 3 x ntri
          h: height
          w: width
      Returns:
          depth_buffer: height x width
      ToDo:
          whether to add x, y by 0.5? the center of the pixel?
          m3. like somewhere is wrong
      # Each triangle has 3 vertices & Each vertex has 3 coordinates x, y, z.
      # Here, the bigger the z, the fronter the point.
      """
      # initial
      depth_buffer = (
          np.zeros([h, w]) - 999999.0
      )  # + np.min(vertices[2,:]) - 999999. # set the initial z to the farest position
      triangle_buffer = (
          np.zeros_like(depth_buffer, dtype=np.int32) - 1
      )  # if -1, the pixel has no triangle correspondance
  
      ## calculate the depth(z) of each triangle
      # -m1. z = the center of shpere(through 3 vertices)
      # center3d = (vertices[:, triangles[0,:]] + vertices[:,triangles[1,:]] + vertices[:, triangles[2,:]])/3.
      # tri_depth = np.sum(center3d**2, axis = 0)
      # -m2. z = the center of z(v0, v1, v2)
      tri_depth = (
          vertices[2, triangles[0, :]]
          + vertices[2, triangles[1, :]]
          + vertices[2, triangles[2, :]]
      ) / 3.0
  
      for i in range(triangles.shape[1]):
          tri = triangles[:, i]  # 3 vertex indices
  
          # the inner bounding box
          umin = max(int(np.ceil(np.min(vertices[0, tri]))), 0)
          umax = min(int(np.floor(np.max(vertices[0, tri]))), w - 1)
  
          vmin = max(int(np.ceil(np.min(vertices[1, tri]))), 0)
          vmax = min(int(np.floor(np.max(vertices[1, tri]))), h - 1)
  
          if umax < umin or vmax < vmin:
              continue
  
          for u in range(umin, umax + 1):
              for v in range(vmin, vmax + 1):
                  # -m3. calculate the accurate depth(z) of each pixel by barycentric weights
                  # w0, w1, w2 = weightsOfpoint([u,v], vertices[:2, tri])
                  # tri_depth = w0*vertices[2,tri[0]] + w1*vertices[2,tri[1]] + w2*vertices[2,tri[2]]
                  if tri_depth[i] > depth_buffer[v, u] and isPointInTri(
                      [u, v], vertices[:2, tri]
                  ):
                      depth_buffer[v, u] = tri_depth[i]
                      triangle_buffer[v, u] = i
  
      return triangle_buffer
  
imports: import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: get_triangle_buffer(vertices, triangles, h, w) and returns: triangle_buffer