Commit af48d4e0 authored by engineer_apple's avatar engineer_apple

fix:wrong software shader used for alpha-blending

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5040 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 05839bee
......@@ -22,319 +22,6 @@ namespace irr
{
namespace video
{
#if 0
namespace glsl
{
typedef sVec4 vec4;
typedef sVec3 vec3;
typedef sVec2 vec2;
#define in
#define uniform
#define attribute
#define varying
#ifdef _MSC_VER
#pragma warning(disable:4244)
#endif
struct mat4{
float m[4][4];
vec4 operator* ( const vec4 &in ) const
{
vec4 out;
return out;
}
};
struct mat3{
float m[3][3];
vec3 operator* ( const vec3 &in ) const
{
vec3 out;
return out;
}
};
const int gl_MaxLights = 8;
inline float dot (float x, float y) { return x * y; }
inline float dot ( const vec2 &x, const vec2 &y) { return x.x * y.x + x.y * y.y; }
inline float dot ( const vec3 &x, const vec3 &y) { return x.x * y.x + x.y * y.y + x.z * y.z; }
inline float dot ( const vec4 &x, const vec4 &y) { return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; }
inline float reflect (float I, float N) { return I - 2.0 * dot (N, I) * N; }
inline vec2 reflect (const vec2 &I, const vec2 &N) { return I - N * 2.0 * dot (N, I); }
inline vec3 reflect (const vec3 &I, const vec3 &N) { return I - N * 2.0 * dot (N, I); }
inline vec4 reflect (const vec4 &I, const vec4 &N) { return I - N * 2.0 * dot (N, I); }
inline float refract (float I, float N, float eta){
const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
if (k < 0.0)
return 0.0;
return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
}
inline vec2 refract (const vec2 &I, const vec2 &N, float eta){
const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
if (k < 0.0)
return vec2 (0.0);
return I * eta - N * (eta * dot (N, I) + sqrt (k));
}
inline vec3 refract (const vec3 &I, const vec3 &N, float eta) {
const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
if (k < 0.0)
return vec3 (0.0);
return I * eta - N * (eta * dot (N, I) + sqrt (k));
}
inline vec4 refract (const vec4 &I, const vec4 &N, float eta) {
const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
if (k < 0.0)
return vec4 (0.0);
return I * eta - N * (eta * dot (N, I) + sqrt (k));
}
static __inline float length ( const vec3 &v ) { return sqrtf ( v.x * v.x + v.y * v.y + v.z * v.z ); }
static __inline vec3 normalize ( const vec3 &v ) { float l = 1.f / length ( v ); return vec3 ( v.x * l, v.y * l, v.z * l ); }
static __inline float maximum ( float a, float b ) { return a > b ? a : b; }
static __inline float minimum ( float a, float b ) { return a < b ? a : b; }
static __inline vec4 clamp ( const vec4 &a, f32 low, f32 high )
{
return vec4 ( minimum (maximum(a.x,low), high), minimum (maximum(a.y,low), high), minimum (maximum(a.z,low), high), minimum (maximum(a.w,low), high) );
}
typedef int sampler2D;
sampler2D texUnit0;
vec4 texture2D (sampler2D sampler, const vec2 &coord) { return vec4 (0.0); }
struct gl_LightSourceParameters {
vec4 ambient; // Acli
vec4 diffuse; // Dcli
vec4 specular; // Scli
vec4 position; // Ppli
vec4 halfVector; // Derived: Hi
vec3 spotDirection; // Sdli
float spotExponent; // Srli
float spotCutoff; // Crli
// (range: [0.0,90.0], 180.0)
float spotCosCutoff; // Derived: cos(Crli)
// (range: [1.0,0.0],-1.0)
float constantAttenuation; // K0
float linearAttenuation; // K1
float quadraticAttenuation;// K2
};
uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
struct gl_LightModelParameters {
vec4 ambient;
};
uniform gl_LightModelParameters gl_LightModel;
struct gl_LightModelProducts {
vec4 sceneColor;
};
uniform gl_LightModelProducts gl_FrontLightModelProduct;
uniform gl_LightModelProducts gl_BackLightModelProduct;
struct gl_LightProducts {
vec4 ambient;
vec4 diffuse;
vec4 specular;
};
uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
struct gl_MaterialParameters
{
vec4 emission; // Ecm
vec4 ambient; // Acm
vec4 diffuse; // Dcm
vec4 specular; // Scm
float shininess; // Srm
};
uniform gl_MaterialParameters gl_FrontMaterial;
uniform gl_MaterialParameters gl_BackMaterial;
// GLSL has some built-in attributes in a vertex shader:
attribute vec4 gl_Vertex; // 4D vector representing the vertex position
attribute vec3 gl_Normal; // 3D vector representing the vertex normal
attribute vec4 gl_Color; // 4D vector representing the vertex color
attribute vec4 gl_MultiTexCoord0; // 4D vector representing the texture coordinate of texture unit X
attribute vec4 gl_MultiTexCoord1; // 4D vector representing the texture coordinate of texture unit X
uniform mat4 gl_ModelViewMatrix; //4x4 Matrix representing the model-view matrix.
uniform mat4 gl_ModelViewProjectionMatrix; //4x4 Matrix representing the model-view-projection matrix.
uniform mat3 gl_NormalMatrix; //3x3 Matrix representing the inverse transpose model-view matrix. This matrix is used for normal transformation.
varying vec4 gl_FrontColor; // 4D vector representing the primitives front color
varying vec4 gl_FrontSecondaryColor; // 4D vector representing the primitives second front color
varying vec4 gl_BackColor; // 4D vector representing the primitives back color
varying vec4 gl_TexCoord[4]; // 4D vector representing the Xth texture coordinate
// shader output
varying vec4 gl_Position; // 4D vector representing the final processed vertex position. Only available in vertex shader.
varying vec4 gl_FragColor; // 4D vector representing the final color which is written in the frame buffer. Only available in fragment shader.
varying float gl_FragDepth; // float representing the depth which is written in the depth buffer. Only available in fragment shader.
varying vec4 gl_SecondaryColor;
varying float gl_FogFragCoord;
vec4 ftransform(void)
{
return gl_ModelViewProjectionMatrix * gl_Vertex;
}
vec3 fnormal(void)
{
//Compute the normal
vec3 normal = gl_NormalMatrix * gl_Normal;
normal = normalize(normal);
return normal;
}
struct program1
{
vec4 Ambient;
vec4 Diffuse;
vec4 Specular;
void pointLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3)
{
float nDotVP; // normal . light direction
float nDotHV; // normal . light half vector
float pf; // power factor
float attenuation; // computed attenuation factor
float d; // distance from surface to light source
vec3 VP; // direction from surface to light position
vec3 halfVector; // direction of maximum highlights
// Compute vector from surface to light position
VP = vec3 (gl_LightSource[i].position) - ecPosition3;
// Compute distance between surface and light position
d = length(VP);
// Normalize the vector from surface to light position
VP = normalize(VP);
// Compute attenuation
attenuation = 1.0 / (gl_LightSource[i].constantAttenuation +
gl_LightSource[i].linearAttenuation * d +
gl_LightSource[i].quadraticAttenuation * d * d);
halfVector = normalize(VP + eye);
nDotVP = maximum(0.0, dot(normal, VP));
nDotHV = maximum(0.0, dot(normal, halfVector));
if (nDotVP == 0.0)
{
pf = 0.0;
}
else
{
pf = pow(nDotHV, gl_FrontMaterial.shininess);
}
Ambient += gl_LightSource[i].ambient * attenuation;
Diffuse += gl_LightSource[i].diffuse * nDotVP * attenuation;
Specular += gl_LightSource[i].specular * pf * attenuation;
}
vec3 fnormal(void)
{
//Compute the normal
vec3 normal = gl_NormalMatrix * gl_Normal;
normal = normalize(normal);
return normal;
}
void ftexgen(in vec3 normal, in vec4 ecPosition)
{
gl_TexCoord[0] = gl_MultiTexCoord0;
}
void flight(in vec3 normal, in vec4 ecPosition, float alphaFade)
{
vec4 color;
vec3 ecPosition3;
vec3 eye;
ecPosition3 = (vec3 (ecPosition)) / ecPosition.w;
eye = vec3 (0.0, 0.0, 1.0);
// Clear the light intensity accumulators
Ambient = vec4 (0.0);
Diffuse = vec4 (0.0);
Specular = vec4 (0.0);
pointLight(0, normal, eye, ecPosition3);
pointLight(1, normal, eye, ecPosition3);
color = gl_FrontLightModelProduct.sceneColor +
Ambient * gl_FrontMaterial.ambient +
Diffuse * gl_FrontMaterial.diffuse;
gl_FrontSecondaryColor = Specular * gl_FrontMaterial.specular;
color = clamp( color, 0.0, 1.0 );
gl_FrontColor = color;
gl_FrontColor.a *= alphaFade;
}
void vertexshader_main (void)
{
vec3 transformedNormal;
float alphaFade = 1.0;
// Eye-coordinate position of vertex, needed in various calculations
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
// Do fixed functionality vertex transform
gl_Position = ftransform();
transformedNormal = fnormal();
flight(transformedNormal, ecPosition, alphaFade);
ftexgen(transformedNormal, ecPosition);
}
void fragmentshader_main (void)
{
vec4 color;
color = gl_Color;
color *= texture2D(texUnit0, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y) );
color += gl_SecondaryColor;
color = clamp(color, 0.0, 1.0);
gl_FragColor = color;
}
};
}
#endif
//! constructor
CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, video::IImagePresenter* presenter)
......@@ -368,7 +55,7 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters&
DriverAttributes->setAttribute("MaxTextureSize", SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE);
DriverAttributes->setAttribute("MaxLights", 1024 ); //glsl::gl_MaxLights);
DriverAttributes->setAttribute("MaxTextureLODBias", 16.f);
DriverAttributes->setAttribute("Version", 48);
DriverAttributes->setAttribute("Version", 49);
// create triangle renderers
......@@ -514,7 +201,11 @@ void CBurningVideoDriver::setCurrentShader()
shader = zMaterialTest ? ETR_TEXTURE_GOURAUD_ALPHA : ETR_TEXTURE_GOURAUD_ALPHA_NOZ;
break;
}
// fall through
else
{
shader = ETR_TEXTURE_GOURAUD_VERTEX_ALPHA;
}
break;
case EMT_TRANSPARENT_ADD_COLOR:
shader = zMaterialTest ? ETR_TEXTURE_GOURAUD_ADD : ETR_TEXTURE_GOURAUD_ADD_NO_Z;
......@@ -629,6 +320,8 @@ bool CBurningVideoDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return true;
#endif
case EVDF_STENCIL_BUFFER:
return StencilBuffer != 0;
case EVDF_RENDER_TO_TARGET:
case EVDF_MULTITEXTURE:
case EVDF_HARDWARE_TL:
......@@ -1845,31 +1538,6 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert
// to DC Space, project homogenous vertex
ndc_2_dc_and_project ( CurrentOut.data + 1, CurrentOut.data, vOut );
/*
// TODO: don't stick on 32 Bit Pointer
#define PointerAsValue(x) ( (u32) (u32*) (x) )
// if not complete inside clipping necessary
if ( ( test & VERTEX4D_INSIDE ) != VERTEX4D_INSIDE )
{
u32 v[2] = { PointerAsValue ( Temp ) , PointerAsValue ( CurrentOut ) };
for ( g = 0; g != 6; ++g )
{
vOut = clipToHyperPlane ( (s4DVertex*) v[0], (s4DVertex*) v[1], vOut, NDCPlane[g] );
if ( vOut < 3 )
break;
v[0] ^= v[1];
v[1] ^= v[0];
v[0] ^= v[1];
}
if ( vOut < 3 )
continue;
}
*/
// check 2d backface culling on first
dc_area = screenarea ( CurrentOut.data );
if ( Material.org.BackfaceCulling && F32_LOWER_EQUAL_0 ( dc_area ) )
......@@ -2518,20 +2186,20 @@ void CBurningVideoDriver::draw3DLine(const core::vector3df& start,
const wchar_t* CBurningVideoDriver::getName() const
{
#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL
return L"Burning's Video 0.48 beautiful";
return L"Burning's Video 0.49 beautiful";
#elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST )
return L"Burning's Video 0.48 ultra fast";
return L"Burning's Video 0.49 ultra fast";
#elif defined ( BURNINGVIDEO_RENDERER_FAST )
return L"Burning's Video 0.48 fast";
return L"Burning's Video 0.49 fast";
#else
return L"Burning's Video 0.48";
return L"Burning's Video 0.49";
#endif
}
//! Returns the graphics card vendor name.
core::stringc CBurningVideoDriver::getVendorInfo()
{
return "Burning's Video: Ing. Thomas Alten (c) 2006-2013";
return "Burning's Video: Ing. Thomas Alten (c) 2006-2015";
}
......
......@@ -30,8 +30,6 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name,
DriverType = EDT_BURNINGSVIDEO;
ColorFormat = BURNINGSHADER_COLOR_FORMAT;
HasMipMaps = (Flags & GEN_MIPMAP) != 0;
HasAlpha = (Flags & HAS_ALPHA) != 0;
IsRenderTarget = (Flags & IS_RENDERTARGET) != 0;
memset32 ( MipMap, 0, sizeof ( MipMap ) );
......@@ -91,6 +89,9 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name,
OrigImageDataSizeInPixels = (f32) 0.3f * MipMap[0]->getImageDataSizeInPixels();
}
HasMipMaps = (Flags & GEN_MIPMAP) != 0;
HasAlpha = (Flags & HAS_ALPHA) != 0;
regenerateMipMapLevels(mipmapData);
}
......
......@@ -210,9 +210,7 @@ void CTRNormalMap::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
tFixPoint tx0, tx1;
tFixPoint ty0, ty1;
......@@ -256,10 +254,11 @@ void CTRNormalMap::scanline_bilinear ()
#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 );
inversew = FIX_POINT_F32_MUL;
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 );
......
......@@ -336,8 +336,8 @@ void CTRTextureBlend::fragment_dst_color_src_alpha ()
getSample_texture ( a0,r0,g0,b0,
&IT[0],
tofix ( line.t[0][0].x,iw),
tofix ( line.t[0][0].y,iw)
tofix(line.t[0][0].x, iw),
tofix(line.t[0][0].y, iw)
);
color_to_fix ( r1, g1, b1, dst[i] );
......
......@@ -191,9 +191,7 @@ void CTRTextureDetailMap2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0, tx1;
tFixPoint ty0, ty1;
......@@ -215,18 +213,12 @@ void CTRTextureDetailMap2::scanline_bilinear ()
{
#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);
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 );
......
......@@ -190,9 +190,7 @@ void CTRTextureGouraud2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0;
tFixPoint ty0;
......@@ -236,8 +234,8 @@ void CTRTextureGouraud2::scanline_bilinear ()
#endif
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
tx0 = tofix(line.t[0][0].x, inversew);
ty0 = tofix(line.t[0][0].y, inversew);
#ifdef IPOL_C0
getTexel_plain2 ( r1, g1, b1, line.c[0][0] );
#endif
......
......@@ -190,9 +190,7 @@ void CTRTextureGouraudAdd2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
......@@ -226,31 +224,19 @@ void CTRTextureGouraudAdd2::scanline_bilinear ()
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
dst[i] = PixelAdd32 (
dst[i],
getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
d + tofix ( line.t[0][0].y,inversew) )
);
#else
dst[i] = PixelAdd32 (
dst[i],
getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y) )
);
#endif
#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);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
color_to_fix ( r1, g1, b1, dst[i] );
......
......@@ -190,9 +190,7 @@ void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
#endif
#ifdef IPOL_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0;
tFixPoint ty0;
......@@ -211,13 +209,9 @@ void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
{
#ifdef IPOL_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
......
......@@ -207,9 +207,7 @@ void CTRTextureGouraudAlpha2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
u32 dIndex = ( line.y & 3 ) << 2;
......@@ -240,21 +238,13 @@ void CTRTextureGouraudAlpha2::scanline_bilinear ()
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
d + tofix ( line.t[0][0].y,inversew)
);
#else
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y)
);
#endif
const u32 alpha = ( argb >> 24 );
if ( alpha > AlphaRef )
{
......
......@@ -207,9 +207,7 @@ void CTRTextureGouraudAlphaNoZ::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
u32 dIndex = ( line.y & 3 ) << 2;
......@@ -240,21 +238,12 @@ void CTRTextureGouraudAlphaNoZ::scanline_bilinear ()
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
d + tofix ( line.t[0][0].y,inversew)
);
#else
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y)
);
#endif
const u32 alpha = ( argb >> 24 );
if ( alpha > AlphaRef )
{
......
......@@ -195,9 +195,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0;
tFixPoint ty0;
......@@ -215,13 +213,9 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
{
#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);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
dst[i] = getTexel_plain ( &IT[0], tx0, ty0 );
/*
......
......@@ -189,9 +189,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
//#define __TEST_THIS
......@@ -236,23 +234,12 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
#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
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#ifdef IPOL_C0
a3 = tofix ( line.c[0][0].y );
#endif
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
......
......@@ -190,6 +190,7 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
......@@ -223,9 +224,8 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
#ifdef BURNINGVIDEO_RENDERER_FAST
#ifdef INVERSE_W
const f32 inversew = fix_inverse32 ( line.w[0] );
inversew = fix_inverse32 ( line.w[0] );
#endif
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
dst[i] = PixelAdd32 (
......@@ -234,17 +234,6 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x,inversew),
d + tofix ( line.t[1][0].y,inversew) )
);
#else
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
dst[i] = PixelAdd32 (
getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y) ),
getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x),
d + tofix ( line.t[1][0].y) )
);
#endif
#else
const f32 inversew = fix_inverse32 ( line.w[0] );
......
......@@ -190,9 +190,7 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0, tx1;
tFixPoint ty0, ty1;
......@@ -216,7 +214,7 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
{
#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);
tx1 = tofix ( line.t[1][0].x,inversew);
......@@ -228,19 +226,6 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
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 );
......
......@@ -644,9 +644,9 @@ inline void getTexel_plain2 ( tFixPoint &r, tFixPoint &g, tFixPoint &b,
const sVec4 &v
)
{
r = tofix ( v.y );
g = tofix ( v.z );
b = tofix ( v.w );
r = tofix(v.y, FIX_POINT_F32_MUL);
g = tofix(v.z, FIX_POINT_F32_MUL);
b = tofix(v.w, FIX_POINT_F32_MUL);
}
/*
......@@ -656,7 +656,7 @@ inline void getSample_color ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoin
const sVec4 &v
)
{
a = tofix ( v.x );
a = tofix(v.x, FIX_POINT_F32_MUL);
r = tofix ( v.y, COLOR_MAX * FIX_POINT_F32_MUL);
g = tofix ( v.z, COLOR_MAX * FIX_POINT_F32_MUL);
b = tofix ( v.w, COLOR_MAX * FIX_POINT_F32_MUL);
......
......@@ -77,7 +77,7 @@
// mip mapping
#if defined ( SOFTWARE_DRIVER_2_MIPMAPPING )
#if defined( BURNINGVIDEO_RENDERER_BEAUTIFUL )
#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8
#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 16
#define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0
#elif defined ( BURNINGVIDEO_RENDERER_CE )
#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4
......@@ -91,7 +91,7 @@
#define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0
#endif
#define SOFTWARE_DRIVER_2_MIPMAPPING_SCALE (8/SOFTWARE_DRIVER_2_MIPMAPPING_MAX)
#define SOFTWARE_DRIVER_2_MIPMAPPING_SCALE (16/SOFTWARE_DRIVER_2_MIPMAPPING_MAX)
#ifndef REALINLINE
#ifdef _MSC_VER
......
......@@ -461,10 +461,7 @@ inline u32 fixPointu_to_u32 (const tFixPointu x)
// 1/x * FIX_POINT
REALINLINE f32 fix_inverse32 ( const f32 x )
{
return FIX_POINT_F32_MUL / x;
}
#define fix_inverse32(x) (FIX_POINT_F32_MUL / (x))
/*
......@@ -483,11 +480,11 @@ static inline int f_round2(f32 f)
convert f32 to Fix Point.
multiply is needed anyway, so scale mulby
*/
REALINLINE tFixPoint tofix (const f32 x, const f32 mulby = FIX_POINT_F32_MUL )
REALINLINE tFixPoint tofix0 (const f32 x, const f32 mulby = FIX_POINT_F32_MUL )
{
return (tFixPoint) (x * mulby);
}
#define tofix(x,y) (tFixPoint)(x * y)
/*
Fix Point , Fix Point Multiply
......@@ -820,7 +817,7 @@ inline void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b,
(tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B );
}
inline void getSample_texture ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b,
inline void getSample_texture ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b,
const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty
)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment