Skip to content

Commit 20ae45c

Browse files
committed
made total area in triangle rasterization absolute to disable back face culling (some models might have wrong facing triangles)
1 parent 6275cdb commit 20ae45c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

triangle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func (triangle Triangle) boundingTriangle(canvas *Canvas, color color.NRGBA, per
5757
return 0, 0, 0, 0, fmt.Errorf("Triangle has 0 height")
5858
}
5959

60-
total_area := triangle.signed_triangle_area()
60+
total_area := math.Abs(triangle.signed_triangle_area()) // absolute to disable backface culling
6161
if total_area < 1 {
62-
return 0, 0, 0, 0, fmt.Errorf("Triangle area is less than 1 pixel") // backface culling + discarding triangles that cover less than a pixel // TODO: test / improve
62+
return 0, 0, 0, 0, fmt.Errorf("Triangle area is less than 1 pixel") // discarding triangles that cover less than a pixel
6363
}
6464

6565
// TODO: add canvas bounds check (via min/max with canvas bounds?)

0 commit comments

Comments
 (0)