/*! */ void CTRGTextureLightMap2_M4::scanline_bilinear () { tVideoSample *dst; #ifdef USE_ZBUFFER fp24 *z; #endif s32 xStart; s32 xEnd; s32 dx; #ifdef SUBTEXEL f32 subPixel; #endif #ifdef IPOL_Z f32 slopeZ; #endif #ifdef IPOL_W fp24 slopeW; #endif #ifdef IPOL_C0 sVec4 slopeC; #endif #ifdef IPOL_T0 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; #endif // apply top-left fill-convention, left xStart = core::ceil32( line.x[0] ); xEnd = core::ceil32( line.x[1] ) - 1; dx = xEnd - xStart; if ( dx < 0 ) return; // slopes const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; #endif #ifdef IPOL_W slopeW = (line.w[1] - line.w[0]) * invDeltaX; #endif #ifdef IPOL_C0 slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX; #endif #ifdef IPOL_T0 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; #endif #ifdef IPOL_T1 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; #endif #ifdef SUBTEXEL subPixel = ( (f32) xStart ) - line.x[0]; #ifdef IPOL_Z line.z[0] += slopeZ * subPixel; #endif #ifdef IPOL_W line.w[0] += slopeW * subPixel; #endif #ifdef IPOL_C0 line.c[0][0] += slopeC * subPixel; #endif #ifdef IPOL_T0 line.t[0][0] += slopeT[0] * subPixel; #endif #ifdef IPOL_T1 line.t[1][0] += slopeT[1] * subPixel; #endif #endif dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; #ifdef USE_ZBUFFER z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; #endif #ifdef INVERSE_W f32 inversew; #endif tFixPoint tx0, tx1; tFixPoint ty0, ty1; tFixPoint r0, g0, b0; tFixPoint r1, g1, b1; tFixPoint r2, g2, b2; #ifdef IPOL_C0 tFixPoint r3, g3, b3; #endif for ( s32 i = 0; i <= dx; i++ ) { #ifdef CMP_Z if ( line.z[0] < z[i] ) #endif #ifdef CMP_W if ( line.w[0] >= z[i] ) #endif { #ifdef INVERSE_W inversew = fix_inverse32 ( line.w[0] ); tx0 = tofix ( line.t[0][0].x,inversew); ty0 = tofix ( line.t[0][0].y,inversew); tx1 = tofix ( line.t[1][0].x,inversew); ty1 = tofix ( line.t[1][0].y,inversew); #ifdef IPOL_C0 r3 = tofix ( line.c[0][0].y ,inversew ); g3 = tofix ( line.c[0][0].z ,inversew ); b3 = tofix ( line.c[0][0].w ,inversew ); #endif #else tx0 = tofix ( line.t[0][0].x ); ty0 = tofix ( line.t[0][0].y ); tx1 = tofix ( line.t[1][0].x ); ty1 = tofix ( line.t[1][0].y ); #ifdef IPOL_C0 r3 = tofix ( line.c[0][0].y ); g3 = tofix ( line.c[0][0].z ); b3 = tofix ( line.c[0][0].w ); #endif #endif getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); #ifdef IPOL_C0 r2 = imulFix ( r0, r3 ); g2 = imulFix ( g0, g3 ); b2 = imulFix ( b0, b3 ); r2 = clampfix_maxcolor ( imulFix_tex4 ( r2, r1 ) ); g2 = clampfix_maxcolor ( imulFix_tex4 ( g2, g1 ) ); b2 = clampfix_maxcolor ( imulFix_tex4 ( b2, b1 ) ); /* r2 = r3 << 8; g2 = g3 << 8; b2 = b3 << 8; */ #else r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); #endif dst[i] = fix_to_color ( r2, g2, b2 ); #ifdef WRITE_Z z[i] = line.z[0]; #endif #ifdef WRITE_W z[i] = line.w[0]; #endif } #ifdef IPOL_Z line.z[0] += slopeZ; #endif #ifdef IPOL_W line.w[0] += slopeW; #endif #ifdef IPOL_C0 line.c[0][0] += slopeC; #endif #ifdef IPOL_T0 line.t[0][0] += slopeT[0]; #endif #ifdef IPOL_T1 line.t[1][0] += slopeT[1]; #endif } }
/*! */ void CTRTextureBlend::scanline_bilinear () { tVideoSample *dst; #ifdef USE_ZBUFFER fp24 *z; #endif s32 xStart; s32 xEnd; s32 dx; #ifdef SUBTEXEL f32 subPixel; #endif #ifdef IPOL_Z f32 slopeZ; #endif #ifdef IPOL_W fp24 slopeW; #endif #ifdef IPOL_C0 sVec4 slopeC; #endif #ifdef IPOL_T0 sVec2 slopeT0; #endif #ifdef IPOL_T1 sVec2 slopeT1; #endif // apply top-left fill-convention, left xStart = core::ceil32( line.x[0] ); xEnd = core::ceil32( line.x[1] ) - 1; dx = xEnd - xStart; if ( dx < 0 ) return; // slopes const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; #endif #ifdef IPOL_W slopeW = (line.w[1] - line.w[0]) * invDeltaX; #endif #ifdef IPOL_C0 slopeC = (line.c[1] - line.c[0]) * invDeltaX; #endif #ifdef IPOL_T0 slopeT0 = (line.t0[1] - line.t0[0]) * invDeltaX; #endif #ifdef IPOL_T1 slopeT1 = (line.t1[1] - line.t1[0]) * invDeltaX; #endif #ifdef SUBTEXEL subPixel = ( (f32) xStart ) - line.x[0]; #ifdef IPOL_Z line.z[0] += slopeZ * subPixel; #endif #ifdef IPOL_W line.w[0] += slopeW * subPixel; #endif #ifdef IPOL_C0 line.c[0] += slopeC * subPixel; #endif #ifdef IPOL_T0 line.t0[0] += slopeT0 * subPixel; #endif #ifdef IPOL_T1 line.t1[0] += slopeT1 * subPixel; #endif #endif dst = lockedSurface + ( line.y * SurfaceWidth ) + xStart; #ifdef USE_ZBUFFER z = lockedZBuffer + ( line.y * SurfaceWidth ) + xStart; #endif f32 inversew = FIX_POINT_F32_MUL; tFixPoint r0, g0, b0; tFixPoint r1, g1, b1; s32 i; switch ( ZCompare ) { case 1: for ( i = 0; i <= dx; ++i ) { #ifdef CMP_W if ( line.w[0] >= z[i] ) #endif { #ifdef WRITE_W z[i] = line.w[0]; #endif #ifdef INVERSEW inversew = fix_inverse32 ( line.w[0] ); #endif getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); color_to_fix ( r1, g1, b1, dst[i] ); dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) ); } #ifdef IPOL_W line.w[0] += slopeW; #endif #ifdef IPOL_T0 line.t0[0] += slopeT0; #endif } break; case 2: for ( i = 0; i <= dx; ++i ) { #ifdef CMP_W if ( line.w[0] == z[i] ) #endif { #ifdef WRITE_W z[i] = line.w[0]; #endif #ifdef INVERSEW inversew = fix_inverse32 ( line.w[0] ); #endif getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) ); color_to_fix ( r1, g1, b1, dst[i] ); dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ), clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ), clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ) ); } #ifdef IPOL_W line.w[0] += slopeW; #endif #ifdef IPOL_T0 line.t0[0] += slopeT0; #endif }break; } // zcompare }