[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Performs rasterization computation. It obtains the minimum depth and the corresponding face index of each pixel on the screen based on the given points and faces in the 3D space, and calculates the perspective-corrected barycentric coordinates of the face.

  • Formulas: findicesfindices records the face index corresponding to the minimum depth of each pixel, and barycentricbarycentric records the perspective-corrected barycentric coordinates of each vertex relative to the face recorded in findicesfindices. The Z-buffer used during the calculation records the minimum depth zmin(x,y)z_{\min}(x, y) of each pixel (x,y)(x, y) and the index face_idx(x,y)\text{face\_idx}(x, y) of the triangle face corresponding to that depth.

    The computation process is as follows: For each triangle face ff in the space:

    1. Convert the coordinates of the three vertices v0v_0, v1v_1, and v2v_2 of ff to the screen coordinates vs0v_{s0}, vs1v_{s1}, and vs2v_{s2}.

    2. Calculate the rectangular area that encloses ff based on vs0v_{s0}, vs1v_{s1}, and vs2v_{s2}.

    3. For each pixel vi=(xi,yi)v_i = (x_i, y_i) in the rectangle, perform the following operations:

      a. Calculate the center coordinates vcv_c of the pixel. b. Calculate the barycentric coordinates (α,β,γ)(\alpha, \beta, \gamma) of vcv_c relative to the triangle ff. c. Determine whether vcv_c is inside the triangle based on (α,β,γ)(\alpha, \beta, \gamma). If vcv_c is not inside the triangle, process the next pixel in the rectangle. Otherwise, go to the next step. d. Use (α,β,γ)(\alpha, \beta, \gamma) and vs0v_{s0}, vs1v_{s1}, vs2v_{s2} to obtain the depth value of the current pixel. e. If the depth prior is enabled, update the Z-buffer. Otherwise, go to the next step.

      • Calculate the depth threshold depth_thres using the depth prior map.
      • If depth < depth_thres, process the next pixel in the rectangle. Otherwise, go to the next step.

      f. Z-buffer update:

      • If depth<zmin(xi,yi)depth < z_{\min}(x_i, y_i):
      zmin(xi,yi)depthface_idx(xi,yi)f\quad z_{\min}(x_i, y_i) \gets \text{depth} \\ \quad \text{face\_idx}(x_i, y_i) \gets f
      • If depth=zmin(xi,yi)depth = z_{\min}(x_i, y_i):
      face_idx(xi,yi)min(face_idx(xi,yi), f)\quad \text{face\_idx}(x_i, y_i) \gets \min(\text{face\_idx}(x_i, y_i),\ f)

    After all triangle patches in the space are processed according to the preceding steps, for each pixel vi=(xi,yi)v_i = (x_i, y_i) on the screen with the size of height×widthheight \times width:

    1. Obtain the patch index fidxf_{idx} corresponding to viv_i in the Z-buffer, and set findices(xi,yi)fidxfindices (x_i, y_i) \gets f_{idx}.
    2. Convert the coordinates of the three vertices v0v_0, v1v_1, and v2v_2 of ff to the screen coordinates vs0v_{s0}, vs1v_{s1}, and vs2v_{s2}.
    3. Calculate the coordinates of the center point vcv_c of viv_i.
    4. Calculate the barycentric coordinates (α,β,γ)(\alpha, \beta, \gamma) of vcv_c relative to the triangle ff.
    5. Use (α,β,γ)(\alpha, \beta, \gamma) to calculate the perspective-corrected interpolation (α~,β~,γ~)(\tilde{\alpha}, \tilde{\beta}, \tilde{\gamma}).
    6. barycentric(xi,yi)(α~,β~,γ~)barycentric(x_i, y_i) \gets (\tilde{\alpha}, \tilde{\beta}, \tilde{\gamma})

    The following are the involved calculation methods:

    • Convert the vertex v=(x,y,z,w)v = (x, y, z, w) to the screen coordinates vs=(xs,ys,zs)v_s = (x_s, y_s, z_s).

      xs=(x/w0.5+0.5)(width1)+0.5ys=(0.5+0.5y/w)(height1)+0.5zs=z/w0.49999+0.5x_s = (x / w * 0.5 + 0.5) * (width - 1) + 0.5\\ y_s = (0.5 + 0.5 * y / w) * (height - 1) + 0.5\\ z_s = z / w * 0.49999 + 0.5
    • Barycentric coordinates (α,β,γ)(\alpha, \beta, \gamma) of point vv relative to the triangle (v0,v1,v2)(v_0, v_1, v_2)

      1. Calculate the directed areas areaarea, beta_tribeta\_tri, and gamma_trigamma\_tri of triangles (v0,v1,v2)(v_0, v_1, v_2), (v0,v,v2)(v_0, v, v_2), and (v0,v1,v)(v_0, v_1, v), respectively.
      2. If areaarea is 0, then α=β=γ=1\alpha = \beta = \gamma = -1. Otherwise,
      β=beta_tri/areaγ=gamma_tri/areaα=1βγ\beta = beta\_tri / area\\ \gamma = gamma\_tri / area\\ \alpha = 1 - \beta - \gamma
    • The directed area of the triangle formed by vertices v0=(x0,y0,z0)v_0 = (x_0, y_0, z_0), v1=(x1,y1,z1)v_1 = (x_1, y_1, z_1), and v2=(x2,y2,z2)v_2 = (x_2, y_2, z_2).

      $$

    are a = (x_2 - x_0) * (y_1 - y_0) - (x_1 - x_0) * (y_2 - y_0) $$

    • Calculate the depth depthdepth of pixel v=(x,y)v = (x, y) based on the barycentric coordinates (α,β,γ)(\alpha, \beta, \gamma) and the screen coordinates of the triangle v0=(x0,y0,z0)v_0 = (x_0, y_0, z_0), v1=(x1,y1,z1)v_1 = (x_1, y_1, z_1), and v2=(x2,y2,z2)v_2 = (x_2, y_2, z_2).

      depth=αz0+βz1+γz2depth = \alpha * z_0 + \beta * z_1 + \gamma * z_2
    • Calculate the depth threshold depth_thresdepth\_thres of point v=(x,y)v = (x, y) based on the depth map dd and occlusion truncation occlusion_truncationocclusion\_truncation.

      depth_thres=d(x,y)0.49999+0.5+occlusion_truncationdepth\_thres = d(x, y) * 0.49999 + 0.5 + occlusion\_truncation
    • Determine whether the vertex is inside the triangle based on the barycentric coordinates (α,β,γ)(\alpha, \beta, \gamma). If α>=0\alpha >= 0, β>=0\beta >= 0, and γ>=0\gamma >= 0, the point is inside the triangle (including on the triangle edges). Otherwise, the point is not inside the triangle.

    • Calculate the perspective correction interpolation (λ0corrected,λ1corrected,λ2corrected)(\lambda_0^{corrected}, \lambda_1^{corrected}, \lambda_2^{corrected}) based on the barycentric coordinates (λ0,λ1,λ2)(\lambda_0, \lambda_1, \lambda_2) and the coordinates of the three vertices of the triangle v0=(x0,y0,z0,w0)v_0 = (x_0, y_0, z_0, w_0), v1=(x1,y1,z1,w1)v_1 = (x_1, y_1, z_1, w_1), and v2=(x2,y2,z2,w2)v_2 = (x_2, y_2, z_2, w_2).

      λicorrected=λi/wi(λj/wj)\lambda_i^{corrected} = \frac{\lambda_i / w_i} { \sum (\lambda_j / w_j)}
[object Object]

Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.

[object Object]
[object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns:

    aclnnStatus: return status code. For details, see .

    The first-phase API implements input parameter validation. The following error codes may be returned.

    [object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns:

    [object Object]: status code. For details, see .

[object Object]
  • Only the scenario where useDepthPrior is 0 is supported. The parameters dOptional, occlusionTruncation, and useDepthPrior do not take effect in actual computation.

  • Deterministic computation:

    • The aclnnRasterizer is implemented in deterministic mode by default.
[object Object]

The following example is for reference only. For details, see .

[object Object]