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: records the face index corresponding to the minimum depth of each pixel, and records the perspective-corrected barycentric coordinates of each vertex relative to the face recorded in . The Z-buffer used during the calculation records the minimum depth of each pixel and the index of the triangle face corresponding to that depth.
The computation process is as follows: For each triangle face in the space:
Convert the coordinates of the three vertices , , and of to the screen coordinates , , and .
Calculate the rectangular area that encloses based on , , and .
For each pixel in the rectangle, perform the following operations:
a. Calculate the center coordinates of the pixel. b. Calculate the barycentric coordinates of relative to the triangle . c. Determine whether is inside the triangle based on . If is not inside the triangle, process the next pixel in the rectangle. Otherwise, go to the next step. d. Use and , , 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 :
- If :
After all triangle patches in the space are processed according to the preceding steps, for each pixel on the screen with the size of :
- Obtain the patch index corresponding to in the Z-buffer, and set .
- Convert the coordinates of the three vertices , , and of to the screen coordinates , , and .
- Calculate the coordinates of the center point of .
- Calculate the barycentric coordinates of relative to the triangle .
- Use to calculate the perspective-corrected interpolation .
The following are the involved calculation methods:
Convert the vertex to the screen coordinates .
Barycentric coordinates of point relative to the triangle
- Calculate the directed areas , , and of triangles , , and , respectively.
- If is 0, then . Otherwise,
The directed area of the triangle formed by vertices , , and .
$$
are a = (x_2 - x_0) * (y_1 - y_0) - (x_1 - x_0) * (y_2 - y_0) $$
Calculate the depth of pixel based on the barycentric coordinates and the screen coordinates of the triangle , , and .
Calculate the depth threshold of point based on the depth map and occlusion truncation .
Determine whether the vertex is inside the triangle based on the barycentric coordinates . If , , and , the point is inside the triangle (including on the triangle edges). Otherwise, the point is not inside the triangle.
Calculate the perspective correction interpolation based on the barycentric coordinates and the coordinates of the three vertices of the triangle , , and .
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.
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]
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.
The following example is for reference only. For details, see .