11

Apologies for the following noob question, it's just I can't find a satisfactory answer anywhere...

When I render a simple axis-aligned quad made up of two triangles, I don't understand why there's never any visible artefacts on the diagonal edge where those triangles meet. Some of those pixels must be in both triangles, right? So if my fragshader always emits a partially-transparent color - 50% black say - then shouldn't there be a visible dark diagonal line in the resulting quad?

Obviously it's great that this isn't a real problem that has to be coded around, I just don't understand why it isn't. What GPU magic is it that makes this always work out?

Simon F
  • 4,241
  • 12
  • 30
Reuben Scratton
  • 213
  • 1
  • 6

1 Answers1

10

This is the same problem as discussed in What are sample gaps during scan conversion?

Briefly, rasterisation - at least with the majority of hardware systems - tests at a single 'infinitesimal' point for each pixel to determine if that pixel is inside a given triangle.

If the sample point lies exactly on an edge, then additional tie-breaking rules, often referred to as "fill rules", come in to play. Typically these will be something equivalent to, say, only consider the edge points on the top/left** edges of a triangle to be "inside".

**Other rules are available ;-)

Simon F
  • 4,241
  • 12
  • 30