Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Although you've discovered that shifting your points by 0.5 makes the problem go away it's not for the reason that you think.</p> <p>The answer does indeed lie in the diamond exit rule which is also at the heart of the correctly accepted answer to <a href="https://stackoverflow.com/questions/10040961/opengl-pixel-perfect-2d-drawing">Opengl pixel perfect 2D drawing</a>.</p> <p>The diagram below shows four fragments/pixels with a diamond inscribed within each. The four coloured spots represent possible starting points for your quad/line loop i.e. the window co-ordinates of the first vertex.</p> <p><img src="https://i.stack.imgur.com/Qrcnk.png" alt="Possible vertex points outside a fragment&#39;s diamond"></p> <p>You didn't say which way you were drawing the quad but it doesn't matter. I'll assume, for argument's sake, that you are drawing it clockwise. The issue is whether the top left of the four fragments shown will be produced by rasterising either your first or last line (it cannot be both).</p> <ol> <li><p>If you start on the yellow vertex then the first line passes through the diamond and exits it as it passes horizontally to the right. The fragment will therefore be produced as a result of the first line's rasterisation.</p></li> <li><p>If you start on the green vertex then the first line exits the fragment without passing through the diamond and hence never exits the diamond. However the last line will pass through it vertically and exit it as it ascends back to the green vertex. The fragment will therefore be produced as a result of the last line's rasterisation.</p></li> <li><p>If you start on the blue vertex then the first line passes through the diamond and exits it as it passes horizontally to the right. The fragment will therefore be produced as a result of the first line's rasterisation.</p></li> <li><p>If you start on the red vertex then the first line exits the fragment without passing through the diamond and hence never exits the diamond. The last line will also not pass through the diamond and therefore not exit it as it ascends back to the red vertex. The fragment will therefore <em>not</em> be produced as a result of either line's rasterisation.</p></li> </ol> <p>Note that any vertex that is inside the diamond will automatically cause the fragment to be produced as the first line must exit the diamond (provided your quad is actually big enough to leave the diamond of course).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload