1
0
Fork 0
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:
Miloslav Číž 2019-06-01 18:49:43 +02:00
parent 2371750e24
commit d3e3112fdd
2 changed files with 10 additions and 4 deletions

View file

@ -167,6 +167,10 @@
triangles. */ triangles. */
#endif #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 typedef int32_t S3L_Unit; /**< Units of measurement in 3D space. There is
S3L_FRACTIONS_PER_UNIT in one spatial unit. S3L_FRACTIONS_PER_UNIT in one spatial unit.
By dividing the unit into fractions we By dividing the unit into fractions we
@ -1522,7 +1526,10 @@ void S3L_drawTriangle(
p.x = x; p.x = x;
#if S3L_COMPUTE_DEPTH #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); p.depth = S3L_getFastLerpValue(depthFLS);
S3L_stepFastLerp(depthFLS); S3L_stepFastLerp(depthFLS);
#endif #endif
@ -1539,9 +1546,6 @@ void S3L_drawTriangle(
#endif #endif
#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));
*barycentric0 = *barycentric0 =
( (
S3L_interpolateFrom0(rOverZ,i,rowLength) S3L_interpolateFrom0(rOverZ,i,rowLength)

View file

@ -152,6 +152,8 @@ else
setPixel(p->x,p->y,col * 120,dep,(2 - col) * 120); 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,sss, (p->triangleID * 37) % 255 ,128);
//setPixel(p->x,p->y,p->modelID * 64,p->modelID * 128,255); //setPixel(p->x,p->y,p->modelID * 64,p->modelID * 128,255);