コード例 #1
0
ファイル: CTRTextureGouraud2.cpp プロジェクト: Aeshylus/Test
/*!
*/
void CTRTextureGouraud2::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;
	tFixPoint ty0;

	tFixPoint r0, g0, b0;

#ifdef IPOL_C0
	tFixPoint r1, g1, b1;
#endif

#ifdef BURNINGVIDEO_RENDERER_FAST
	u32 dIndex = ( line.y & 3 ) << 2;
#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 WRITE_Z
			z[i] = line.z[0];
#endif
#ifdef WRITE_W
			z[i] = line.w[0];
#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);

#ifdef IPOL_C0
			r1 = tofix ( line.c[0][0].y ,inversew );
			g1 = tofix ( line.c[0][0].z ,inversew );
			b1 = tofix ( line.c[0][0].w ,inversew );
#endif

#else
			tx0 = tofix ( line.t[0][0].x );
			ty0 = tofix ( line.t[0][0].y );
#ifdef IPOL_C0
			getTexel_plain2 ( r1, g1, b1, line.c[0][0] );
#endif
#endif

#ifdef IPOL_C0
			getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );

			dst[i] = fix_to_color ( imulFix ( r0, r1 ),
									imulFix ( g0, g1 ),
									imulFix ( b0, b1 )
								);
#else

#ifdef BURNINGVIDEO_RENDERER_FAST
			const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
			dst[i] = getTexel_plain ( &IT[0], d + tx0, d + ty0 );
#else
			getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
			dst[i] = fix_to_color ( r0, g0, b0 );
#endif

#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
	}

}
コード例 #2
0
/*!
*/
REALINLINE void CTRTextureLightMap2_Add::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




#ifdef BURNINGVIDEO_RENDERER_FAST
	u32 dIndex = ( line.y & 3 ) << 2;


#else
	// 
	tFixPoint r0, g0, b0;
	tFixPoint r1, g1, b1;
#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 WRITE_Z
			z[i] = line.z[0];
#endif
#ifdef WRITE_W
			z[i] = line.w[0];
#endif

#ifdef BURNINGVIDEO_RENDERER_FAST

#ifdef INVERSE_W

			const f32 inversew = fix_inverse32 ( line.w[0] );

			const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];

			dst[i] = PixelAdd32 (
					getTexel_plain ( &IT[0],	d + f32_to_fixPoint ( line.t0[0].x,inversew), 
												d + f32_to_fixPoint ( line.t0[0].y,inversew) ),
					getTexel_plain ( &IT[1],	d + f32_to_fixPoint ( line.t1[0].x,inversew), 
												d + f32_to_fixPoint ( line.t1[0].y,inversew) )
							);
#else
			const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];

			dst[i] = PixelAdd32 (
					getTexel_plain ( &IT[0],	d + f32_to_fixPoint ( line.t0[0].x), 
												d + f32_to_fixPoint ( line.t0[0].y) ),
					getTexel_plain ( &IT[1],	d + f32_to_fixPoint ( line.t1[0].x), 
												d + f32_to_fixPoint ( line.t1[0].y) )
							);

#endif

#else
			const f32 inversew = fix_inverse32 ( line.w[0] );

			getSample_texture ( r0, g0, b0, &IT[0], f32_to_fixPoint ( line.t0[0].x,inversew), f32_to_fixPoint ( line.t0[0].y,inversew) );
			getSample_texture ( r1, g1, b1, &IT[1], f32_to_fixPoint ( line.t0[1].x,inversew), f32_to_fixPoint ( line.t0[1].y,inversew) );

			dst[i] = fix_to_color ( clampfix_maxcolor ( r0 + r1 ),
									clampfix_maxcolor ( g0 + g1 ),
									clampfix_maxcolor ( b0 + b1 )
								);
#endif

		}

#ifdef IPOL_Z
		line.z[0] += slopeZ;
#endif
#ifdef IPOL_W
		line.w[0] += slopeW;
#endif
#ifdef IPOL_C0
		line.c[0] += slopeC;
#endif
#ifdef IPOL_T0
		line.t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
		line.t1[0] += slopeT1;
#endif
	}

}
コード例 #3
0
/*!
*/
void CTRTextureVertexAlpha2::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->getData() + ( line.y * RenderTarget->getDimension().Width ) + xStart;

#ifdef USE_ZBUFFER
	z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
#endif


	f32 inversew = FIX_POINT_F32_MUL;

//#define __TEST_THIS

#ifdef __TEST_THIS

#else
	tFixPoint tx0;
	tFixPoint ty0;

	tFixPoint r0, g0, b0;
	tFixPoint r1, g1, b1;
	tFixPoint r2, g2, b2;
#endif


#ifdef IPOL_C0
	tFixPoint a3;
#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 __TEST_THIS

			inversew = fix_inverse32 ( line.w[0] );

			dst[i] = PixelAdd32 (
						dst[i],
					getTexel_plain ( &IT[0],	tofix ( line.t[0][0].x,inversew),
												tofix ( line.t[0][0].y,inversew) )
												  );

#else

#ifdef INVERSE_W
			inversew = fix_inverse32 ( line.w[0] );
#endif
			tx0 = tofix ( line.t[0][0].x,inversew);
			ty0 = tofix ( line.t[0][0].y,inversew);

#ifdef IPOL_C0
			a3 = tofix ( line.c[0][0].y,inversew );
#endif

			getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
			color_to_fix ( r1, g1, b1, dst[i] );

#ifdef IPOL_C0
			r2 = clampfix_maxcolor ( r1 + imulFix ( r0, a3 ) );
			g2 = clampfix_maxcolor ( g1 + imulFix ( g0, a3 ) );
			b2 = clampfix_maxcolor ( b1 + imulFix ( b0, a3 ) );
#else
			r2 = clampfix_maxcolor ( r1 + r0 );
			g2 = clampfix_maxcolor ( g1 + g0 );
			b2 = clampfix_maxcolor ( b1 + b0 );
#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
#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
	}

}
コード例 #4
0
/*!
*/
void CTRGouraudAlpha2::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[0];
#endif
#ifdef IPOL_T1
	sVec2 slopeT[1];
#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 IPOL_C0

#ifdef INVERSE_W
	f32 inversew;
#endif

	tFixPoint a0;
	tFixPoint r0, g0, b0;
	tFixPoint r1, g1, b1;
	tFixPoint r2, g2, b2;
#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 IPOL_C0
#ifdef INVERSE_W
			inversew = core::reciprocal ( line.w[0] );

			getSample_color ( a0, r0, g0, b0, line.c[0][0] * inversew );
#else
			getSample_color ( a0, r0, g0, b0, line.c[0][0] );
#endif

			color_to_fix ( r1, g1, b1, dst[i] );

			r2 = r1 + imulFix ( a0, r0 - r1 );
			g2 = g1 + imulFix ( a0, g0 - g1 );
			b2 = b1 + imulFix ( a0, b0 - b1 );

			dst[i] = fix_to_color ( r2, g2, b2 );
#else
			dst[i] = COLOR_BRIGHT_WHITE;
#endif
#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
	}

}
コード例 #5
0
/*!
*/
void CTRTextureVertexAlpha2::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


#ifdef INVERSE_W
    f32 inversew;
#endif

//#define __TEST_THIS

#ifdef __TEST_THIS

#else
    tFixPoint tx0;
    tFixPoint ty0;

    tFixPoint r0, g0, b0;
    tFixPoint r1, g1, b1;
    tFixPoint r2, g2, b2;
#endif


#ifdef IPOL_C0
    tFixPoint a3;
#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 __TEST_THIS

                inversew = fix_inverse32 ( line.w[0] );

                dst[i] = PixelAdd32 (
                             dst[i],
                             getTexel_plain ( &IT[0],	f32_to_fixPoint ( line.t0[0].x,inversew),
                                              f32_to_fixPoint ( line.t0[0].y,inversew) )
                         );

#else

#ifdef INVERSE_W
                inversew = fix_inverse32 ( line.w[0] );

                tx0 = f32_to_fixPoint ( line.t0[0].x,inversew);
                ty0 = f32_to_fixPoint ( line.t0[0].y,inversew);

#ifdef IPOL_C0
                a3 = f32_to_fixPoint ( line.c[0].y,inversew );
#endif

#else
                tx0 = f32_to_fixPoint ( line.t0[0].x );
                ty0 = f32_to_fixPoint ( line.t0[0].y );

#ifdef IPOL_C0
                a3 = f32_to_fixPoint ( line.c[0].y );
#endif


#endif

                getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
                color_to_fix ( r1, g1, b1, dst[i] );

#ifdef IPOL_C0
                r2 = clampfix_maxcolor ( r1 + imulFix ( r0, a3 ) );
                g2 = clampfix_maxcolor ( g1 + imulFix ( g0, a3 ) );
                b2 = clampfix_maxcolor ( b1 + imulFix ( b0, a3 ) );
#else
                r2 = clampfix_maxcolor ( r1 + r0 );
                g2 = clampfix_maxcolor ( g1 + g0 );
                b2 = clampfix_maxcolor ( b1 + b0 );
#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
#endif
            }

#ifdef IPOL_Z
        line.z[0] += slopeZ;
#endif
#ifdef IPOL_W
        line.w[0] += slopeW;
#endif
#ifdef IPOL_C0
        line.c[0] += slopeC;
#endif
#ifdef IPOL_T0
        line.t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
        line.t1[0] += slopeT1;
#endif
    }

}
コード例 #6
0
/*!
*/
void CTRTextureDetailMap2::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;


	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);

#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 );
#endif
			getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
			getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 );

			// bias half color
			r1 += -FIX_POINT_HALF_COLOR;
			g1 += -FIX_POINT_HALF_COLOR;
			b1 += -FIX_POINT_HALF_COLOR;

			r2 = clampfix_mincolor ( clampfix_maxcolor ( r0 + r1 ) );
			g2 = clampfix_mincolor ( clampfix_maxcolor ( g0 + g1 ) );
			b2 = clampfix_mincolor ( clampfix_maxcolor ( b0 + b1 ) );

			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
	}

}
コード例 #7
0
/*!
*/
void CTRTextureLightMap2_M4::scanline_bilinear ( sScanLineData * data ) const
{
	tVideoSample *dst;

#ifdef USE_Z
	TZBufferType2 *z;
#endif

	s32 xStart;
	s32 xEnd;
	s32 dx;

	f32 invDeltaX;

#ifdef SUBTEXEL
	f32 subPixel;
#endif

#ifdef IPOL_Z
	f32 slopeZ;
#endif
#ifdef IPOL_W
	f32 slopeW;
#endif
#ifdef IPOL_C
	sVec4 slopeC;
#endif
#ifdef IPOL_T0
	sVec2 slopeT0;
#endif
#ifdef IPOL_T1
	sVec2 slopeT1;
#endif

	// apply top-left fill-convention, left
	xStart = irr::core::ceil32( data->x[0] );
	xEnd = irr::core::ceil32( data->x[1] ) - 1;

	dx = xEnd - xStart;

	if ( dx < 0 )
		return;

	// slopes
	invDeltaX = data->x[1] - data->x[0];
	invDeltaX = inverse32 ( invDeltaX );

#ifdef IPOL_Z
	slopeZ = (data->z[1] - data->z[0]) * invDeltaX;
#endif
#ifdef IPOL_W
	slopeW = (data->w[1] - data->w[0]) * invDeltaX;
#endif
#ifdef IPOL_C
	slopeC = (data->c[1] - data->c[0]) * invDeltaX;
#endif
#ifdef IPOL_T0
	slopeT0 = (data->t0[1] - data->t0[0]) * invDeltaX;
#endif
#ifdef IPOL_T1
	slopeT1 = (data->t1[1] - data->t1[0]) * invDeltaX;
#endif

#ifdef SUBTEXEL
	subPixel = ( (f32) xStart ) - data->x[0];
#ifdef IPOL_Z
	data->z[0] += slopeZ * subPixel;
#endif
#ifdef IPOL_W
	data->w[0] += slopeW * subPixel;
#endif
#ifdef IPOL_C
	data->c[0] += slopeC * subPixel;
#endif
#ifdef IPOL_T0
	data->t0[0] += slopeT0 * subPixel;
#endif
#ifdef IPOL_T1
	data->t1[0] += slopeT1 * subPixel;
#endif
#endif

	dst = lockedSurface + ( data->y * SurfaceWidth ) + xStart;

#ifdef USE_Z
	z = lockedZBuffer + ( data->y * SurfaceWidth ) + 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_C
	tFixPoint r3, g3, b3;
#endif

	for ( s32 i = 0; i <= dx; i++ )
	{
#ifdef CMP_Z
		if ( data->z[0] < z[i] )
#endif
#ifdef CMP_W
		if ( data->w[0] > z[i] )
#endif
		{
#ifdef INVERSE_W
			inversew = fix_inverse32 ( data->w[0] );

			tx0 = f32_to_fixPoint ( data->t0[0].x,inversew);
			ty0 = f32_to_fixPoint ( data->t0[0].y,inversew);
			tx1 = f32_to_fixPoint ( data->t1[0].x,inversew);
			ty1 = f32_to_fixPoint ( data->t1[0].y,inversew);

#ifdef IPOL_C
			r3 = f32_to_fixPoint ( data->c[0].y ,inversew );
			g3 = f32_to_fixPoint ( data->c[0].z ,inversew );
			b3 = f32_to_fixPoint ( data->c[0].w ,inversew );
#endif

#else
			tx0 = f32_to_fixPoint ( data->t0[0].x );
			ty0 = f32_to_fixPoint ( data->t0[0].y );
			tx1 = f32_to_fixPoint ( data->t1[0].x );
			ty1 = f32_to_fixPoint ( data->t1[0].y );

#endif
			getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
			getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 );

#ifdef IPOL_C
			r2 = imulFix ( r0, r3 );
			g2 = imulFix ( g0, g3 );
			b2 = imulFix ( b0, b3 );

			r2 = clampfix_maxcolor ( imulFix3 ( r2, r1 ) );
			g2 = clampfix_maxcolor ( imulFix3 ( g2, g1 ) );
			b2 = clampfix_maxcolor ( imulFix3 ( b2, b1 ) );
/*
			r2 = r3 << 8;
			g2 = g3 << 8;
			b2 = b3 << 8;
*/
#else
			r2 = clampfix_maxcolor ( imulFix3 ( r0, r1 ) );
			g2 = clampfix_maxcolor ( imulFix3 ( g0, g1 ) );
			b2 = clampfix_maxcolor ( imulFix3 ( b0, b1 ) );
#endif


			dst[i] = fix_to_color ( r2, g2, b2 );

#ifdef WRITE_Z
			z[i] = data->z[0];
#endif
#ifdef WRITE_W
			z[i] = data->w[0];
#endif
		}

#ifdef IPOL_Z
		data->z[0] += slopeZ;
#endif
#ifdef IPOL_W
		data->w[0] += slopeW;
#endif
#ifdef IPOL_C
		data->c[0] += slopeC;
#endif
#ifdef IPOL_T0
		data->t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
		data->t1[0] += slopeT1;
#endif
	}

}
コード例 #8
0
ファイル: CTRGouraud2.cpp プロジェクト: John-He-928/krkrz
/*!
*/
void CTRGouraud2::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



#ifdef IPOL_C0
	tFixPoint r0, g0, b0;

#ifdef INVERSE_W
	f32 inversew;
#endif

#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 IPOL_C0
#ifdef INVERSE_W
			inversew = core::reciprocal ( line.w[0] );

			getSample_color ( r0, g0, b0, line.c[0] * inversew );
#else
			getSample_color ( r0, g0, b0, line.c[0] );
#endif

			dst[i] = fix_to_color ( r0, g0, b0 );
#else
			dst[i] = COLOR_BRIGHT_WHITE;
#endif

#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] += slopeC;
#endif
#ifdef IPOL_T0
		line.t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
		line.t1[0] += slopeT1;
#endif
	}

}
コード例 #9
0
/*!
*/
inline void CTRTextureGouraud2::scanline_bilinear ( sScanLineData * data ) const
{
	tVideoSample *dst;

#ifdef IPOL_Z
	TZBufferType2 *z;
#endif

	s32 xStart;
	s32 xEnd;
	s32 dx;

	f32 invDeltaX;

#ifdef SUBTEXEL
	f32 subPixel;
#endif

#ifdef IPOL_Z
	f32 slopeZ;
#endif
#ifdef IPOL_W
	f32 slopeW;
#endif
#ifdef IPOL_C
	sVec4 slopeC;
#endif
#ifdef IPOL_T0
	sVec2 slopeT0;
#endif
#ifdef IPOL_T1
	sVec2 slopeT1;
#endif

	// apply top-left fill-convention, left
	xStart = ceil32( data->x[0] );
	xEnd = ceil32( data->x[1] ) - 1;

	dx = xEnd - xStart;

	if ( dx < 0 )
		return;

	// slopes
	invDeltaX = data->x[1] - data->x[0];
	invDeltaX = inverse32 ( invDeltaX );

#ifdef IPOL_Z
	slopeZ = (data->z[1] - data->z[0]) * invDeltaX;
#endif
#ifdef IPOL_W
	slopeW = (data->w[1] - data->w[0]) * invDeltaX;
#endif
#ifdef IPOL_C
	slopeC = (data->c[1] - data->c[0]) * invDeltaX;
#endif
#ifdef IPOL_T0
	slopeT0 = (data->t0[1] - data->t0[0]) * invDeltaX;
#endif
#ifdef IPOL_T1
	slopeT1 = (data->t1[1] - data->t1[0]) * invDeltaX;
#endif

#ifdef SUBTEXEL
	subPixel = ( (f32) xStart ) - data->x[0];
#ifdef IPOL_Z
	data->z[0] += slopeZ * subPixel;
#endif
#ifdef IPOL_W
	data->w[0] += slopeW * subPixel;
#endif
#ifdef IPOL_C
	data->c[0] += slopeC * subPixel;
#endif
#ifdef IPOL_T0
	data->t0[0] += slopeT0 * subPixel;
#endif
#ifdef IPOL_T1
	data->t1[0] += slopeT1 * subPixel;
#endif
#endif

	dst = lockedSurface + ( data->y * SurfaceWidth ) + xStart;

#ifdef IPOL_Z
	z = lockedZBuffer + ( data->y * SurfaceWidth ) + xStart;
#endif


#ifdef IPOL_W
	f32 inversew;
#endif

	tFixPoint tx0;
	tFixPoint ty0;

	tFixPoint r0, g0, b0;
#ifdef IPOL_C
	tFixPoint r1, g1, b1;
	tFixPoint r2, g2, b2;
#endif

	for ( s32 i = 0; i <= dx; ++i )
	{
#ifdef CMP_Z
		if ( data->z[0] < z[i] )
#endif
		{
#ifdef IPOL_W
			inversew = inverse32 ( data->w[0] );

			tx0 = f32_to_fixPoint ( data->t0[0].x * inversew);
			ty0 = f32_to_fixPoint ( data->t0[0].y * inversew);
#ifdef IPOL_C
			getSample_plain ( r1, g1, b1, data->c[0] * inversew );
#endif
#else
			tx0 = f32_to_fixPoint ( data->t0[0].x );
			ty0 = f32_to_fixPoint ( data->t0[0].y );
#ifdef IPOL_C
			getSample_plain ( r1, g1, b1, data->c[0] );
#endif
#endif

#ifdef IPOL_C
			getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );

			r2 = imulFix ( r0, r1 );
			g2 = imulFix ( g0, g1 );
			b2 = imulFix ( b0, b1 );

			dst[i] = fix_to_color ( r2, g2, b2 );
#else
			getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
			dst[i] = fix_to_color ( r0, g0, b0 );
#endif

#ifdef WRITE_Z
			z[i] = data->z[0];
#endif
		}

#ifdef IPOL_Z
		data->z[0] += slopeZ;
#endif
#ifdef IPOL_W
		data->w[0] += slopeW;
#endif
#ifdef IPOL_C
		data->c[0] += slopeC;
#endif
#ifdef IPOL_T0
		data->t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
		data->t1[0] += slopeT1;
#endif
	}

}
コード例 #10
0
/*!
*/
void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
{
	
	int pitch0 = RenderTarget->getDimension().Width << VIDEO_SAMPLE_GRANULARITY;
	int pitch1 = RenderTarget->getDimension().Width << 2;

	int aposx = (int) a->Pos.x;
	int aposy = (int) a->Pos.y;
	int bposx = (int) b->Pos.x;
	int bposy = (int) b->Pos.y;

	int dx = bposx - aposx;
	int dy = bposy - aposy;

	int c;
	int m;
	int d = 0;
	int run;

	tVideoSample *dst;
#ifdef USE_ZBUFFER
	fp24 *z;
#endif

	int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY;
	int yInc0 = pitch0;

	int xInc1 = 4;
	int yInc1 = pitch1;

	tVideoSample color;

#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
	tFixPoint r0, g0, b0;
	getSample_color ( r0, g0, b0, a->Color[0] );
	color = fix_to_color ( r0, g0, b0 );
#else
	color = (tVideoSample) 0xFFFFFFFF;
#endif

	if ( dx < 0 )
	{
		xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY);
		xInc1 = -4;
		dx = -dx;
	}

	if ( dy > dx )
	{
		swap_xor ( dx, dy );
		swap_xor ( xInc0, yInc0 );
		swap_xor ( xInc1, yInc1 );
	}

	if ( 0 == dx )
		return;

	dst = (tVideoSample*) ( (u8*) lockedSurface + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) );
#ifdef USE_ZBUFFER
	z = (fp24*) ( (u8*) lockedDepthBuffer + ( aposy * pitch1 ) + (aposx << 2 ) );
#endif

	c = dx << 1;
	m = dy << 1;

#ifdef IPOL_Z
	f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx);
	f32 dataZ = a->Pos.z;
#endif

#ifdef IPOL_W
	fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx );
	fp24 dataW = a->Pos.w;
#endif

	run = dx;
	while ( run )
	{
#ifdef CMP_Z
		if ( *z >= dataZ )
#endif
#ifdef CMP_W
		if ( dataW >= *z )
#endif
		{
#ifdef WRITE_Z
			*z = dataZ;
#endif
#ifdef WRITE_W
			*z = dataW;
#endif

		*dst = color;

		}

		dst = (tVideoSample*) ( (u8*) dst + xInc0 );	// x += xInc
#ifdef IPOL_Z
		z = (fp24*) ( (u8*) z + xInc1 );
#endif
#ifdef IPOL_W
		z = (fp24*) ( (u8*) z + xInc1 );
#endif

		d += m;
		if ( d > dx )
		{
			dst = (tVideoSample*) ( (u8*) dst + yInc0 );	// y += yInc
#ifdef IPOL_Z
			z = (fp24*) ( (u8*) z + yInc1 );
#endif
#ifdef IPOL_W
			z = (fp24*) ( (u8*) z + yInc1 );
#endif

			d -= c;
		}
		run -= 1;
#ifdef IPOL_Z
		dataZ += slopeZ;
#endif
#ifdef IPOL_W
		dataW += slopeW;
#endif

	}

}
コード例 #11
0
/*!
*/
void CTRGouraudAlpha2::scanline_bilinear ( sScanLineData * data ) const
{
	tVideoSample *dst;

#ifdef USE_Z
	TZBufferType2 *z;
#endif

	s32 xStart;
	s32 xEnd;
	s32 dx;

	f32 invDeltaX;

#ifdef SUBTEXEL
	f32 subPixel;
#endif

#ifdef IPOL_Z
	f32 slopeZ;
#endif
#ifdef IPOL_W
	f32 slopeW;
#endif
#ifdef IPOL_C
	sVec4 slopeC;
#endif
#ifdef IPOL_T0
	sVec2 slopeT0;
#endif
#ifdef IPOL_T1
	sVec2 slopeT1;
#endif

	// apply top-left fill-convention, left
	xStart = irr::core::ceil32( data->x[0] );
	xEnd = irr::core::ceil32( data->x[1] ) - 1;

	dx = xEnd - xStart;

	if ( dx < 0 )
		return;

	// slopes
	invDeltaX = data->x[1] - data->x[0];
	invDeltaX = inverse32 ( invDeltaX );

#ifdef IPOL_Z
	slopeZ = (data->z[1] - data->z[0]) * invDeltaX;
#endif
#ifdef IPOL_W
	slopeW = (data->w[1] - data->w[0]) * invDeltaX;
#endif
#ifdef IPOL_C
	slopeC = (data->c[1] - data->c[0]) * invDeltaX;
#endif
#ifdef IPOL_T0
	slopeT0 = (data->t0[1] - data->t0[0]) * invDeltaX;
#endif
#ifdef IPOL_T1
	slopeT1 = (data->t1[1] - data->t1[0]) * invDeltaX;
#endif

#ifdef SUBTEXEL
	subPixel = ( (f32) xStart ) - data->x[0];
#ifdef IPOL_Z
	data->z[0] += slopeZ * subPixel;
#endif
#ifdef IPOL_W
	data->w[0] += slopeW * subPixel;
#endif
#ifdef IPOL_C
	data->c[0] += slopeC * subPixel;
#endif
#ifdef IPOL_T0
	data->t0[0] += slopeT0 * subPixel;
#endif
#ifdef IPOL_T1
	data->t1[0] += slopeT1 * subPixel;
#endif
#endif

	dst = lockedSurface + ( data->y * SurfaceWidth ) + xStart;

#ifdef USE_Z
	z = lockedZBuffer + ( data->y * SurfaceWidth ) + xStart;
#endif


#ifdef INVERSE_W
	f32 inversew;
#endif


	tFixPoint a0;
	tFixPoint r0, g0, b0;
	tFixPoint r1, g1, b1;
	tFixPoint r2, g2, b2;


	for ( s32 i = 0; i <= dx; ++i )
	{
#ifdef CMP_Z
		if ( data->z[0] < z[i] )
#endif
#ifdef CMP_W
		if ( data->w[0] > z[i] )
#endif

		{
#ifdef INVERSE_W
			inversew = inverse32 ( data->w[0] );

			getSample_color ( a0, r0, g0, b0, data->c[0] * inversew );
#else
			getSample_color ( a0, r0, g0, b0, data->c[0] );
#endif

			color_to_fix ( r1, g1, b1, dst[i] );

			r2 = r1 + imulFix ( a0, r0 - r1 );
			g2 = g1 + imulFix ( a0, g0 - g1 );
			b2 = b1 + imulFix ( a0, b0 - b1 );

			dst[i] = fix_to_color ( r2, g2, b2 );

#ifdef WRITE_Z
			z[i] = data->z[0];
#endif
#ifdef WRITE_W
			z[i] = data->w[0];
#endif

		}

#ifdef IPOL_Z
		data->z[0] += slopeZ;
#endif
#ifdef IPOL_W
		data->w[0] += slopeW;
#endif
#ifdef IPOL_C
		data->c[0] += slopeC;
#endif
#ifdef IPOL_T0
		data->t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
		data->t1[0] += slopeT1;
#endif
	}

}
コード例 #12
0
/*!
*/
void CTRTextureDetailMap2::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


#ifdef INVERSE_W
    f32 inversew;
#endif

    tFixPoint tx0, tx1;
    tFixPoint ty0, ty1;

    tFixPoint r0, g0, b0;
    tFixPoint r1, g1, b1;
    tFixPoint r2, g2, b2;


    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 = f32_to_fixPoint ( line.t0[0].x,inversew);
                ty0 = f32_to_fixPoint ( line.t0[0].y,inversew);
                tx1 = f32_to_fixPoint ( line.t1[0].x,inversew);
                ty1 = f32_to_fixPoint ( line.t1[0].y,inversew);

#else
                tx0 = f32_to_fixPoint ( line.t0[0].x );
                ty0 = f32_to_fixPoint ( line.t0[0].y );
                tx1 = f32_to_fixPoint ( line.t1[0].x );
                ty1 = f32_to_fixPoint ( line.t1[0].y );
#endif
                getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
                getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 );

#define FIX_POINT_HALF_COLOR ( (tFixPoint) ( ((f32) COLOR_MAX / 2.f * FIX_POINT_F32_MUL ) ) )

                // bias half color
                r1 += -FIX_POINT_HALF_COLOR;
                g1 += -FIX_POINT_HALF_COLOR;
                b1 += -FIX_POINT_HALF_COLOR;

                r2 = clampfix_mincolor ( clampfix_maxcolor ( r0 + r1 ) );
                g2 = clampfix_mincolor ( clampfix_maxcolor ( g0 + g1 ) );
                b2 = clampfix_mincolor ( clampfix_maxcolor ( b0 + b1 ) );

                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] += slopeC;
#endif
#ifdef IPOL_T0
        line.t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
        line.t1[0] += slopeT1;
#endif
    }

}
コード例 #13
0
/*!
*/
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
	}

}
コード例 #14
0
/*!
*/
void CTRTextureBlend::fragment_src_color_src_alpha ()
{
	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[MATERIAL_MAX_COLORS];
#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[0] = (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[0] * 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


	f32 iw = 	FIX_POINT_F32_MUL;

	tFixPointu a0, 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 INVERSE_W
		iw = fix_inverse32 ( line.w[0] );
#endif

		getSample_texture ( a0, r0, g0, b0, &IT[0],	tofix ( line.t[0][0].x,iw),	tofix ( line.t[0][0].y,iw) );
		color_to_fix ( r1, g1, b1, dst[i] );

//		u32 check = imulFix_tex1( r0, r1 );
		dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1( r0, r1 ) + imulFix_tex1( r1, a0 ) ),
								clampfix_maxcolor ( imulFix_tex1( g0, g1 ) + imulFix_tex1( g1, a0 ) ),
								clampfix_maxcolor ( imulFix_tex1( b0, b1 ) + imulFix_tex1( b1, a0 ) )
							);
		}

#ifdef IPOL_W
		line.w[0] += slopeW;
#endif
#ifdef IPOL_T0
		line.t[0][0] += slopeT[0];
#endif
#ifdef IPOL_C0
		line.c[0][0] += slopeC[0];
#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 INVERSE_W
		iw = fix_inverse32 ( line.w[0] );
#endif

		getSample_texture ( (tFixPointu&) a0, (tFixPointu&)r0, (tFixPointu&)g0, (tFixPointu&)b0, 
							&IT[0],
							tofix ( line.t[0][0].x,iw),
							tofix ( line.t[0][0].y,iw)
						);
	
		color_to_fix ( r1, g1, b1, dst[i] );

		dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ),
								clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ),
								clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) )
							);

		}

#ifdef IPOL_W
		line.w[0] += slopeW;
#endif
#ifdef IPOL_T0
		line.t[0][0] += slopeT[0];
#endif
#ifdef IPOL_C0
		line.c[0][0] += slopeC[0];
#endif
	}break;
	} // zcompare

}
コード例 #15
0
/*!
*/
inline void CTRTextureDetailMap2::scanline_bilinear ( sScanLineData * data ) const
{
	tVideoSample *dst;

#ifdef IPOL_Z
	TZBufferType2 *z;
#endif

	s32 xStart;
	s32 xEnd;
	s32 dx;

	f32 invDeltaX;

#ifdef SUBTEXEL
	f32 subPixel;
#endif

#ifdef IPOL_Z
	f32 slopeZ;
#endif
#ifdef IPOL_W
	f32 slopeW;
#endif
#ifdef IPOL_C
	sVec4 slopeC;
#endif
#ifdef IPOL_T0
	sVec2 slopeT0;
#endif
#ifdef IPOL_T1
	sVec2 slopeT1;
#endif

	// apply top-left fill-convention, left
	xStart = ceil32( data->x[0] );
	xEnd = ceil32( data->x[1] ) - 1;

	dx = xEnd - xStart;

	if ( dx < 0 )
		return;

	// slopes
	invDeltaX = data->x[1] - data->x[0];
	invDeltaX = inverse32 ( invDeltaX );

#ifdef IPOL_Z
	slopeZ = (data->z[1] - data->z[0]) * invDeltaX;
#endif
#ifdef IPOL_W
	slopeW = (data->w[1] - data->w[0]) * invDeltaX;
#endif
#ifdef IPOL_C
	slopeC = (data->c[1] - data->c[0]) * invDeltaX;
#endif
#ifdef IPOL_T0
	slopeT0 = (data->t0[1] - data->t0[0]) * invDeltaX;
#endif
#ifdef IPOL_T1
	slopeT1 = (data->t1[1] - data->t1[0]) * invDeltaX;
#endif

#ifdef SUBTEXEL
	subPixel = ( (f32) xStart ) - data->x[0];
#ifdef IPOL_Z
	data->z[0] += slopeZ * subPixel;
#endif
#ifdef IPOL_W
	data->w[0] += slopeW * subPixel;
#endif
#ifdef IPOL_C
	data->c[0] += slopeC * subPixel;
#endif
#ifdef IPOL_T0
	data->t0[0] += slopeT0 * subPixel;
#endif
#ifdef IPOL_T1
	data->t1[0] += slopeT1 * subPixel;
#endif
#endif

	dst = lockedSurface + ( data->y * SurfaceWidth ) + xStart;

#ifdef IPOL_Z
	z = lockedZBuffer + ( data->y * SurfaceWidth ) + xStart;
#endif


#ifdef IPOL_W
	f32 inversew;
#endif

	tFixPoint tx0, tx1;
	tFixPoint ty0, ty1;

	tFixPoint r0, g0, b0;
	tFixPoint r1, g1, b1;
	tFixPoint r2, g2, b2;


	for ( s32 i = 0; i <= dx; ++i )
	{
#ifdef CMP_Z
		if ( data->z[0] < z[i] )
#endif
		{
#ifdef IPOL_W
			inversew = inverse32 ( data->w[0] );

			tx0 = f32_to_fixPoint ( data->t0[0].x * inversew);
			ty0 = f32_to_fixPoint ( data->t0[0].y * inversew);
			tx1 = f32_to_fixPoint ( data->t1[0].x * inversew);
			ty1 = f32_to_fixPoint ( data->t1[0].y * inversew);

#else
			tx0 = f32_to_fixPoint ( data->t0[0].x );
			ty0 = f32_to_fixPoint ( data->t0[0].y );
			tx1 = f32_to_fixPoint ( data->t1[0].x );
			ty1 = f32_to_fixPoint ( data->t1[0].y );
#endif
			getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
			getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 );

#define FIX_POINT_HALF_COLOR ( (tFixPoint) ( ((f32) COLOR_MAX / 2.f * FIX_POINT_F32_MUL ) ) )

			// bias half color
			r1 += -FIX_POINT_HALF_COLOR;
			g1 += -FIX_POINT_HALF_COLOR;
			b1 += -FIX_POINT_HALF_COLOR;

			r2 = clampfix_mincolor ( clampfix_maxcolor ( r0 + r1 ) );
			g2 = clampfix_mincolor ( clampfix_maxcolor ( g0 + g1 ) );
			b2 = clampfix_mincolor ( clampfix_maxcolor ( b0 + b1 ) );

			dst[i] = fix_to_color ( r2, g2, b2 );

#ifdef WRITE_Z
			z[i] = data->z[0];
#endif
		}

#ifdef IPOL_Z
		data->z[0] += slopeZ;
#endif
#ifdef IPOL_W
		data->w[0] += slopeW;
#endif
#ifdef IPOL_C
		data->c[0] += slopeC;
#endif
#ifdef IPOL_T0
		data->t0[0] += slopeT0;
#endif
#ifdef IPOL_T1
		data->t1[0] += slopeT1;
#endif
	}

}
コード例 #16
0
/*!
*/
void CTRTextureBlend::fragment_one_minus_dst_alpha_one ()
{
	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[MATERIAL_MAX_COLORS];
#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[0] = (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[0] * 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


	f32 iw = FIX_POINT_F32_MUL;

	tFixPoint r0, g0, b0;
	tFixPoint a1, r1, g1, b1;
	tFixPoint r2, g2, b2;

	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 INVERSE_W
		iw = fix_inverse32 ( line.w[0] );
#endif

		getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
		color_to_fix1 ( a1, r1, g1, b1, dst[i] );
#ifdef IPOL_C0
		getSample_color ( r2, g2, b2, line.c[0][0],iw );

		a1 = FIX_POINT_ONE - a1;
		dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ),
								imulFix ( imulFix ( g0, a1 ) + g1, g2 ),
								imulFix ( imulFix ( b0, a1 ) + b1, b2 )
							);
#else
		dst[i] = fix_to_color ( imulFix ( r0, a1) + r0,
								imulFix ( g0, a1) + g0,
								imulFix ( b0, a1) + b0
							);

#endif

		}

#ifdef IPOL_W
		line.w[0] += slopeW;
#endif
#ifdef IPOL_T0
		line.t[0][0] += slopeT[0];
#endif
#ifdef IPOL_C0
		line.c[0][0] += slopeC[0];
#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 INVERSE_W
		iw = fix_inverse32 ( line.w[0] );
#endif
		getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
		color_to_fix1 ( a1, r1, g1, b1, dst[i] );

#ifdef IPOL_C0
		getSample_color ( r2, g2, b2, line.c[0][0],iw );

		a1 = FIX_POINT_ONE - a1;
		dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ),
								imulFix ( imulFix ( g0, a1 ) + g1, g2 ),
								imulFix ( imulFix ( b0, a1 ) + b1, b2 )
							);
#else
		dst[i] = fix_to_color ( imulFix ( r0, a1) + r0,
								imulFix ( g0, a1) + g0,
								imulFix ( b0, a1) + b0
							);

#endif

		}

#ifdef IPOL_W
		line.w[0] += slopeW;
#endif
#ifdef IPOL_T0
		line.t[0][0] += slopeT[0];
#endif
#ifdef IPOL_C0
		line.c[0][0] += slopeC[0];
#endif
	}break;
	} // zcompare

}
コード例 #17
0
ファイル: CTRTextureBlend.cpp プロジェクト: John-He-928/krkrz
/*!
*/
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

}