Rasterize¶
rasterize
¶
rasterize_triangles
¶
rasterize_triangles(vertices: array, faces: array, width: int, height: int, depth_prior: array | None = None, occlusion_truncation: float = 1e-06) -> tuple[array, array]
Rasterize projected triangles with depth-aware z-buffering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array
|
(N, 4) float32, clip-space homogeneous (x, y, z, w). |
required |
faces
|
array
|
(F, 3) int32, triangle vertex indices. |
required |
width
|
int
|
Image width in pixels. |
required |
height
|
int
|
Image height in pixels. |
required |
depth_prior
|
array | None
|
Optional (H, W) float32 depth map for occlusion culling. |
None
|
occlusion_truncation
|
float
|
Depth threshold for occlusion. |
1e-06
|
Returns:
| Name | Type | Description |
|---|---|---|
face_indices |
array
|
(H, W) int32 -- 1-indexed face ID per pixel (0 = background). |
barycentric |
array
|
(H, W, 3) float32 -- barycentric coordinates per pixel. |
interpolate
¶
interpolate
¶
Interpolate per-vertex attributes at rasterized pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attributes
|
array
|
(N, C) float32 per-vertex data (normals, UVs, colors, ...). |
required |
face_indices
|
array
|
(H, W) int32 from rasterize_triangles (1-indexed, 0=background). |
required |
barycentric
|
array
|
(H, W, 3) float32 from rasterize_triangles. |
required |
faces
|
array
|
(F, 3) int32 triangle vertex indices. |
required |
Returns:
| Type | Description |
|---|---|
array
|
(H, W, C) float32 interpolated attributes per pixel. |
rasterize
¶
Metal triangle rasterizer with z-buffering for Apple Silicon.
Port of Hunyuan3D-2.1 CUDA rasterizer to Metal via mx.fast.metal_kernel. Uses a per-pixel kernel that loops over all faces with bounding-box culling.
rasterize_triangles
¶
rasterize_triangles(vertices: array, faces: array, width: int, height: int, depth_prior: array | None = None, occlusion_truncation: float = 1e-06) -> tuple[array, array]
Rasterize projected triangles with depth-aware z-buffering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array
|
(N, 4) float32, clip-space homogeneous (x, y, z, w). |
required |
faces
|
array
|
(F, 3) int32, triangle vertex indices. |
required |
width
|
int
|
Image width in pixels. |
required |
height
|
int
|
Image height in pixels. |
required |
depth_prior
|
array | None
|
Optional (H, W) float32 depth map for occlusion culling. |
None
|
occlusion_truncation
|
float
|
Depth threshold for occlusion. |
1e-06
|
Returns:
| Name | Type | Description |
|---|---|---|
face_indices |
array
|
(H, W) int32 -- 1-indexed face ID per pixel (0 = background). |
barycentric |
array
|
(H, W, 3) float32 -- barycentric coordinates per pixel. |