- BurningVideo: 0.50
- 10 year anniversary update - Lighting model reworked. moved to eyespace like openGL. [Specular Highlights, Fog, Sphere/Reflection Map] - increased internal s4DVertex to support 4 Textures and 4 Colors [switchable] - Textures are handled as sRGB during Mipmap Generation. More accurate, less visual disruption - 2D is drawn as 3D like hardware drivers. [switchable]. enables viewport scaling, material2D - Texture Spatial Resolution Limiting working. [lower memory consumption,SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE] - SuperTuxKart 8.0.1 playable git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6086 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@@ -28,14 +28,14 @@
|
||||
#define SUBTEXEL
|
||||
#define INVERSE_W
|
||||
|
||||
#define USE_ZBUFFER
|
||||
//#define USE_ZBUFFER
|
||||
#define IPOL_W
|
||||
#define CMP_W
|
||||
#define WRITE_W
|
||||
//#define CMP_W
|
||||
//#define WRITE_W
|
||||
|
||||
|
||||
//#define IPOL_C0
|
||||
#define IPOL_T0
|
||||
#define IPOL_C0
|
||||
//#define IPOL_T0
|
||||
//#define IPOL_T1
|
||||
|
||||
// apply global override
|
||||
@@ -47,6 +47,10 @@
|
||||
#undef SUBTEXEL
|
||||
#endif
|
||||
|
||||
#if BURNING_MATERIAL_MAX_COLORS < 1
|
||||
#undef IPOL_C0
|
||||
#endif
|
||||
|
||||
#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
|
||||
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
|
||||
#undef IPOL_W
|
||||
@@ -80,14 +84,17 @@ public:
|
||||
CTRTextureWire2(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_;
|
||||
virtual void drawLine ( const s4DVertex *a,const s4DVertex *b) _IRR_OVERRIDE_;
|
||||
virtual void drawPoint( const s4DVertex *a) _IRR_OVERRIDE_;
|
||||
virtual bool canWireFrame () _IRR_OVERRIDE_ { return true; }
|
||||
virtual bool canPointCloud() _IRR_OVERRIDE_ { return true; }
|
||||
|
||||
protected:
|
||||
virtual void scanline_bilinear ();
|
||||
|
||||
|
||||
private:
|
||||
void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const;
|
||||
void renderLine ( const s4DVertex *a,const s4DVertex *b ) const;
|
||||
void renderLine ( const s4DVertex *a,const s4DVertex *b, int renderZero = 0 ) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -101,26 +108,20 @@ CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver)
|
||||
}
|
||||
|
||||
|
||||
// swap integer with xor
|
||||
static inline void swap_xor ( s32 &a, s32 &b )
|
||||
{
|
||||
a ^= b;
|
||||
b ^= a;
|
||||
a ^= b;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
2d line
|
||||
*/
|
||||
void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
|
||||
void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int renderZero) 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;
|
||||
//todo:!
|
||||
int aposx = fill_convention_none(a->Pos.x);
|
||||
int aposy = fill_convention_none(a->Pos.y);
|
||||
int bposx = fill_convention_none(b->Pos.x);
|
||||
int bposy = fill_convention_none(b->Pos.y);
|
||||
|
||||
int dx = bposx - aposx;
|
||||
int dy = bposy - aposy;
|
||||
@@ -138,37 +139,39 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
|
||||
int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY;
|
||||
int yInc0 = pitch0;
|
||||
|
||||
#ifdef USE_ZBUFFER
|
||||
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);
|
||||
#ifdef USE_ZBUFFER
|
||||
xInc1 = -4;
|
||||
#endif
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
swap_xor ( dx, dy );
|
||||
swap_xor ( xInc0, yInc0 );
|
||||
swap_xor ( xInc1, yInc1 );
|
||||
//swap
|
||||
register s32 t;
|
||||
t = dx;dx=dy;dy=t;
|
||||
t = xInc0;xInc0=yInc0;yInc0=t;
|
||||
#ifdef USE_ZBUFFER
|
||||
t = xInc1;xInc1=yInc1;yInc1=t;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( 0 == dx )
|
||||
return;
|
||||
if (0 == dx)
|
||||
{
|
||||
if (!renderZero) return;
|
||||
dx = 1;
|
||||
}
|
||||
|
||||
dst = (tVideoSample*) ( (u8*) (tVideoSample*)RenderTarget->getData() + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) );
|
||||
SOFTWARE_DRIVER_2_CLIPCHECK_WIRE;
|
||||
dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( aposy * pitch0 ) + (aposx* (1<< VIDEO_SAMPLE_GRANULARITY) ) );
|
||||
#ifdef USE_ZBUFFER
|
||||
z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) );
|
||||
#endif
|
||||
@@ -176,16 +179,43 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
// slopes
|
||||
const f32 invDeltaX = reciprocal_zero2( (f32)dx );
|
||||
|
||||
#ifdef IPOL_Z
|
||||
f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx);
|
||||
f32 slopeZ = (b->Pos.z - a->Pos.z) * invDeltaX;
|
||||
f32 dataZ = a->Pos.z;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_W
|
||||
fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx );
|
||||
fp24 slopeW = (b->Pos.w - a->Pos.w) * invDeltaX;
|
||||
fp24 dataW = a->Pos.w;
|
||||
#endif
|
||||
|
||||
f32 inversew = FIX_POINT_F32_MUL;
|
||||
|
||||
tVideoSample color;
|
||||
#if BURNING_MATERIAL_MAX_COLORS > 0
|
||||
tFixPoint r0, g0, b0;
|
||||
#ifdef IPOL_C0
|
||||
sVec4 slopeC;
|
||||
sVec4 C;
|
||||
slopeC = (b->Color[0] - a->Color[0]) * invDeltaX;
|
||||
C = a->Color[0];
|
||||
#endif
|
||||
|
||||
#ifdef INVERSE_W
|
||||
inversew = fix_inverse32_color(dataW);
|
||||
#endif
|
||||
|
||||
vec4_to_fix( r0, g0, b0, a->Color[0], inversew);
|
||||
color = fix_to_sample( r0, g0, b0 );
|
||||
|
||||
#else
|
||||
color = (tVideoSample) 0xFFFFFFFF;
|
||||
#endif
|
||||
|
||||
|
||||
run = dx;
|
||||
while ( run )
|
||||
{
|
||||
@@ -203,15 +233,22 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
|
||||
*z = dataW;
|
||||
#endif
|
||||
|
||||
*dst = color;
|
||||
#ifdef IPOL_C0
|
||||
#ifdef INVERSE_W
|
||||
inversew = fix_inverse32_color(dataW);
|
||||
#endif
|
||||
vec4_to_fix(r0, g0, b0, C,inversew);
|
||||
color = fix_to_sample( r0, g0, b0 );
|
||||
#endif
|
||||
*dst = color;
|
||||
|
||||
}
|
||||
|
||||
dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc
|
||||
#ifdef IPOL_Z
|
||||
#ifdef CMP_Z
|
||||
z = (fp24*) ( (u8*) z + xInc1 );
|
||||
#endif
|
||||
#ifdef IPOL_W
|
||||
#ifdef CMP_W
|
||||
z = (fp24*) ( (u8*) z + xInc1 );
|
||||
#endif
|
||||
|
||||
@@ -219,10 +256,10 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc
|
||||
#ifdef IPOL_Z
|
||||
#ifdef CMP_Z
|
||||
z = (fp24*) ( (u8*) z + yInc1 );
|
||||
#endif
|
||||
#ifdef IPOL_W
|
||||
#ifdef CMP_W
|
||||
z = (fp24*) ( (u8*) z + yInc1 );
|
||||
#endif
|
||||
|
||||
@@ -235,15 +272,21 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
|
||||
#ifdef IPOL_W
|
||||
dataW += slopeW;
|
||||
#endif
|
||||
#ifdef IPOL_C0
|
||||
C += slopeC;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
|
||||
void CTRTextureWire2::scanline_bilinear()
|
||||
{
|
||||
sScanLineData line;
|
||||
}
|
||||
|
||||
void CTRTextureWire2::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);
|
||||
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
|
||||
@@ -258,14 +301,17 @@ void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const
|
||||
|
||||
void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b)
|
||||
{
|
||||
|
||||
// query access to TexMaps
|
||||
|
||||
// sort on height, y
|
||||
if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b);
|
||||
if (F32_A_GREATER_B(a->Pos.y,b->Pos.y )) swapVertexPointer(&a, &b);
|
||||
|
||||
renderLine ( a, b );
|
||||
}
|
||||
|
||||
void CTRTextureWire2::drawPoint(const s4DVertex *a)
|
||||
{
|
||||
if ( (a->flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) renderLine(a, a,1);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +329,7 @@ namespace video
|
||||
//! creates a flat triangle renderer
|
||||
IBurningShader* createTriangleRendererTextureGouraudWire2(CBurningVideoDriver* driver)
|
||||
{
|
||||
//ETR_TEXTURE_GOURAUD_WIRE
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
return new CTRTextureWire2(driver);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user