Hello! We've encountered an edge case that seems to break watertightness in the rasterization step.
import torch
import drtk
device = "cuda:0"
verts = torch.tensor(
[
[0.5, 0.49993896484375, 1],
[0.5, 6.5, 1],
[6.50006103515625, 0.49993896484375, 1],
[6.50006103515625, 6.5, 1],
],
device=device
).unsqueeze(0)
tris = torch.tensor(
[
[0, 1, 2],
[3, 2, 1],
], device=device
).int()
rast_out = drtk.rasterize(verts, tris, height=8, width=8)
print(rast_out)
The resulting buffer is:
tensor([[[-1, -1, -1, -1, -1, -1, -1, -1],
[-1, 0, 0, 0, 0, 0, -1, -1],
[-1, 0, 0, 0, 0, -1, 1, -1],
[-1, 0, 0, 0, -1, 1, 1, -1],
[-1, 0, 0, -1, 1, 1, 1, -1],
[-1, 0, -1, 1, 1, 1, 1, -1],
[-1, -1, 1, 1, 1, 1, 1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1]]], device='cuda:0',
dtype=torch.int32)
Note -1s on the diagonal strip of pixels between the two triangles. Since the triangles share the edge, there should not be a holes between them. And indeed, nvdiffrast, which uses hardware rasterizer, does not produce similar artefacts.
One curious detail is if we flip one of the triangles the problem seems to go away:
tris = torch.tensor(
[
[0, 1, 2],
[3, 1, 2],
], device=device
).int()
rast_out = drtk.rasterize(verts, tris, height=8, width=8)
print(rast_out)
Output:
tensor([[[-1, -1, -1, -1, -1, -1, -1, -1],
[-1, 0, 0, 0, 0, 0, 1, -1],
[-1, 0, 0, 0, 0, 1, 1, -1],
[-1, 0, 0, 0, 1, 1, 1, -1],
[-1, 0, 0, 1, 1, 1, 1, -1],
[-1, 0, 1, 1, 1, 1, 1, -1],
[-1, 1, 1, 1, 1, 1, 1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1]]], device='cuda:0',
dtype=torch.int32)
Hello! We've encountered an edge case that seems to break watertightness in the rasterization step.
The resulting buffer is:
Note -1s on the diagonal strip of pixels between the two triangles. Since the triangles share the edge, there should not be a holes between them. And indeed, nvdiffrast, which uses hardware rasterizer, does not produce similar artefacts.
One curious detail is if we flip one of the triangles the problem seems to go away:
Output: