mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-24 21:09:57 +01:00
Expand rasterization rules
This commit is contained in:
parent
b77fbb38b2
commit
8c4809e9d9
1 changed files with 21 additions and 11 deletions
32
s3l.h
32
s3l.h
|
@ -65,19 +65,29 @@
|
||||||
|
|
||||||
Coordinates of pixels on screen start typically at the top left, from [0,0].
|
Coordinates of pixels on screen start typically at the top left, from [0,0].
|
||||||
|
|
||||||
Rasterization rules are to be the same as in OpenGL or DirectX:
|
Triangle rasterization rules are these (mostly same as OpenGL, D3D etc.):
|
||||||
|
|
||||||
- Pixel centers are at integer coordinates.
|
- Let's define:
|
||||||
- Pixel is rasterized if its center is inside the primitive (e.g. a triangle)
|
- left side: not exactly horizontal, and on the left side of triangle
|
||||||
OR
|
- top side: exactly horizontal and above the other two sides
|
||||||
if its center is exactly on the primitive's side, which is either left
|
- right side: not left side nor top side
|
||||||
(no exactly horizontal and on the left side of triangle) or top (exactly
|
- Pixel centers are at integer coordinates and triangle for drawing are
|
||||||
horizontal and above the other two edges)
|
specified with integer coordinates of pixel centers.
|
||||||
|
- A pixel is rasterized:
|
||||||
|
- if its center is inside the triangle OR
|
||||||
|
- if its center is exactly on the triangle side which is either left or top
|
||||||
|
and at the same time is not on the side that's right (case of a triangle
|
||||||
|
that's on a single line) OR
|
||||||
|
- if its center is exactly on the triangle corner of sides neither of which
|
||||||
|
is right.
|
||||||
|
|
||||||
These rules imply e.g.:
|
These rules imply among others:
|
||||||
|
|
||||||
- Triangles of points that lie on a single line are not rasterized.
|
- Adjacent triangles don't have any overlapping pixels, nor gaps between.
|
||||||
- A single "long" triangle can be rasterized as non-continuous.
|
- Triangles of points that lie on a single line are NOT rasterized.
|
||||||
|
- A single "long" triangle CAN be rasterized as non-continuous.
|
||||||
|
- Bottom most corner (or side) of a triangle is never rasterized if specified
|
||||||
|
with integer coordinates.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef S3L_H
|
#ifndef S3L_H
|
||||||
|
@ -666,7 +676,7 @@ void S3L_drawTriangle(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// triangle mode
|
// triangle mode -- TODO: maybe move to the top as this is most common?
|
||||||
|
|
||||||
S3L_ScreenCoord
|
S3L_ScreenCoord
|
||||||
tPointX, tPointY, // top triangle point coords
|
tPointX, tPointY, // top triangle point coords
|
||||||
|
|
Loading…
Reference in a new issue