mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-21 20:39:57 +01:00
Fix z-test bug
This commit is contained in:
parent
2371750e24
commit
d3e3112fdd
2 changed files with 10 additions and 4 deletions
12
small3dlib.h
12
small3dlib.h
|
@ -167,6 +167,10 @@
|
|||
triangles. */
|
||||
#endif
|
||||
|
||||
#if S3L_PERSPECTIVE_CORRECTION
|
||||
#define S3L_COMPUTE_DEPTH 1 // PC inevitably computes depth, so enable it
|
||||
#endif
|
||||
|
||||
typedef int32_t S3L_Unit; /**< Units of measurement in 3D space. There is
|
||||
S3L_FRACTIONS_PER_UNIT in one spatial unit.
|
||||
By dividing the unit into fractions we
|
||||
|
@ -1522,7 +1526,10 @@ void S3L_drawTriangle(
|
|||
p.x = x;
|
||||
|
||||
#if S3L_COMPUTE_DEPTH
|
||||
#if S3L_PERSPECTIVE_CORRECTION != 1
|
||||
#if S3L_PERSPECTIVE_CORRECTION == 1
|
||||
p.depth = (S3L_FRACTIONS_PER_UNIT * S3L_FRACTIONS_PER_UNIT) /
|
||||
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,x - lX,rX - lX));
|
||||
#else
|
||||
p.depth = S3L_getFastLerpValue(depthFLS);
|
||||
S3L_stepFastLerp(depthFLS);
|
||||
#endif
|
||||
|
@ -1539,9 +1546,6 @@ void S3L_drawTriangle(
|
|||
#endif
|
||||
|
||||
#if S3L_PERSPECTIVE_CORRECTION == 1
|
||||
p.depth = (S3L_FRACTIONS_PER_UNIT * S3L_FRACTIONS_PER_UNIT) /
|
||||
S3L_nonZero(S3L_interpolate(lRecipZ,rRecipZ,x - lX,rX - lX));
|
||||
|
||||
*barycentric0 =
|
||||
(
|
||||
S3L_interpolateFrom0(rOverZ,i,rowLength)
|
||||
|
|
|
@ -152,6 +152,8 @@ else
|
|||
|
||||
setPixel(p->x,p->y,col * 120,dep,(2 - col) * 120);
|
||||
|
||||
// setPixel(p->x,p->y, (p->triangleID * 60) % 255, (p->triangleID * 170) % 255, (p->triangleID * 10) % 255 );
|
||||
|
||||
//setPixel(p->x,p->y,sss, (p->triangleID * 37) % 255 ,128);
|
||||
|
||||
//setPixel(p->x,p->y,p->modelID * 64,p->modelID * 128,255);
|
||||
|
|
Loading…
Reference in a new issue