diff --git a/s3l.h b/s3l.h index 08e990c..9fd398c 100644 --- a/s3l.h +++ b/s3l.h @@ -1068,32 +1068,6 @@ static inline void S3L_mapCameraToScreen(S3L_Vec4 point, S3L_Camera *camera, // ^ S3L_FRACTIONS_PER_UNIT cancel out } -/* - Helper function to interpolate texture coordinates based on barycentric - coordinates. If you're going for max performance, you may want to compute - these values yourself -- some specific cases may be possible to compute - faster. -*/ - -void S3L_interpolateTexCoords( - S3L_Unit u0, - S3L_Unit v0, - S3L_Unit u1, - S3L_Unit v1, - S3L_Unit u2, - S3L_Unit v2, - S3L_PixelInfo *p, - S3L_Unit *u, - S3L_Unit *v - ) -{ - *u = (p->barycentric0 * u0 + p->barycentric1 * u1 + p->barycentric2 * u2) / - S3L_FRACTIONS_PER_UNIT; - - *v = (p->barycentric0 * v0 + p->barycentric1 * v1 + p->barycentric2 * v2) / - S3L_FRACTIONS_PER_UNIT; -} - void S3L_drawModelIndexed( const S3L_Unit coords[], const S3L_Index triangleVertexIndices[], diff --git a/testSDL.c b/testSDL.c index c0d680e..b4a0ba7 100644 --- a/testSDL.c +++ b/testSDL.c @@ -90,12 +90,17 @@ void drawPixel(S3L_PixelInfo *p) coords = tex_coords + p->triangleID * 6; - S3L_interpolateTexCoords( - coords[0] * 16,coords[1] * 16, - coords[2] * 16,coords[3] * 16, - coords[4] * 16,coords[5] * 16, - p, - &u,&v); + u = S3L_interpolateBarycentric( + coords[0] * 16, + coords[2] * 16, + coords[4] * 16, + p->barycentric0, p->barycentric1, p->barycentric2); + + v = S3L_interpolateBarycentric( + coords[1] * 16, + coords[3] * 16, + coords[5] * 16, + p->barycentric0, p->barycentric1, p->barycentric2); uint8_t col = texturePixel(u,v);