Merging r6075 through r6106 from trunk to ogl-es branch.
Burnings renderer changes. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6116 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#undef INVERSE_W
|
||||
|
||||
#undef IPOL_C0
|
||||
#undef IPOL_C1
|
||||
#undef IPOL_T0
|
||||
#undef IPOL_T1
|
||||
|
||||
@@ -34,6 +35,7 @@
|
||||
//#define WRITE_W
|
||||
|
||||
#define IPOL_C0
|
||||
#define IPOL_C1
|
||||
#define IPOL_T0
|
||||
//#define IPOL_T1
|
||||
|
||||
@@ -46,10 +48,15 @@
|
||||
#undef SUBTEXEL
|
||||
#endif
|
||||
|
||||
#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
|
||||
#if BURNING_MATERIAL_MAX_COLORS < 1
|
||||
#undef IPOL_C0
|
||||
#endif
|
||||
|
||||
#if BURNING_MATERIAL_MAX_COLORS < 2
|
||||
#undef IPOL_C1
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
|
||||
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
|
||||
#undef IPOL_W
|
||||
@@ -82,13 +89,11 @@ public:
|
||||
CTRTextureVertexAlpha2(CBurningVideoDriver* driver);
|
||||
|
||||
//! draws an indexed triangle list
|
||||
virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) _IRR_OVERRIDE_;
|
||||
virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) _IRR_OVERRIDE_;
|
||||
|
||||
|
||||
private:
|
||||
void scanline_bilinear ();
|
||||
sScanConvertData scan;
|
||||
sScanLineData line;
|
||||
|
||||
};
|
||||
|
||||
@@ -129,15 +134,15 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
fp24 slopeW;
|
||||
#endif
|
||||
#ifdef IPOL_C0
|
||||
sVec4 slopeC;
|
||||
sVec4 slopeC[BURNING_MATERIAL_MAX_COLORS];
|
||||
#endif
|
||||
#ifdef IPOL_T0
|
||||
sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
|
||||
#endif
|
||||
|
||||
// apply top-left fill-convention, left
|
||||
xStart = core::ceil32_fast( line.x[0] );
|
||||
xEnd = core::ceil32_fast( line.x[1] ) - 1;
|
||||
xStart = fill_convention_left( line.x[0] );
|
||||
xEnd = fill_convention_right( line.x[1] );
|
||||
|
||||
dx = xEnd - xStart;
|
||||
|
||||
@@ -145,7 +150,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
return;
|
||||
|
||||
// slopes
|
||||
const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
|
||||
const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] );
|
||||
|
||||
#ifdef IPOL_Z
|
||||
slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
|
||||
@@ -154,7 +159,10 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
slopeW = (line.w[1] - line.w[0]) * invDeltaX;
|
||||
#endif
|
||||
#ifdef IPOL_C0
|
||||
slopeC = (line.c[0][1] - line.c[0][0]) * invDeltaX;
|
||||
slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
|
||||
#endif
|
||||
#ifdef IPOL_C1
|
||||
slopeC[1] = (line.c[1][1] - line.c[1][0]) * invDeltaX;
|
||||
#endif
|
||||
#ifdef IPOL_T0
|
||||
slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
|
||||
@@ -172,8 +180,12 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
line.w[0] += slopeW * subPixel;
|
||||
#endif
|
||||
#ifdef IPOL_C0
|
||||
line.c[0][0] += slopeC * subPixel;
|
||||
line.c[0][0] += slopeC[0] * subPixel;
|
||||
#endif
|
||||
#ifdef IPOL_C1
|
||||
line.c[1][0] += slopeC[1] * subPixel;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
line.t[0][0] += slopeT[0] * subPixel;
|
||||
#endif
|
||||
@@ -182,6 +194,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SOFTWARE_DRIVER_2_CLIPCHECK;
|
||||
dst = (tVideoSample*)RenderTarget->getData() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
|
||||
|
||||
#ifdef USE_ZBUFFER
|
||||
@@ -191,22 +204,18 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
|
||||
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;
|
||||
tFixPoint a2,r2, g2, b2;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
tFixPoint aFog = FIX_POINT_ONE;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -220,50 +229,74 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
#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
|
||||
|
||||
#ifdef INVERSE_W
|
||||
inversew = fix_inverse32 ( line.w[0] );
|
||||
#endif
|
||||
#ifdef IPOL_C1
|
||||
//complete inside fog
|
||||
if (TL_Flag & TL_FOG)
|
||||
{
|
||||
aFog = tofix(line.c[1][0].a, inversew);
|
||||
if (aFog <= 0)
|
||||
{
|
||||
dst[i] = fog_color_sample;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
tx0 = tofix ( line.t[0][0].x,inversew);
|
||||
ty0 = tofix ( line.t[0][0].y,inversew);
|
||||
|
||||
getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
|
||||
color_to_fix ( r1, g1, b1, dst[i] );
|
||||
|
||||
#ifdef IPOL_C0
|
||||
vec4_to_fix(a2,r2, g2, b2, line.c[0][0], inversew);
|
||||
|
||||
r0 = imulFix_simple(r0, r2);
|
||||
g0 = imulFix_simple(g0, g2);
|
||||
b0 = imulFix_simple(b0, b2);
|
||||
|
||||
#ifdef IPOL_C1
|
||||
//specular highlight
|
||||
if (TL_Flag & TL_SPECULAR)
|
||||
{
|
||||
vec4_to_fix(r2, g2, b2, line.c[1][0], inversew*COLOR_MAX);
|
||||
r0 = clampfix_maxcolor(r2 + r0);
|
||||
g0 = clampfix_maxcolor(g2 + g0);
|
||||
b0 = clampfix_maxcolor(b2 + b0);
|
||||
}
|
||||
#endif
|
||||
//blend background
|
||||
r0 = r1 + imulFix(a2, r0 - r1);
|
||||
g0 = g1 + imulFix(a2, g0 - g1);
|
||||
b0 = b1 + imulFix(a2, b0 - b1);
|
||||
|
||||
#ifdef IPOL_C1
|
||||
//mix with distance
|
||||
if (aFog < FIX_POINT_ONE) //TL_Flag & TL_FOG)
|
||||
{
|
||||
r0 = fog_color[1] + imulFix(aFog, r0 - fog_color[1]);
|
||||
g0 = fog_color[2] + imulFix(aFog, g0 - fog_color[2]);
|
||||
b0 = fog_color[3] + imulFix(aFog, b0 - fog_color[3]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
r0 = clampfix_maxcolor ( r1 + r0 );
|
||||
g0 = clampfix_maxcolor ( g1 + g0 );
|
||||
b0 = clampfix_maxcolor ( b1 + b0 );
|
||||
#endif
|
||||
|
||||
dst[i] = fix_to_sample( r0, g0, b0 );
|
||||
|
||||
}
|
||||
|
||||
#ifdef IPOL_Z
|
||||
@@ -273,7 +306,10 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
line.w[0] += slopeW;
|
||||
#endif
|
||||
#ifdef IPOL_C0
|
||||
line.c[0][0] += slopeC;
|
||||
line.c[0][0] += slopeC[0];
|
||||
#endif
|
||||
#ifdef IPOL_C1
|
||||
line.c[1][0] += slopeC[1];
|
||||
#endif
|
||||
#ifdef IPOL_T0
|
||||
line.t[0][0] += slopeT[0];
|
||||
@@ -285,7 +321,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
|
||||
|
||||
}
|
||||
|
||||
void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
|
||||
void CTRTextureVertexAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c)
|
||||
{
|
||||
// sort on height, y
|
||||
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
|
||||
@@ -296,9 +332,9 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
const f32 ba = b->Pos.y - a->Pos.y;
|
||||
const f32 cb = c->Pos.y - b->Pos.y;
|
||||
// calculate delta y of the edges
|
||||
scan.invDeltaY[0] = core::reciprocal( ca );
|
||||
scan.invDeltaY[1] = core::reciprocal( ba );
|
||||
scan.invDeltaY[2] = core::reciprocal( cb );
|
||||
scan.invDeltaY[0] = reciprocal_zero( ca );
|
||||
scan.invDeltaY[1] = reciprocal_zero( ba );
|
||||
scan.invDeltaY[2] = reciprocal_zero( cb );
|
||||
|
||||
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
|
||||
return;
|
||||
@@ -333,6 +369,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][0] = a->Color[0];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.slopeC[1][0] = (c->Color[1] - a->Color[1]) * scan.invDeltaY[0];
|
||||
scan.c[1][0] = a->Color[1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
|
||||
scan.t[0][0] = a->Tex[0];
|
||||
@@ -373,6 +414,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][1] = a->Color[0];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.slopeC[1][1] = (b->Color[1] - a->Color[1]) * scan.invDeltaY[1];
|
||||
scan.c[1][1] = a->Color[1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
|
||||
scan.t[0][1] = a->Tex[0];
|
||||
@@ -384,8 +430,8 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = core::ceil32_fast( a->Pos.y );
|
||||
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
|
||||
yStart = fill_convention_left( a->Pos.y );
|
||||
yEnd = fill_convention_right( b->Pos.y );
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
subPixel = ( (f32) yStart ) - a->Pos.y;
|
||||
@@ -409,6 +455,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][1] += scan.slopeC[0][1] * subPixel;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.c[1][0] += scan.slopeC[1][0] * subPixel;
|
||||
scan.c[1][1] += scan.slopeC[1][1] * subPixel;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
|
||||
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
|
||||
@@ -442,6 +493,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
line.c[0][scan.right] = scan.c[0][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
line.c[1][scan.left] = scan.c[1][0];
|
||||
line.c[1][scan.right] = scan.c[1][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
line.t[0][scan.left] = scan.t[0][0];
|
||||
line.t[0][scan.right] = scan.t[0][1];
|
||||
@@ -473,6 +529,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][1] += scan.slopeC[0][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.c[1][0] += scan.slopeC[1][0];
|
||||
scan.c[1][1] += scan.slopeC[1][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.t[0][0] += scan.slopeT[0][0];
|
||||
scan.t[0][1] += scan.slopeT[0][1];
|
||||
@@ -504,6 +565,9 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
#ifdef IPOL_C0
|
||||
scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0];
|
||||
#endif
|
||||
#ifdef IPOL_C1
|
||||
scan.c[1][0] = a->Color[1] + scan.slopeC[1][0] * temp[0];
|
||||
#endif
|
||||
#ifdef IPOL_T0
|
||||
scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
|
||||
#endif
|
||||
@@ -532,6 +596,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][1] = b->Color[0];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.slopeC[1][1] = (c->Color[1] - b->Color[1]) * scan.invDeltaY[2];
|
||||
scan.c[1][1] = b->Color[1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
|
||||
scan.t[0][1] = b->Tex[0];
|
||||
@@ -543,8 +612,8 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
#endif
|
||||
|
||||
// apply top-left fill convention, top part
|
||||
yStart = core::ceil32_fast( b->Pos.y );
|
||||
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
|
||||
yStart = fill_convention_left( b->Pos.y );
|
||||
yEnd = fill_convention_right( c->Pos.y );
|
||||
|
||||
#ifdef SUBTEXEL
|
||||
|
||||
@@ -569,6 +638,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][1] += scan.slopeC[0][1] * subPixel;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.c[1][0] += scan.slopeC[1][0] * subPixel;
|
||||
scan.c[1][1] += scan.slopeC[1][1] * subPixel;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
|
||||
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
|
||||
@@ -602,6 +676,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
line.c[0][scan.right] = scan.c[0][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
line.c[1][scan.left] = scan.c[1][0];
|
||||
line.c[1][scan.right] = scan.c[1][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
line.t[0][scan.left] = scan.t[0][0];
|
||||
line.t[0][scan.right] = scan.t[0][1];
|
||||
@@ -633,6 +712,11 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
|
||||
scan.c[0][1] += scan.slopeC[0][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C1
|
||||
scan.c[1][0] += scan.slopeC[1][0];
|
||||
scan.c[1][1] += scan.slopeC[1][1];
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_T0
|
||||
scan.t[0][0] += scan.slopeT[0][0];
|
||||
scan.t[0][1] += scan.slopeT[0][1];
|
||||
@@ -662,6 +746,7 @@ namespace video
|
||||
//! creates a flat triangle renderer
|
||||
IBurningShader* createTriangleRendererTextureVertexAlpha2(CBurningVideoDriver* driver)
|
||||
{
|
||||
/* ETR_TEXTURE_GOURAUD_VERTEX_ALPHA */
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
return new CTRTextureVertexAlpha2(driver);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user