burningvideo 0.54

removed CTRGouraudAlpha2.cpp
added CTRParallaxMap.cpp

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6371 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
engineer_apple 2022-05-03 20:47:32 +00:00
parent 9db39e8534
commit 21e2569e5b
38 changed files with 1922 additions and 1066 deletions

@ -70,7 +70,7 @@ bool CMainMenu::run()
gui::IGUIListBox* box = guienv->addListBox(core::rect<int>(10,10,220,120), optTab, 1);
box->addItem(L"OpenGL 1.5");
box->addItem(L"Direct3D 9.0c");
box->addItem(L"Burning's Video 0.53");
box->addItem(L"Burning's Video 0.54");
box->addItem(L"Irrlicht Software Renderer 1.0");
switch (driverType )
{

@ -108,7 +108,6 @@ bool mat44_transposed_inverse(irr::core::CMatrix4<T>& out, const irr::core::CMat
}
#endif
#if 0
// difference to CMatrix4<T>::getInverse . higher precision in determinant. return identity on failure
template <class T>
bool mat44_inverse(irr::core::CMatrix4<T>& out, const irr::core::CMatrix4<T>& M)
@ -153,7 +152,7 @@ bool mat44_inverse(irr::core::CMatrix4<T>& out, const irr::core::CMatrix4<T>& M)
return true;
}
#endif
// void CMatrix4<T>::transformVec4(T *out, const T * in) const
template <class T>
@ -167,6 +166,15 @@ inline void transformVec4Vec4(const irr::core::CMatrix4<T>& m, T* burning_restri
out[3] = in[0] * M[3] + in[1] * M[7] + in[2] * M[11] + in[3] * M[15];
}
template <class T>
inline void transformVec3Vec3(const irr::core::CMatrix4<T>& m, T* burning_restrict out, const T* burning_restrict in)
{
const T* burning_restrict M = m.pointer();
out[0] = in[0] * M[0] + in[1] * M[4] + in[2] * M[8] + M[12];
out[1] = in[0] * M[1] + in[1] * M[5] + in[2] * M[9] + M[13];
out[2] = in[0] * M[2] + in[1] * M[6] + in[2] * M[10] + M[14];
}
#if 0
// void CMatrix4<T>::transformVect(T *out, const core::vector3df &in) const
template <class T>
@ -256,6 +264,11 @@ static inline float dot(const irr::video::sVec4& a, const irr::video::sVec4& b)
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}
static inline float inversesqrt(const float x )
{
return x!= 0.f ? 1.f / sqrtf(x) : 0.f;
}
static inline irr::video::sVec4 operator-(const irr::video::sVec4& a)
{
@ -619,7 +632,7 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters&
BurningShader[ETR_TEXTURE_GOURAUD_ALPHA] = createTRTextureGouraudAlpha(this);
BurningShader[ETR_TEXTURE_GOURAUD_ALPHA_NOZ] = createTRTextureGouraudAlphaNoZ(this);
BurningShader[ETR_NORMAL_MAP_SOLID] = createTRNormalMap(this);
//BurningShader[ETR_NORMAL_MAP_SOLID] = createTRNormalMap(this, EMT_NORMAL_MAP_SOLID);
BurningShader[ETR_STENCIL_SHADOW] = createTRStencilShadow(this);
BurningShader[ETR_TEXTURE_BLEND] = createTRTextureBlend(this);
@ -651,12 +664,28 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters&
addMaterialRenderer(tmr); // EMT_TRANSPARENT_ALPHA_CHANNEL_REF,
addMaterialRenderer(tmr); // EMT_TRANSPARENT_VERTEX_ALPHA,
addMaterialRenderer(tmr); // EMT_TRANSPARENT_REFLECTION_2_LAYER,
#if 0
addMaterialRenderer(smr); // EMT_NORMAL_MAP_SOLID,
addMaterialRenderer(tmr); // EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR,
addMaterialRenderer(tmr); // EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA,
addMaterialRenderer(smr); // EMT_PARALLAX_MAP_SOLID,
addMaterialRenderer(tmr); // EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR,
addMaterialRenderer(tmr); // EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA,
#else
// add normal map renderers
s32 tmp = 0;
video::IMaterialRenderer* renderer = 0;
renderer = createTRNormalMap(this, tmp, EMT_NORMAL_MAP_SOLID); renderer->drop();
renderer = createTRNormalMap(this, tmp, EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); renderer->drop();
renderer = createTRNormalMap(this, tmp, EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); renderer->drop();
renderer = createTRParallaxMap(this, tmp, EMT_PARALLAX_MAP_SOLID); renderer->drop();
renderer = createTRParallaxMap(this, tmp, EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); renderer->drop();
renderer = createTRParallaxMap(this, tmp, EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); renderer->drop();
#endif
addMaterialRenderer(tmr); // EMT_ONETEXTURE_BLEND
smr->drop();
@ -820,6 +849,9 @@ void CBurningVideoDriver::transform_calc(E_TRANSFORMATION_STATE_BURNING_VIDEO st
case ETS_NORMAL:
ok = flag[ETS_MODEL_VIEW] & ETF_VALID;
break;
case ETS_MODEL_INVERSE:
ok = flag[ETS_WORLD] & ETF_VALID;
break;
default:
break;
}
@ -827,7 +859,7 @@ void CBurningVideoDriver::transform_calc(E_TRANSFORMATION_STATE_BURNING_VIDEO st
if (!ok)
{
char buf[256];
sprintf(buf, "transform_calc not valid for %d\n", state);
sprintf(buf, "transform_calc not valid for %d", state);
os::Printer::log(buf, ELL_WARNING);
}
@ -862,6 +894,16 @@ void CBurningVideoDriver::transform_calc(E_TRANSFORMATION_STATE_BURNING_VIDEO st
case ETS_NORMAL:
mat33_transposed_inverse(matrix[state], matrix[ETS_MODEL_VIEW]);
break;
case ETS_MODEL_INVERSE:
if (flag[ETS_WORLD] & ETF_IDENTITY)
{
matrix[state] = matrix[ETS_WORLD];
}
else
{
mat44_inverse(matrix[state], matrix[ETS_WORLD]);
}
break;
default:
break;
@ -917,6 +959,7 @@ void CBurningVideoDriver::setTransform(E_TRANSFORMATION_STATE state, const core:
flag[ETS_MODEL_VIEW_PROJ] &= ~ETF_VALID;
flag[ETS_MODEL_VIEW] &= ~ETF_VALID;
flag[ETS_NORMAL] &= ~ETF_VALID;
flag[ETS_MODEL_INVERSE] &= ~ETF_VALID;
break;
case ETS_TEXTURE_0:
case ETS_TEXTURE_1:
@ -1739,7 +1782,6 @@ f32 MipmapLevel(const sVec2& uv, const sVec2& textureSize)
}
#endif
//#define MAT_TEXTURE(tex) ( (video::CSoftwareTexture2*) Material.org.getTexture ( (u32)tex ) )
#define MAT_TEXTURE(tex) ( (video::CSoftwareTexture2*) Material.org.TextureLayer[tex].Texture )
//! clamp(value,0,1)
@ -1904,46 +1946,59 @@ void CBurningVideoDriver::VertexCache_map_source_format()
SVSize* vSize = VertexShader.vSize;
//vSize[E4VT_STANDARD].Format = VERTEX4D_FORMAT_TEXTURE_1 | VERTEX4D_FORMAT_COLOR_1 | VERTEX4D_FORMAT_LIGHT_1 | VERTEX4D_FORMAT_SPECULAR;
vSize[E4VT_STANDARD].Format = VERTEX4D_FORMAT_TEXTURE_1 | VERTEX4D_FORMAT_COLOR_2_FOG;
vSize[E4VT_STANDARD].Pitch = sizeof(S3DVertex);
vSize[E4VT_STANDARD].TexSize = 1;
vSize[E4VT_STANDARD].TexCooSize = 1;
vSize[E4VT_STANDARD].ColSize = 2;
vSize[E4VT_2TCOORDS].Format = VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_2_FOG;
vSize[E4VT_2TCOORDS].Pitch = sizeof(S3DVertex2TCoords);
vSize[E4VT_2TCOORDS].TexSize = 2;
vSize[E4VT_2TCOORDS].TexCooSize = 2;
vSize[E4VT_2TCOORDS].ColSize = 2;
//vSize[E4VT_TANGENTS].Format = VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_1 | VERTEX4D_FORMAT_LIGHT_1 | VERTEX4D_FORMAT_BUMP_DOT3;
vSize[E4VT_TANGENTS].Format = VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_2_FOG | VERTEX4D_FORMAT_LIGHT_1 | VERTEX4D_FORMAT_BUMP_DOT3;
// EMT_NORMAL_MAP_SOLID,EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR,EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA
vSize[E4VT_TANGENTS].Format = VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_4 | VERTEX4D_FORMAT_BUMP_DOT3;
vSize[E4VT_TANGENTS].Pitch = sizeof(S3DVertexTangents);
vSize[E4VT_TANGENTS].TexSize = 2;
vSize[E4VT_TANGENTS].TexCooSize = 2;
vSize[E4VT_TANGENTS].ColSize = 4;
// reflection map
// EMT_PARALLAX_MAP_SOLID,EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR,EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA
vSize[E4VT_TANGENTS_PARALLAX].Format = VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_4 | VERTEX4D_FORMAT_PARALLAX;
vSize[E4VT_TANGENTS_PARALLAX].Pitch = sizeof(S3DVertexTangents);
vSize[E4VT_TANGENTS_PARALLAX].TexSize = 2;
vSize[E4VT_TANGENTS_PARALLAX].TexCooSize = 2;
vSize[E4VT_TANGENTS_PARALLAX].ColSize = 4;
// EMT_TRANSPARENT_REFLECTION_2_LAYER map
vSize[E4VT_REFLECTION_MAP].Format = VERTEX4D_FORMAT_TEXTURE_2 | VERTEX4D_FORMAT_COLOR_2_FOG;
vSize[E4VT_REFLECTION_MAP].Pitch = sizeof(S3DVertex);
vSize[E4VT_REFLECTION_MAP].TexSize = 2;
vSize[E4VT_REFLECTION_MAP].TexCooSize = 1; //TexCoo2 generated
vSize[E4VT_REFLECTION_MAP].ColSize = 2;
// shadow
vSize[E4VT_SHADOW].Format = 0;
vSize[E4VT_SHADOW].Pitch = sizeof(f32) * 3; // core::vector3df*
vSize[E4VT_SHADOW].TexSize = 0;
vSize[E4VT_SHADOW].TexCooSize = 0;
vSize[E4VT_SHADOW].ColSize = 0;
// color shading only (no texture)
vSize[E4VT_NO_TEXTURE].Format = VERTEX4D_FORMAT_COLOR_1 | VERTEX4D_FORMAT_LIGHT_1 | VERTEX4D_FORMAT_SPECULAR;
vSize[E4VT_NO_TEXTURE].Format = VERTEX4D_FORMAT_COLOR_2_FOG;
vSize[E4VT_NO_TEXTURE].Pitch = sizeof(S3DVertex);
vSize[E4VT_NO_TEXTURE].TexSize = 0;
vSize[E4VT_NO_TEXTURE].TexCooSize = 0;
vSize[E4VT_NO_TEXTURE].ColSize = 2;
//Line
vSize[E4VT_LINE].Format = VERTEX4D_FORMAT_COLOR_1;
vSize[E4VT_LINE].Pitch = sizeof(S3DVertex);
vSize[E4VT_LINE].TexSize = 0;
vSize[E4VT_LINE].TexCooSize = 0;
vSize[E4VT_LINE].ColSize = 1;
//verify with global defines
u32 size;
@ -1952,7 +2007,7 @@ void CBurningVideoDriver::VertexCache_map_source_format()
u32& flag = vSize[i].Format;
#if !defined(SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR)
flag &= ~VERTEX4D_FORMAT_SPECULAR;
//flag &= ~VERTEX4D_FORMAT_SPECULAR;
#endif
if (vSize[i].TexSize > BURNING_MATERIAL_MAX_TEXTURES)
@ -2036,9 +2091,29 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest
sVec4 gl_Color; gl_Color.setA8R8G8B8(base->Color.color);
// Irrlicht TCoords and TCoords2 must be contiguous memory. baseTCoord has no 4 byte aligned start address!
sVec4 gl_MultiTexCoord0(base->TCoords.X, base->TCoords.Y, 1.f, 1.f);
sVec4 gl_MultiTexCoord1(((S3DVertex2TCoords*)source)->TCoords2.X, ((S3DVertex2TCoords*)source)->TCoords2.Y, 1.f, 1.f);
sVec4 gl_MultiTexCoord[4];
const sVec2Pack* baseTCoord = (const sVec2Pack*)&base->TCoords.X;
for (u32 m = 0; m < array_size(gl_MultiTexCoord); ++m)
{
if (m < VertexShader.vSize[VertexShader.vType].TexCooSize)
{
gl_MultiTexCoord[m].s = baseTCoord[m].x;
gl_MultiTexCoord[m].t = baseTCoord[m].y;
}
else
{
gl_MultiTexCoord[m].s = 0.f;
gl_MultiTexCoord[m].t = 0.f;
}
gl_MultiTexCoord[m].p = 1.f;
gl_MultiTexCoord[m].q = 1.f;
}
#define gl_MultiTexCoord0 gl_MultiTexCoord[0]
#define gl_MultiTexCoord1 gl_MultiTexCoord[1]
#define gl_MultiTexCoord2 gl_MultiTexCoord[2]
#define gl_MultiTexCoord3 gl_MultiTexCoord[3]
#define gl_Position dest->Pos
#define gl_TexCoord dest->Tex
#define gl_FrontColor dest->Color[0]
@ -2052,9 +2127,6 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest
#define gl_ModelViewProjectionMatrix matrix[ETS_MODEL_VIEW_PROJ]
#define ftransform() (matrix[ETS_MODEL_VIEW_PROJ] * gl_Vertex)
//#define uniform(var,name) const var& name = shader->uniform_##var(#name)
//#define varying(var,name) var name = shader->varying_##var(#name)
#define uniform(var,name) const var& name = (const var&)*shader->getUniform(#name,BL_VERTEX_FLOAT)
#define varying(var,name) var& name = (var&)*shader->getUniform(#name,BL_FRAGMENT_FLOAT)
@ -2198,12 +2270,66 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest
normal = normalize(gl_Normal);
lightdir2 = normalize(lightdir);
}
else if (Material.VertexShader == STK_1303_0xd872cdb6)
{
// Shader based on work by Fabien Sanglard
// Released under the terms of CC-BY 3.0
varying(vec3,lightVec);
varying(vec3,halfVec);
varying(vec3,eyeVec);
uniform(vec3,lightdir);
//void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
// Building the matrix Eye Space -> Tangent Space
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
// gl_MultiTexCoord1.xyz
vec3 t = normalize(gl_NormalMatrix * vec3(1.0, 0.0, 0.0)); // tangent
vec3 b = cross(n, t);
vec3 vertexPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
// transform light and half angle vectors by tangent basis
vec3 v;
v.x = dot(lightdir, t);
v.y = dot(lightdir, b);
v.z = dot(lightdir, n);
lightVec = normalize(v);
vertexPosition = normalize(vertexPosition);
eyeVec = normalize(-vertexPosition); // we are in Eye Coordinates, so EyePos is (0,0,0)
// Normalize the halfVector to pass it to the fragment shader
// No need to divide by two, the result is normalized anyway.
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
vec3 halfVector = normalize(vertexPosition + lightdir);
v.x = dot(halfVector, t);
v.y = dot(halfVector, b);
v.z = dot(halfVector, n);
// No need to normalize, t,b,n and halfVector are normal vectors.
//normalize (v);
halfVec = v;
gl_Position = ftransform();
}
}
#ifdef _MSC_VER
#pragma warning (default: 4244) // conversion
#pragma warning (default: 4305) // truncation
#endif
#undef gl_MultiTexCoord0
#undef gl_MultiTexCoord1
#undef gl_MultiTexCoord2
#undef gl_MultiTexCoord3
#undef vec2
#undef vec3
#undef vec4
@ -2335,7 +2461,7 @@ fftransform:
break;
}
sVec4* a = dest->Color + ((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_COLOR_2_FOG) ? 1 : 0);
sVec4* a = dest->Color + (((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_MASK_COLOR)>=VERTEX4D_FORMAT_COLOR_2_FOG) ? 1 : 0);
a->a = clampf01(fog_factor);
}
@ -2497,42 +2623,71 @@ fftransform:
#if BURNING_MATERIAL_MAX_LIGHT_TANGENT > 0
if ((EyeSpace.TL_Flag & TL_LIGHT0_IS_NORMAL_MAP) &&
((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_MASK_TANGENT) == VERTEX4D_FORMAT_BUMP_DOT3)
((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_MASK_TANGENT) >= VERTEX4D_FORMAT_BUMP_DOT3)
)
{
const S3DVertexTangents* tangent = ((S3DVertexTangents*)source);
sVec4 vp;
sVec4 light_accu;
light_accu.x = 0.f;
light_accu.y = 0.f;
light_accu.z = 0.f;
light_accu.w = 0.f;
for (u32 i = 0; i < 2 && i < EyeSpace.Light.size(); ++i)
light_accu.set(0.f);
/*
* Color[0] lightcolor[0] a: vertexalpha
* Color[1] lightcolor[1] a: fogdistance
* Color[2] lightvector[0]
* Color[3] lightvector[1]
* LightVector[0] eyevector
*/
if ((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_MASK_TANGENT) >= VERTEX4D_FORMAT_PARALLAX)
{
vp.x = EyeSpace.leye.x - base->Pos.X;
vp.y = EyeSpace.leye.y - base->Pos.Y;
vp.z = EyeSpace.leye.z - base->Pos.Z;
light_accu.x = vp.dot(tangent->Tangent);
light_accu.y = -vp.dot(tangent->Binormal);
light_accu.z = -vp.dot(tangent->Normal);
light_accu.normalize_pack_xyz(dest->LightTangent[0], 1.f, 0.f);
}
const u32 maxLight = core::min_((u32)BURNING_MATERIAL_MAX_COLORS,(u32)2, EyeSpace.Light.size());
for (u32 i = 0; i < maxLight; ++i)
{
const SBurningShaderLight& light = EyeSpace.Light[i];
if (!light.LightIsOn)
continue;
// lightcolor with standard model
// but shader is different. treating light and vertex in same space
#if 1
vp.x = light.pos.x - base->Pos.X;
vp.y = light.pos.y - base->Pos.Y;
vp.z = light.pos.z - base->Pos.Z;
#else
vp.x = light.pos4.x - EyeSpace.vertex.x;
vp.y = light.pos4.y - EyeSpace.vertex.y;
vp.z = light.pos4.z - EyeSpace.vertex.z;
#endif
vp.x = light.pos_local.x - base->Pos.X;
vp.y = light.pos_local.y - base->Pos.Y;
vp.z = light.pos_local.z - base->Pos.Z;
// transform by tangent matrix
f32 attenuation = inversesqrt(vp.dot_xyz(vp) * light.nmap_linearAttenuation);
dest->Color[i].r = light.DiffuseColor.r * attenuation;
dest->Color[i].g = light.DiffuseColor.g * attenuation;
dest->Color[i].b = light.DiffuseColor.b * attenuation;
dest->Color[i].clampf01();
// lightvector transform by tangent matrix
#if BURNING_MATERIAL_MAX_COLORS >=4
dest->Color[2+i].x = vp.dot(tangent->Tangent);
dest->Color[2+i].y = vp.dot(tangent->Binormal);
dest->Color[2+i].z = vp.dot(tangent->Normal);
dest->Color[2 + i].normalize_dir_xyz_zero();
#else
light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z);
light_accu.y += (vp.x * tangent->Binormal.X + vp.y * tangent->Binormal.Y + vp.z * tangent->Binormal.Z);
light_accu.z += (vp.x * tangent->Normal.X + vp.y * tangent->Normal.Y + vp.z * tangent->Normal.Z);
#endif
}
#if BURNING_MATERIAL_MAX_COLORS >=4
#else
//normalize [-1,+1] to [0,1] -> obsolete
light_accu.normalize_pack_xyz(dest->LightTangent[0], 1.f, 0.f);
#endif
dest->Tex[1].x = dest->Tex[0].x;
dest->Tex[1].y = dest->Tex[0].y;
@ -2887,6 +3042,11 @@ int CBurningVideoDriver::VertexCache_reset(const void* vertices, u32 vertexCount
switch (Material.org.MaterialType) // (Material.Fallback_MaterialType)
{
case EMT_PARALLAX_MAP_SOLID:
case EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR:
case EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA:
VertexShader.vType = vType == EVT_TANGENTS ? E4VT_TANGENTS_PARALLAX : (e4DVertexType)vType;
break;
case EMT_REFLECTION_2_LAYER:
case EMT_TRANSPARENT_REFLECTION_2_LAYER:
VertexShader.vType = vType == EVT_STANDARD ? E4VT_REFLECTION_MAP : (e4DVertexType)vType;
@ -2937,12 +3097,7 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert
return;
pushShader(pType, 1);
/*
if ((u32)Material.org.MaterialType < MaterialRenderers.size())
{
MaterialRenderers[Material.org.MaterialType].Renderer->OnRender(this, vType);
}
*/
//Matrices needed for this primitive
transform_calc(ETS_MODEL_VIEW_PROJ);
if ((EyeSpace.TL_Flag & (TL_TEXTURE_TRANSFORM | TL_FOG | TL_LIGHT)) ||
@ -2952,6 +3107,37 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert
transform_calc(ETS_NORMAL);
}
//objectspace
if (EyeSpace.TL_Flag & TL_LIGHT0_IS_NORMAL_MAP)
{
transform_calc(ETS_MODEL_INVERSE);
const core::matrix4* matrix = Transformation[TransformationStack];
if ((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_MASK_TANGENT) >= VERTEX4D_FORMAT_PARALLAX)
{
transform_calc(ETS_MODEL_VIEW);
mat44_inverse(EyeSpace.mvi, matrix[ETS_MODEL_VIEW]);
sVec4 eye(0.f, 0.f, 0.f, 1.f);
transformVec3Vec3(EyeSpace.mvi, &EyeSpace.leye.x, &eye.x);
}
const u32 maxLight = core::min_((u32)BURNING_MATERIAL_MAX_COLORS, (u32)2, EyeSpace.Light.size());
for (u32 i = 0; i < maxLight; ++i)
{
SBurningShaderLight& light = EyeSpace.Light[i];
if (!light.LightIsOn)
continue;
transformVec3Vec3(matrix[ETS_MODEL_INVERSE], &light.pos_local.x, &light.pos.x);
}
}
if ((u32)Material.org.MaterialType < MaterialRenderers.size())
{
MaterialRenderers[Material.org.MaterialType].Renderer->OnRender(this, (video::E_VERTEX_TYPE)VertexShader.vType);
}
s4DVertexPair* face[4];
@ -3087,106 +3273,72 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert
continue; //not break; per clipper triangle
// mipmap2
#if 1
// select mipmap
#if BURNING_MAX_MIP_CLIPPER == 1
if (probe == use_max_mip)
if (probe == use_max_mip)
#endif
for (u32 m = 0; m < VertexShader.vSize[VertexShader.vType].TexSize; ++m)
{
video::CSoftwareTexture2* tex = MAT_TEXTURE(m);
const sVec2& v0 = (face[0] + s4DVertex_ofs(0))->Tex[m];
const sVec2& v1 = (face[1] + s4DVertex_ofs(0))->Tex[m];
const sVec2& v2 = (face[2] + s4DVertex_ofs(0))->Tex[m];
//todo: get triangle setup here
//bbox
t[0] = t[2] = v0.x;
t[1] = t[3] = v0.y;
if (v1.x < t[0]) t[0] = v1.x;
if (v1.y < t[1]) t[1] = v1.y;
if (v1.x > t[2]) t[2] = v1.x;
if (v1.y > t[3]) t[3] = v1.y;
if (v2.x < t[0]) t[0] = v2.x;
if (v2.y < t[1]) t[1] = v2.y;
if (v2.x > t[2]) t[2] = v2.x;
if (v2.y > t[3]) t[3] = v2.y;
f32 tex_area = fabsf((t[2] - t[0]) * (t[3] - t[1]));
//tex_area = |a.x * b.y - b.x * a.y| * 0.5; // crossproduct
//f32 tex_area = fabsf((v1.x - v0.x) * (v2.y - v0.y) - (v2.x - v0.x) * (v1.y - v0.y));
//various over and underflow cases
if (tex_area <= 0.000001f)
tex_area = 0.000001f;
else if (tex_area > 1.01f)
tex_area = 1.f / tex_area;
/* 2.f * tex_area * 1.6f bias. 1.6 too much for detailsmap3 */
//not dc_area * 0.5 cancel out 2 * TexBias
const u32 dc_area_over_tex_area = (u32)floorf( /*/tex_area > 0.0000001f ? */
fabsf(dc_area.f) * TexBias[TransformationStack] / tex_area
/*: 0.f*/
);
// get a near 1:1 ratio between pixel and texel
// tex_area * b[lodFactor].w * b[lodFactor].h > dc_area_abs
s32 lodFactor = 0;
const CSoftwareTexture2_Bound* b = tex->getTexBound_index();
while (lodFactor < SOFTWARE_DRIVER_2_MIPMAPPING_MAX &&
b[lodFactor].area > dc_area_over_tex_area
)
{
lodFactor += 1;
}
//clipped triangle should take single area based mipmap from unclipped face
//skybox,billboard test case
//if (vertex_from_clipper) lodFactor -= 1;
if (has_vertex_run == 0) lod_max[m] = lodFactor;
else if (lodFactor < lod_max[m]) lod_max[m] = lodFactor;
//CurrentShader->setTextureParam(m, tex, lodFactor);
//select_polygon_mipmap_inside(face, m, tex->getTexBound());
}
#else
//select mipmap ratio between drawing space and texture space (for multiply divide here)
dc_area.f = reciprocal_zero(dc_area.f);
// select mipmap
for (u32 m = 0; m < VertexShader.vSize[VertexShader.vType].TexSize; ++m)
{
video::CSoftwareTexture2* tex = MAT_TEXTURE(m);
//only guessing: take more detail (lower mipmap) in light+bump textures
f32 lod_bias = 0.100f;// core::clamp(map_value((f32)ScreenSize.Width * ScreenSize.Height, 160 * 120, 640 * 480, 1.f / 8.f, 1.f / 8.f), 0.01f, 1.f);
const sVec2& v0 = (face[0] + s4DVertex_ofs(0))->Tex[m];
const sVec2& v1 = (face[1] + s4DVertex_ofs(0))->Tex[m];
const sVec2& v2 = (face[2] + s4DVertex_ofs(0))->Tex[m];
//assume transparent add is ~50% transparent -> more detail
switch (Material.org.MaterialType)
//todo: get triangle setup here
//bbox
t[0] = t[2] = v0.x;
t[1] = t[3] = v0.y;
if (v1.x < t[0]) t[0] = v1.x;
if (v1.y < t[1]) t[1] = v1.y;
if (v1.x > t[2]) t[2] = v1.x;
if (v1.y > t[3]) t[3] = v1.y;
if (v2.x < t[0]) t[0] = v2.x;
if (v2.y < t[1]) t[1] = v2.y;
if (v2.x > t[2]) t[2] = v2.x;
if (v2.y > t[3]) t[3] = v2.y;
f32 tex_area = fabsf((t[2] - t[0]) * (t[3] - t[1]));
//tex_area = |a.x * b.y - b.x * a.y| * 0.5; // crossproduct
//f32 tex_area = fabsf((v1.x - v0.x) * (v2.y - v0.y) - (v2.x - v0.x) * (v1.y - v0.y));
//various over and underflow cases
if (tex_area <= 0.000001f)
tex_area = 0.000001f;
else if (tex_area > 1.01f)
tex_area = 1.f / tex_area;
/* 2.f * tex_area * 1.6f bias. 1.6 too much for detailsmap3 */
//not dc_area * 0.5 cancel out 2 * TexBias
const u32 dc_area_over_tex_area = (u32)floorf( /*/tex_area > 0.0000001f ? */
fabsf(dc_area.f) * TexBias[TransformationStack] / tex_area
/*: 0.f*/
);
// get a near 1:1 ratio between pixel and texel
// tex_area * b[lodFactor].w * b[lodFactor].h > dc_area_abs
s32 lodFactor = 0;
const CSoftwareTexture2_Bound* b = tex->getTexBound_index();
while (lodFactor < SOFTWARE_DRIVER_2_MIPMAPPING_MAX &&
b[lodFactor].area > dc_area_over_tex_area
)
{
case EMT_TRANSPARENT_ADD_COLOR:
case EMT_TRANSPARENT_ALPHA_CHANNEL:
lod_bias *= 0.5f;
break;
default:
break;
lodFactor += 1;
}
lod_bias *= tex->get_lod_bias();
//lod_bias += Material.org.TextureLayer[m].LODBias * 0.125f;
s32 lodFactor = lodFactor_inside(face, m, dc_area.f, lod_bias);
//clipped triangle should take single area based mipmap from unclipped face
//skybox,billboard test case
//if (vertex_from_clipper) lodFactor -= 1;
if (has_vertex_run == 0) lod_max[m] = lodFactor;
else if (lodFactor < lod_max[m]) lod_max[m] = lodFactor;
CurrentShader->setTextureParam(m, tex, lodFactor);
//currently shader receives texture coordinate as Pixelcoo of 1 Texture
select_polygon_mipmap_inside(face, m, tex->getTexBound());
//CurrentShader->setTextureParam(m, tex, lodFactor);
//select_polygon_mipmap_inside(face, m, tex->getTexBound());
}
#endif
}
//else /* if (VertexShader.primitiveHasVertex == 3) */
#if BURNING_MAX_MIP_CLIPPER == 1
@ -3349,6 +3501,7 @@ void CBurningVideoDriver::assignHardwareLight(SBurningShaderLight& l, const SLig
transformVec4Vec4(matrix[ETS_MODEL_VIEW], &l.pos4.x, &l.pos.x);
rotateMat44Vec3Vec4(matrix[ETS_MODEL_VIEW], &l.spotDirection4.x, &l.spotDirection.x);
l.nmap_linearAttenuation = 1.f / (0.001f + dl.Radius * dl.Radius);
/*
//case ELT_DIRECTIONAL:
@ -3432,13 +3585,14 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
const SMaterial& in = Material.org;
const u32 shaderid = (u32)in.MaterialType;
//basically set always. 2d does its own compare
//if (TransformationStack == ETF_STACK_2D || Material.resetRenderStates || compare_3d_material(Material.lastMaterial,in))
{
// ---------- Notify Shader
// unset old material
u32 shaderid_old = (u32)Material.lastMaterial.MaterialType;
u32 shaderid = (u32)in.MaterialType;
if (shaderid != shaderid_old && shaderid_old < MaterialRenderers.size())
{
@ -3470,7 +3624,8 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
EyeSpace.TL_Flag &= ~(TL_TEXTURE_TRANSFORM | TL_LIGHT0_IS_NORMAL_MAP);
#ifdef SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM
for (u32 m = 0; m < VertexShader.vSize[VertexShader.vType].TexSize; ++m)
//vertextype not set!
for (u32 m = 0; m < BURNING_MATERIAL_MAX_TEXTURES /*VertexShader.vSize[VertexShader.vType].TexSize*/; ++m)
{
flag[ETS_TEXTURE_0 + m] &= ~ETF_TEXGEN_MASK;
setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + m), in.getTextureMatrix(m));
@ -3520,7 +3675,7 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
EBurningFFShader shader = Material.depth_test ? ETR_TEXTURE_GOURAUD : ETR_TEXTURE_GOURAUD_NOZ;
switch (Material.Fallback_MaterialType) //(Material.org.MaterialType)
switch (Material.Fallback_MaterialType) //(Material.org.MaterialType) // Material.Fallback_MaterialType)
{
case EMT_ONETEXTURE_BLEND:
shader = ETR_TEXTURE_BLEND;
@ -3604,6 +3759,7 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
{
shader = ETR_NORMAL_MAP_SOLID;
EyeSpace.TL_Flag |= TL_TEXTURE_TRANSFORM | TL_LIGHT0_IS_NORMAL_MAP;
EyeSpace.TL_Flag &= ~TL_LIGHT;
}
break;
case EMT_PARALLAX_MAP_SOLID:
@ -3611,8 +3767,9 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
case EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA:
if (texture1)
{
shader = ETR_NORMAL_MAP_SOLID;
shader = ETR_PARALLAX_MAP_SOLID;
EyeSpace.TL_Flag |= TL_TEXTURE_TRANSFORM | TL_LIGHT0_IS_NORMAL_MAP;
EyeSpace.TL_Flag &= ~TL_LIGHT;
}
break;
@ -3653,6 +3810,11 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
// switchToTriangleRenderer
CurrentShader = BurningShader[shader];
if (!CurrentShader && shaderid < MaterialRenderers.size())
{
CurrentShader = (IBurningShader *) MaterialRenderers[shaderid].Renderer;
}
if (CurrentShader)
{
CurrentShader->setTLFlag(EyeSpace.TL_Flag);
@ -3664,12 +3826,13 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
}
#if 0
{
u32 shaderid = (u32)Material.org.MaterialType;
//u32 shaderid = (u32)Material.org.MaterialType;
if (shaderid < MaterialRenderers.size())
MaterialRenderers[shaderid].Renderer->OnRender(this, (video::E_VERTEX_TYPE)VertexShader.vType);
}
#endif
}
@ -3913,7 +4076,7 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex* dest, const u32 vertexargb)
//separate specular
const sVec4& spec_mat = (EyeSpace.TL_Flag & TL_COLORMAT_SPECULAR) ? vertexColor : Material.SpecularColor;
#if defined(SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR)
if ((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_COLOR_2_FOG))
if ((VertexShader.vSize[VertexShader.vType].Format & VERTEX4D_FORMAT_MASK_COLOR)>=VERTEX4D_FORMAT_COLOR_2_FOG)
{
specular.sat_mul_xyz(dest->Color[1], spec_mat);
}
@ -4566,17 +4729,17 @@ void CBurningVideoDriver::pushShader(scene::E_PRIMITIVE_TYPE pType, int testCurr
const wchar_t* CBurningVideoDriver::getName() const
{
#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL
return L"Burning's Video 0.53 beautiful";
return L"Burning's Video 0.54 beautiful";
#elif defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
return L"Burning's Video 0.53 STK";
return L"Burning's Video 0.54 STK";
#elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST )
return L"Burning's Video 0.53 ultra fast";
return L"Burning's Video 0.54 ultra fast";
#elif defined ( BURNINGVIDEO_RENDERER_FAST )
return L"Burning's Video 0.53 fast";
return L"Burning's Video 0.54 fast";
#elif defined ( BURNINGVIDEO_RENDERER_CE )
return L"Burning's Video 0.53 CE";
return L"Burning's Video 0.54 CE";
#else
return L"Burning's Video 0.53";
return L"Burning's Video 0.54";
#endif
}

@ -365,6 +365,8 @@ namespace video
ETS_MODEL_VIEW,
ETS_NORMAL, //3x3 ModelView Transposed Inverse
ETS_MODEL_INVERSE, //normal,parallax
ETS_COUNT_BURNING = 16
};

@ -93,7 +93,7 @@ protected:
//! constructor
CTRGouraud2::CTRGouraud2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_SOLID)
{
#ifdef _DEBUG
setDebugName("CTRGouraud2");

@ -1,651 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#include "IBurningShader.h"
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
// compile flag for this file
#undef USE_ZBUFFER
#undef IPOL_Z
#undef CMP_Z
#undef WRITE_Z
#undef IPOL_W
#undef CMP_W
#undef WRITE_W
#undef SUBTEXEL
#undef INVERSE_W
#undef IPOL_C0
#undef IPOL_T0
#undef IPOL_T1
// define render case
#define SUBTEXEL
#define INVERSE_W
#define USE_ZBUFFER
#define IPOL_W
#define CMP_W
#define WRITE_W
#define IPOL_C0
//#define IPOL_T0
//#define IPOL_T1
// apply global override
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
#undef INVERSE_W
#endif
#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
#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
#endif
#define IPOL_Z
#ifdef CMP_W
#undef CMP_W
#define CMP_Z
#endif
#ifdef WRITE_W
#undef WRITE_W
#define WRITE_Z
#endif
#endif
namespace irr
{
namespace video
{
class CTRGouraudAlpha2 : public IBurningShader
{
public:
//! constructor
CTRGouraudAlpha2(CBurningVideoDriver* driver);
//! draws an indexed triangle list
virtual void drawTriangle ( const s4DVertex* burning_restrict a,const s4DVertex* burning_restrict b,const s4DVertex* burning_restrict c ) IRR_OVERRIDE;
private:
void fragmentShader();
};
//! constructor
CTRGouraudAlpha2::CTRGouraudAlpha2(CBurningVideoDriver* driver)
: IBurningShader(driver)
{
#ifdef _DEBUG
setDebugName("CTRGouraudAlpha2");
#endif
}
/*!
*/
void CTRGouraudAlpha2::fragmentShader()
{
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 = fill_convention_left( line.x[0] );
xEnd = fill_convention_right( line.x[1] );
dx = xEnd - xStart;
if ( dx < 0 )
return;
// slopes
const f32 invDeltaX = fill_step_x( 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
SOFTWARE_DRIVER_2_CLIPCHECK;
dst = (tVideoSample*)RenderTarget->getData() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
#ifdef USE_ZBUFFER
z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
#endif
#ifdef IPOL_C0
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint a0;
tFixPoint r0, g0, b0;
tFixPoint r1, g1, b1;
tFixPoint r2, g2, b2;
#endif
for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X)
{
#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 = reciprocal_zero( line.w[0] );
#endif
vec4_to_fix( a0, r0, g0, b0, line.c[0][0],inversew );
color_to_fix ( r1, g1, b1, dst[i] );
fix_color_norm(a0);
r2 = r1 + imulFix ( a0, r0 - r1 );
g2 = g1 + imulFix ( a0, g0 - g1 );
b2 = b1 + imulFix ( a0, b0 - b1 );
dst[i] = fix_to_sample( r2, g2, b2 );
#else
dst[i] = PrimitiveColor;
#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
}
}
void CTRGouraudAlpha2::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);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
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] = fill_step_y( ca );
scan.invDeltaY[1] = fill_step_y( ba );
scan.invDeltaY[2] = fill_step_y( cb );
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) < 0.f ? 1 : 0;
scan.right = 1 - scan.left;
// calculate slopes for the major edge
scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0];
scan.x[0] = a->Pos.x;
#ifdef IPOL_Z
scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0];
scan.z[0] = a->Pos.z;
#endif
#ifdef IPOL_W
scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0];
scan.w[0] = a->Pos.w;
#endif
#ifdef IPOL_C0
scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0];
scan.c[0][0] = a->Color[0];
#endif
#ifdef IPOL_T0
scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
scan.t[0][0] = a->Tex[0];
#endif
#ifdef IPOL_T1
scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0];
scan.t[1][0] = a->Tex[1];
#endif
// top left fill convention y run
s32 yStart;
s32 yEnd;
#ifdef SUBTEXEL
f32 subPixel;
#endif
// rasterize upper sub-triangle
if ( (f32) 0.0 != scan.invDeltaY[1] )
{
// calculate slopes for top edge
scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1];
scan.x[1] = a->Pos.x;
#ifdef IPOL_Z
scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1];
scan.z[1] = a->Pos.z;
#endif
#ifdef IPOL_W
scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1];
scan.w[1] = a->Pos.w;
#endif
#ifdef IPOL_C0
scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1];
scan.c[0][1] = a->Color[0];
#endif
#ifdef IPOL_T0
scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
scan.t[0][1] = a->Tex[0];
#endif
#ifdef IPOL_T1
scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1];
scan.t[1][1] = a->Tex[1];
#endif
// apply top-left fill convention, top part
yStart = fill_convention_top( a->Pos.y );
yEnd = fill_convention_down( b->Pos.y );
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
// correct to pixel center
scan.x[0] += scan.slopeX[0] * subPixel;
scan.x[1] += scan.slopeX[1] * subPixel;
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0] * subPixel;
scan.z[1] += scan.slopeZ[1] * subPixel;
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0] * subPixel;
scan.w[1] += scan.slopeW[1] * subPixel;
#endif
#ifdef IPOL_C0
scan.c[0][0] += scan.slopeC[0][0] * subPixel;
scan.c[0][1] += scan.slopeC[0][1] * subPixel;
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0] * subPixel;
scan.t[1][1] += scan.slopeT[1][1] * subPixel;
#endif
#endif
// rasterize the edge scanlines
for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y)
{
line.x[scan.left] = scan.x[0];
line.x[scan.right] = scan.x[1];
#ifdef IPOL_Z
line.z[scan.left] = scan.z[0];
line.z[scan.right] = scan.z[1];
#endif
#ifdef IPOL_W
line.w[scan.left] = scan.w[0];
line.w[scan.right] = scan.w[1];
#endif
#ifdef IPOL_C0
line.c[0][scan.left] = scan.c[0][0];
line.c[0][scan.right] = scan.c[0][1];
#endif
#ifdef IPOL_T0
line.t[0][scan.left] = scan.t[0][0];
line.t[0][scan.right] = scan.t[0][1];
#endif
#ifdef IPOL_T1
line.t[1][scan.left] = scan.t[1][0];
line.t[1][scan.right] = scan.t[1][1];
#endif
// render a scanline
if_interlace_scanline fragmentShader();
scan.x[0] += scan.slopeX[0];
scan.x[1] += scan.slopeX[1];
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0];
scan.z[1] += scan.slopeZ[1];
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0];
scan.w[1] += scan.slopeW[1];
#endif
#ifdef IPOL_C0
scan.c[0][0] += scan.slopeC[0][0];
scan.c[0][1] += scan.slopeC[0][1];
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0];
scan.t[0][1] += scan.slopeT[0][1];
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0];
scan.t[1][1] += scan.slopeT[1][1];
#endif
}
}
// rasterize lower sub-triangle
if ( (f32) 0.0 != scan.invDeltaY[2] )
{
// advance to middle point
if( (f32) 0.0 != scan.invDeltaY[1] )
{
temp[0] = b->Pos.y - a->Pos.y; // dy
scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0];
#ifdef IPOL_Z
scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0];
#endif
#ifdef IPOL_W
scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0];
#endif
#ifdef IPOL_C0
scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0];
#endif
#ifdef IPOL_T0
scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
#endif
#ifdef IPOL_T1
scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0];
#endif
}
// calculate slopes for bottom edge
scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2];
scan.x[1] = b->Pos.x;
#ifdef IPOL_Z
scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2];
scan.z[1] = b->Pos.z;
#endif
#ifdef IPOL_W
scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2];
scan.w[1] = b->Pos.w;
#endif
#ifdef IPOL_C0
scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2];
scan.c[0][1] = b->Color[0];
#endif
#ifdef IPOL_T0
scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
scan.t[0][1] = b->Tex[0];
#endif
#ifdef IPOL_T1
scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2];
scan.t[1][1] = b->Tex[1];
#endif
// apply top-left fill convention, top part
yStart = fill_convention_top( b->Pos.y );
yEnd = fill_convention_down( c->Pos.y );
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - b->Pos.y;
// correct to pixel center
scan.x[0] += scan.slopeX[0] * subPixel;
scan.x[1] += scan.slopeX[1] * subPixel;
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0] * subPixel;
scan.z[1] += scan.slopeZ[1] * subPixel;
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0] * subPixel;
scan.w[1] += scan.slopeW[1] * subPixel;
#endif
#ifdef IPOL_C0
scan.c[0][0] += scan.slopeC[0][0] * subPixel;
scan.c[0][1] += scan.slopeC[0][1] * subPixel;
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0] * subPixel;
scan.t[1][1] += scan.slopeT[1][1] * subPixel;
#endif
#endif
// rasterize the edge scanlines
for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y)
{
line.x[scan.left] = scan.x[0];
line.x[scan.right] = scan.x[1];
#ifdef IPOL_Z
line.z[scan.left] = scan.z[0];
line.z[scan.right] = scan.z[1];
#endif
#ifdef IPOL_W
line.w[scan.left] = scan.w[0];
line.w[scan.right] = scan.w[1];
#endif
#ifdef IPOL_C0
line.c[0][scan.left] = scan.c[0][0];
line.c[0][scan.right] = scan.c[0][1];
#endif
#ifdef IPOL_T0
line.t[0][scan.left] = scan.t[0][0];
line.t[0][scan.right] = scan.t[0][1];
#endif
#ifdef IPOL_T1
line.t[1][scan.left] = scan.t[1][0];
line.t[1][scan.right] = scan.t[1][1];
#endif
// render a scanline
if_interlace_scanline fragmentShader();
scan.x[0] += scan.slopeX[0];
scan.x[1] += scan.slopeX[1];
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0];
scan.z[1] += scan.slopeZ[1];
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0];
scan.w[1] += scan.slopeW[1];
#endif
#ifdef IPOL_C0
scan.c[0][0] += scan.slopeC[0][0];
scan.c[0][1] += scan.slopeC[0][1];
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0];
scan.t[0][1] += scan.slopeT[0][1];
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0];
scan.t[1][1] += scan.slopeT[1][1];
#endif
}
}
}
} // end namespace video
} // end namespace irr
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
namespace irr
{
namespace video
{
//! creates a flat triangle renderer
IBurningShader* createTriangleRendererGouraudAlpha2(CBurningVideoDriver* driver)
{
// ETR_GOURAUD_ALPHA unused
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CTRGouraudAlpha2(driver);
#else
return 0;
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
}
} // end namespace video
} // end namespace irr

@ -93,7 +93,7 @@ private:
//! constructor
CTRGouraudAlphaNoZ2::CTRGouraudAlphaNoZ2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_TRANSPARENT_ALPHA_CHANNEL)
{
#ifdef _DEBUG
setDebugName("CTRGouraudAlphaNoZ2");

@ -92,7 +92,7 @@ protected:
//! constructor
CTRGouraudNoZ2::CTRGouraudNoZ2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_SOLID)
{
#ifdef _DEBUG
setDebugName("CTRGouraudNoZ2");

@ -4,6 +4,7 @@
#include "IrrCompileConfig.h"
#include "IBurningShader.h"
#include "CSoftwareDriver2.h"
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
@ -22,6 +23,8 @@
#undef IPOL_C0
#undef IPOL_C1
#undef IPOL_C2
#undef IPOL_C3
#undef IPOL_T0
#undef IPOL_T1
#undef IPOL_T2
@ -38,9 +41,11 @@
#define IPOL_C0
#define IPOL_C1
#define IPOL_C2
#define IPOL_C3
#define IPOL_T0
#define IPOL_T1
#define IPOL_L0
//#define IPOL_L0
// apply global override
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
@ -90,26 +95,35 @@ class CTRNormalMap : public IBurningShader
public:
//! constructor
CTRNormalMap(CBurningVideoDriver* driver);
CTRNormalMap(CBurningVideoDriver* driver,s32& outMaterialTypeNr, E_MATERIAL_TYPE baseMaterial);
~CTRNormalMap();
//! draws an indexed triangle list
virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) IRR_OVERRIDE;
virtual void OnSetMaterial(const SBurningShaderMaterial& material) IRR_OVERRIDE;
virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData) IRR_OVERRIDE;
private:
void fragmentShader();
};
//! constructor
CTRNormalMap::CTRNormalMap(CBurningVideoDriver* driver)
: IBurningShader(driver)
CTRNormalMap::CTRNormalMap(CBurningVideoDriver* driver, s32& outMaterialTypeNr, E_MATERIAL_TYPE baseMaterial)
: IBurningShader(driver, baseMaterial)
{
#ifdef _DEBUG
setDebugName("CTRNormalMap");
#endif
CallBack = this;
outMaterialTypeNr = driver->addMaterialRenderer(this);
}
CTRNormalMap::~CTRNormalMap()
{
if (CallBack == this)
CallBack = 0;
}
void CTRNormalMap::OnSetMaterial(const SBurningShaderMaterial& material)
{
@ -174,6 +188,12 @@ void CTRNormalMap::fragmentShader()
#ifdef IPOL_C1
slopeC[1] = (line.c[1][1] - line.c[1][0]) * invDeltaX;
#endif
#ifdef IPOL_C2
slopeC[2] = (line.c[2][1] - line.c[2][0]) * invDeltaX;
#endif
#ifdef IPOL_C3
slopeC[3] = (line.c[3][1] - line.c[3][0]) * invDeltaX;
#endif
#ifdef IPOL_T0
slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
#endif
@ -201,6 +221,12 @@ void CTRNormalMap::fragmentShader()
#ifdef IPOL_C1
line.c[1][0] += slopeC[1] * subPixel;
#endif
#ifdef IPOL_C2
line.c[2][0] += slopeC[2] * subPixel;
#endif
#ifdef IPOL_C3
line.c[3][0] += slopeC[3] * subPixel;
#endif
#ifdef IPOL_T0
line.t[0][0] += slopeT[0] * subPixel;
#endif
@ -249,6 +275,10 @@ void CTRNormalMap::fragmentShader()
tFixPoint aFog = FIX_POINT_ONE;
#endif
#ifdef IPOL_C2
tFixPoint lx, ly, lz;
#endif
for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X)
{
@ -301,10 +331,13 @@ void CTRNormalMap::fragmentShader()
// normal map ( same texcoord0 but different mipmapping)
getSample_texture(r1, g1, b1, &IT[1], tx1, ty1);
// normal: xyz * 2 - 1
r1 = (r1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2 - 1);
g1 = (g1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2 - 1);
b1 = (b1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2 - 1);
//lightvector
#ifdef IPOL_L0
lx = tofix(line.l[0][0].x, inversew);
ly = tofix(line.l[0][0].y, inversew);
@ -314,18 +347,35 @@ void CTRNormalMap::fragmentShader()
//max(dot(LightVector, Normal), 0.0);
ndotl = clampfix_mincolor((imulFix_simple(r1, lx) + imulFix_simple(g1, ly) + imulFix_simple(b1, lz)));
#endif
lx = tofix(line.c[2][0].x, inversew);
ly = tofix(line.c[2][0].y, inversew);
lz = tofix(line.c[2][0].z, inversew);
//omit normalize
ndotl = clampfix_mincolor((imulFix_simple(r1, lx) + imulFix_simple(g1, ly) + imulFix_simple(b1, lz)));
#ifdef IPOL_C0
//LightColor[0]
r3 = tofix(line.c[0][0].r, inversew);
g3 = tofix(line.c[0][0].g, inversew);
b3 = tofix(line.c[0][0].b, inversew);
//LightColor[0] * lambert
r3 = imulFix_simple(tofix(line.c[0][0].r, inversew), ndotl);
g3 = imulFix_simple(tofix(line.c[0][0].g, inversew), ndotl);
b3 = imulFix_simple(tofix(line.c[0][0].b, inversew), ndotl);
// Lambert * LightColor[0] * Diffuse Texture;
r2 = imulFix(imulFix_simple(r3, ndotl), r0);
g2 = imulFix(imulFix_simple(g3, ndotl), g0);
b2 = imulFix(imulFix_simple(b3, ndotl), b0);
//lightvector1
lx = tofix(line.c[3][0].x, inversew);
ly = tofix(line.c[3][0].y, inversew);
lz = tofix(line.c[3][0].z, inversew);
//omit normalize
ndotl = clampfix_mincolor((imulFix_simple(r1, lx) + imulFix_simple(g1, ly) + imulFix_simple(b1, lz)));
//LightColor[1] * lambert
r3 += imulFix_simple(tofix(line.c[1][0].r, inversew), ndotl);
g3 += imulFix_simple(tofix(line.c[1][0].g, inversew), ndotl);
b3 += imulFix_simple(tofix(line.c[1][0].b, inversew), ndotl);
// (Lambert0 * LightColor[0] + Lambert1 * LightColor[1]) * Diffuse Texture;
r2 = clampfix_maxcolor(imulFix_simple(r3, r0));
g2 = clampfix_maxcolor(imulFix_simple(g3, g0));
b2 = clampfix_maxcolor(imulFix_simple(b3, b0));
//vertex alpha blend ( and omit depthwrite ,hacky..)
if (a3 + 2 < FIX_POINT_ONE)
@ -369,6 +419,12 @@ void CTRNormalMap::fragmentShader()
#ifdef IPOL_C1
line.c[1][0] += slopeC[1];
#endif
#ifdef IPOL_C2
line.c[2][0] += slopeC[2];
#endif
#ifdef IPOL_C3
line.c[3][0] += slopeC[3];
#endif
#ifdef IPOL_T0
line.t[0][0] += slopeT[0];
#endif
@ -438,6 +494,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][0] = a->Color[1];
#endif
#ifdef IPOL_C2
scan.slopeC[2][0] = (c->Color[2] - a->Color[2]) * scan.invDeltaY[0];
scan.c[2][0] = a->Color[2];
#endif
#ifdef IPOL_C3
scan.slopeC[3][0] = (c->Color[3] - a->Color[3]) * scan.invDeltaY[0];
scan.c[3][0] = a->Color[3];
#endif
#ifdef IPOL_T0
scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
scan.t[0][0] = a->Tex[0];
@ -494,6 +560,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][1] = a->Color[1];
#endif
#ifdef IPOL_C2
scan.slopeC[2][1] = (b->Color[2] - a->Color[2]) * scan.invDeltaY[1];
scan.c[2][1] = a->Color[2];
#endif
#ifdef IPOL_C3
scan.slopeC[3][1] = (b->Color[3] - a->Color[3]) * scan.invDeltaY[1];
scan.c[3][1] = a->Color[3];
#endif
#ifdef IPOL_T0
scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
scan.t[0][1] = a->Tex[0];
@ -545,6 +621,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][1] += scan.slopeC[1][1] * subPixel;
#endif
#ifdef IPOL_C2
scan.c[2][0] += scan.slopeC[2][0] * subPixel;
scan.c[2][1] += scan.slopeC[2][1] * subPixel;
#endif
#ifdef IPOL_C3
scan.c[3][0] += scan.slopeC[3][0] * subPixel;
scan.c[3][1] += scan.slopeC[3][1] * subPixel;
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
@ -593,6 +679,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
line.c[1][scan.right] = scan.c[1][1];
#endif
#ifdef IPOL_C2
line.c[2][scan.left] = scan.c[2][0];
line.c[2][scan.right] = scan.c[2][1];
#endif
#ifdef IPOL_C3
line.c[3][scan.left] = scan.c[3][0];
line.c[3][scan.right] = scan.c[3][1];
#endif
#ifdef IPOL_T0
line.t[0][scan.left] = scan.t[0][0];
line.t[0][scan.right] = scan.t[0][1];
@ -639,6 +735,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][1] += scan.slopeC[1][1];
#endif
#ifdef IPOL_C2
scan.c[2][0] += scan.slopeC[2][0];
scan.c[2][1] += scan.slopeC[2][1];
#endif
#ifdef IPOL_C3
scan.c[3][0] += scan.slopeC[3][0];
scan.c[3][1] += scan.slopeC[3][1];
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0];
scan.t[0][1] += scan.slopeT[0][1];
@ -683,6 +789,12 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
#ifdef IPOL_C1
scan.c[1][0] = a->Color[1] + scan.slopeC[1][0] * temp[0];
#endif
#ifdef IPOL_C2
scan.c[2][0] = a->Color[2] + scan.slopeC[2][0] * temp[0];
#endif
#ifdef IPOL_C3
scan.c[3][0] = a->Color[3] + scan.slopeC[3][0] * temp[0];
#endif
#ifdef IPOL_T0
scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
#endif
@ -722,6 +834,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][1] = b->Color[1];
#endif
#ifdef IPOL_C2
scan.slopeC[2][1] = (c->Color[2] - b->Color[2]) * scan.invDeltaY[2];
scan.c[2][1] = b->Color[2];
#endif
#ifdef IPOL_C3
scan.slopeC[3][1] = (c->Color[3] - b->Color[3]) * scan.invDeltaY[2];
scan.c[3][1] = b->Color[3];
#endif
#ifdef IPOL_T0
scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
scan.t[0][1] = b->Tex[0];
@ -773,6 +895,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][1] += scan.slopeC[1][1] * subPixel;
#endif
#ifdef IPOL_C2
scan.c[2][0] += scan.slopeC[2][0] * subPixel;
scan.c[2][1] += scan.slopeC[2][1] * subPixel;
#endif
#ifdef IPOL_C3
scan.c[3][0] += scan.slopeC[3][0] * subPixel;
scan.c[3][1] += scan.slopeC[3][1] * subPixel;
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
@ -821,6 +953,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
line.c[1][scan.right] = scan.c[1][1];
#endif
#ifdef IPOL_C2
line.c[2][scan.left] = scan.c[2][0];
line.c[2][scan.right] = scan.c[2][1];
#endif
#ifdef IPOL_C3
line.c[3][scan.left] = scan.c[3][0];
line.c[3][scan.right] = scan.c[3][1];
#endif
#ifdef IPOL_T0
line.t[0][scan.left] = scan.t[0][0];
line.t[0][scan.right] = scan.t[0][1];
@ -867,6 +1009,16 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
scan.c[1][1] += scan.slopeC[1][1];
#endif
#ifdef IPOL_C2
scan.c[2][0] += scan.slopeC[2][0];
scan.c[2][1] += scan.slopeC[2][1];
#endif
#ifdef IPOL_C3
scan.c[3][0] += scan.slopeC[3][0];
scan.c[3][1] += scan.slopeC[3][1];
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0];
scan.t[0][1] += scan.slopeT[0][1];
@ -887,10 +1039,62 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe
#endif
}
}
}
}
//! Called by the engine when the vertex and/or pixel shader constants for an
//! material renderer should be set.
void CTRNormalMap::OnSetConstants(IMaterialRendererServices* services, s32 userData)
{
#if 0
video::IVideoDriver* driver = services->getVideoDriver();
// set transposed world matrix
const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed();
services->setVertexShaderConstant(tWorld.pointer(), 0, 4);
// set transposed worldViewProj matrix
core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
worldViewProj *= driver->getTransform(video::ETS_VIEW);
worldViewProj *= driver->getTransform(video::ETS_WORLD);
core::matrix4 tr(worldViewProj.getTransposed());
services->setVertexShaderConstant(tr.pointer(), 8, 4);
// here we fetch the fixed function lights from the driver
// and set them as constants
u32 cnt = driver->getDynamicLightCount();
// Load the inverse world matrix.
core::matrix4 invWorldMat;
driver->getTransform(video::ETS_WORLD).getInverse(invWorldMat);
for (u32 i = 0; i < 2; ++i)
{
video::SLight light;
if (i < cnt)
light = driver->getDynamicLight(i);
else
{
light.DiffuseColor.set(0, 0, 0); // make light dark
light.Radius = 1.0f;
}
light.DiffuseColor.a = 1.0f / (light.Radius * light.Radius); // set attenuation
// Transform the light by the inverse world matrix to get it into object space.
invWorldMat.transformVect(light.Position);
services->setVertexShaderConstant(
reinterpret_cast<const f32*>(&light.Position), 12 + (i * 2), 1);
services->setVertexShaderConstant(
reinterpret_cast<const f32*>(&light.DiffuseColor), 13 + (i * 2), 1);
}
#endif
}
burning_namespace_end
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
@ -898,10 +1102,10 @@ burning_namespace_end
burning_namespace_start
//! creates a triangle renderer
IBurningShader* createTRNormalMap(CBurningVideoDriver* driver)
IBurningShader* createTRNormalMap(CBurningVideoDriver* driver, s32& outMaterialTypeNr, E_MATERIAL_TYPE baseMaterial)
{
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CTRNormalMap(driver);
return new CTRNormalMap(driver, outMaterialTypeNr,baseMaterial);
#else
return 0;
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_

File diff suppressed because it is too large Load Diff

@ -93,7 +93,7 @@ private:
//! constructor
CTRStencilShadow::CTRStencilShadow(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_SOLID)
{
#ifdef _DEBUG
setDebugName("CTRStencilShadow");

@ -108,7 +108,7 @@ private:
//! constructor
CTRTextureBlend::CTRTextureBlend(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_ONETEXTURE_BLEND)
{
#ifdef _DEBUG
setDebugName("CTRTextureBlend");

@ -94,7 +94,7 @@ protected:
//! constructor
CTRTextureDetailMap2::CTRTextureDetailMap2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_DETAIL_MAP)
{
#ifdef _DEBUG
setDebugName("CTRTextureDetailMap2");

@ -112,7 +112,7 @@ private:
//! constructor
CTRTextureGouraud2::CTRTextureGouraud2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver,EMT_SOLID)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraud2");

@ -93,7 +93,7 @@ private:
//! constructor
CTRTextureGouraudAdd2::CTRTextureGouraudAdd2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_TRANSPARENT_ADD_COLOR)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraudAdd2");

@ -93,7 +93,7 @@ private:
//! constructor
CTRTextureGouraudAddNoZ2::CTRTextureGouraudAddNoZ2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_TRANSPARENT_ADD_COLOR)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraudAddNoZ2");

@ -100,7 +100,7 @@ private:
//! constructor
CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_TRANSPARENT_ALPHA_CHANNEL)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraudAlpha2");

@ -103,7 +103,7 @@ private:
//! constructor
CTRTextureGouraudAlphaNoZ::CTRTextureGouraudAlphaNoZ(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_TRANSPARENT_ALPHA_CHANNEL)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraudAlphaNoZ");
@ -125,7 +125,7 @@ void CTRTextureGouraudAlphaNoZ::OnSetMaterial(const SBurningShaderMaterial& mate
//check triangle on w = 1.f instead..
#ifdef SOFTWARE_DRIVER_2_BILINEAR
if (material.Fallback_MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
if (material.org.MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
fragmentShader = &CTRTextureGouraudAlphaNoZ::fragment_linear_alpharef;
else
if ( material.org.TextureLayer[0].BilinearFilter )

@ -100,7 +100,7 @@ private:
//! constructor
CTRTextureGouraudNoZ2::CTRTextureGouraudNoZ2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver,EMT_SOLID)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraudNoZ2");

@ -99,7 +99,7 @@ private:
//! constructor
CTRTextureVertexAlpha2::CTRTextureVertexAlpha2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_TRANSPARENT_VERTEX_ALPHA)
{
#ifdef _DEBUG
setDebugName("CTRTextureVertexAlpha2");

@ -92,7 +92,7 @@ private:
//! constructor
CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_LIGHTMAP_ADD)
{
#ifdef _DEBUG
setDebugName("CTRTextureLightMap2_Add");

@ -92,7 +92,7 @@ private:
//! constructor
CTRTextureLightMap2_M1::CTRTextureLightMap2_M1(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_LIGHTMAP)
{
#ifdef _DEBUG
setDebugName("CTRTextureLightMap2_M1");

@ -92,7 +92,7 @@ private:
//! constructor
CTRTextureLightMap2_M2::CTRTextureLightMap2_M2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_LIGHTMAP_LIGHTING_M2)
{
#ifdef _DEBUG
setDebugName("CTRTextureLightMap2_M2");

@ -93,7 +93,7 @@ private:
//! constructor
CTRTextureLightMap2_M4::CTRTextureLightMap2_M4(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_LIGHTMAP_M4)
{
#ifdef _DEBUG
setDebugName("CTRTextureLightMap2_M4");

@ -92,7 +92,7 @@ private:
//! constructor
CTRGTextureLightMap2_M4::CTRGTextureLightMap2_M4(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_LIGHTMAP_LIGHTING_M4)
{
#ifdef _DEBUG
setDebugName("CTRGTextureLightMap2_M4");

@ -98,7 +98,7 @@ protected:
//! constructor
CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_SOLID)
{
#ifdef _DEBUG
setDebugName("CTRTextureWire2");

@ -98,7 +98,7 @@ private:
//! constructor
CTR_transparent_reflection_2_layer::CTR_transparent_reflection_2_layer(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver, EMT_REFLECTION_2_LAYER)
{
#ifdef _DEBUG
setDebugName("CTR_transparent_reflection_2_layer");

@ -20,7 +20,7 @@ const tFixPointu IBurningShader::dithermask[] =
0xf0,0x70,0xd0,0x50
};
void IBurningShader::constructor_IBurningShader(CBurningVideoDriver* driver)
void IBurningShader::constructor_IBurningShader(CBurningVideoDriver* driver, E_MATERIAL_TYPE baseMaterial)
{
#ifdef _DEBUG
setDebugName("IBurningShader");
@ -62,16 +62,37 @@ void IBurningShader::constructor_IBurningShader(CBurningVideoDriver* driver)
stencilOp[1] = StencilOp_KEEP;
stencilOp[2] = StencilOp_KEEP;
AlphaRef = 0;
RenderPass_ShaderIsTransparent = 0;
PrimitiveColor = COLOR_BRIGHT_WHITE;
TL_Flag = 0;
fragment_draw_count = 0;
VertexShaderProgram_buildin = BVT_Fix;
//set default Transparent/Solid
BaseMaterial = baseMaterial;
switch (BaseMaterial)
{
case EMT_TRANSPARENT_ADD_COLOR:
case EMT_TRANSPARENT_ALPHA_CHANNEL:
case EMT_TRANSPARENT_ALPHA_CHANNEL_REF:
case EMT_TRANSPARENT_VERTEX_ALPHA:
case EMT_TRANSPARENT_REFLECTION_2_LAYER:
case EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR:
case EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA:
case EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR:
case EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA:
case EMT_ONETEXTURE_BLEND:
RenderPass_ShaderIsTransparent = 1;
break;
default:
RenderPass_ShaderIsTransparent = 0;
break;
}
}
IBurningShader::IBurningShader(CBurningVideoDriver* driver)
IBurningShader::IBurningShader(CBurningVideoDriver* driver,E_MATERIAL_TYPE baseMaterial)
{
constructor_IBurningShader(driver);
constructor_IBurningShader(driver, baseMaterial);
}
//! Constructor
@ -94,32 +115,12 @@ IBurningShader::IBurningShader(
E_MATERIAL_TYPE baseMaterial,
s32 userData)
{
constructor_IBurningShader(driver);
BaseMaterial = baseMaterial;
constructor_IBurningShader(driver, baseMaterial);
UserData = userData;
CallBack = callback;
if (CallBack)
CallBack->grab();
//set default Transparent/Solid
switch (BaseMaterial)
{
case EMT_TRANSPARENT_ADD_COLOR:
case EMT_TRANSPARENT_ALPHA_CHANNEL:
case EMT_TRANSPARENT_ALPHA_CHANNEL_REF:
case EMT_TRANSPARENT_VERTEX_ALPHA:
case EMT_TRANSPARENT_REFLECTION_2_LAYER:
case EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR:
case EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA:
case EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR:
case EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA:
case EMT_ONETEXTURE_BLEND:
RenderPass_ShaderIsTransparent = 1;
break;
default:
RenderPass_ShaderIsTransparent = 0;
break;
}
//v0.53 compile. only buildin
const c8* ip = vertexShaderProgram;
@ -140,6 +141,7 @@ IBurningShader::IBurningShader(
else if (len == 958 && hash == 0xa048973b) VertexShaderProgram_buildin = STK_958_0xa048973b; /* supertuxkart motion_blur.vert */
else if (len == 1309 && hash == 0x1fd689c2) VertexShaderProgram_buildin = STK_1309_0x1fd689c2; /* supertuxkart normalmap.vert */
else if (len == 1204 && hash == 0x072a4094) VertexShaderProgram_buildin = STK_1204_0x072a4094; /* supertuxkart splatting.vert */
else if (len == 1303 && hash == 0xd872cdb6) VertexShaderProgram_buildin = STK_1303_0xd872cdb6; /* supertuxkart water.vert */
//VertexShaderProgram = vertexShaderProgram;
@ -154,7 +156,8 @@ IBurningShader::IBurningShader(
FILE* f = fopen("shader_id.txt", run ? "a" : "wb");
if (f)
{
fprintf(f, "--- start outMaterialTypeNr:%d len:%d hash: 0x%08x\n", outMaterialTypeNr, len, hash);
fprintf(f, "--- start outMaterialTypeNr:%d len:%d hash: 0x%08x buildIn:%d\n"
, outMaterialTypeNr, len, hash, VertexShaderProgram_buildin);
fprintf(f, "%s", vertexShaderProgram);
fprintf(f, "\n-------------- end ---------------------------\n");
fclose(f);
@ -335,43 +338,6 @@ void IBurningShader::setBasicRenderStates(const SMaterial& material, const SMate
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
#if 0
const core::matrix4& IBurningShader::uniform_mat4(const c8* name)
{
return (const core::matrix4&)*getUniform(name, BL_VERTEX_FLOAT);
}
video::sVec4 IBurningShader::uniform_vec4(const c8* name)
{
const f32* v = getUniform(name, BL_VERTEX_FLOAT);
return video::sVec4(v[0], v[1], v[2], v[3]);
}
video::sVec4 IBurningShader::uniform_vec3(const c8* name)
{
const f32* v = getUniform(name, BL_VERTEX_FLOAT);
return video::sVec4(v[0], v[1], v[2], 0.f);
}
core::matrix4& IBurningShader::varying_mat4(const c8* name)
{
return (core::matrix4&)*getUniform(name, BL_FRAGMENT_FLOAT);
}
video::sVec4 IBurningShader::varying_vec4(const c8* name)
{
const f32* v = getUniform(name, BL_FRAGMENT_FLOAT);
return video::sVec4(v[0], v[1], v[2], v[3]);
}
video::sVec4 IBurningShader::varying_vec3(const c8* name)
{
const f32* v = getUniform(name, BL_FRAGMENT_FLOAT);
return video::sVec4(v[0], v[1], v[2], 0.f);
}
#endif
static BurningUniform _empty = { "null",BL_VERTEX_FLOAT,{0.f,0.f,0.f,0.f} };
const f32* IBurningShader::getUniform(const c8* name, EBurningUniformFlags flags) const
{
@ -430,15 +396,6 @@ bool IBurningShader::setShaderConstantID(EBurningUniformFlags flags, s32 index,
{
if ((u32)index >= UniformInfo.size())
return false;
#if 0
BurningUniform add;
while ((u32)index >= UniformInfo.size())
{
tiny_strcpy(add.name, tiny_itoa(UniformInfo.size(), 10));
add.type = flags;
UniformInfo.push_back(add);
}
#endif
BurningUniform& use = UniformInfo[index];
use.type = flags;
@ -472,7 +429,7 @@ void IBurningShader::setVertexShaderConstant(const f32* data, s32 startRegister,
c8 name[BL_ACTIVE_UNIFORM_MAX_LENGTH];
tiny_strcpy(name, tiny_itoa(startRegister, 10));
setShaderConstantID(BL_VERTEX_FLOAT, getShaderConstantID(BL_VERTEX_PROGRAM, name), data, constantAmount);
setShaderConstantID(BL_VERTEX_FLOAT, getShaderConstantID(BL_VERTEX_PROGRAM, name), data, constantAmount*4);
}
void IBurningShader::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
@ -480,7 +437,7 @@ void IBurningShader::setPixelShaderConstant(const f32* data, s32 startRegister,
c8 name[BL_ACTIVE_UNIFORM_MAX_LENGTH];
tiny_strcpy(name, tiny_itoa(startRegister, 10));
setShaderConstantID(BL_FRAGMENT_FLOAT, getShaderConstantID(BL_FRAGMENT_PROGRAM, name), data, constantAmount);
setShaderConstantID(BL_FRAGMENT_FLOAT, getShaderConstantID(BL_FRAGMENT_PROGRAM, name), data, constantAmount*4);
}
bool IBurningShader::setVertexShaderConstant(s32 index, const f32* floats, int count)

@ -20,6 +20,7 @@
#include "IMaterialRenderer.h"
#include "IMaterialRendererServices.h"
#include "IGPUProgrammingServices.h"
#include "IShaderConstantSetCallback.h"
burning_namespace_start
@ -47,6 +48,11 @@ struct SBurningShaderLight
sVec3Color AmbientColor;
sVec3Color DiffuseColor;
sVec3Color SpecularColor;
//normal,parallax
sVec4 pos_local; //modelinverse
f32 nmap_linearAttenuation;
SBurningShaderLight()
{
LightIsOn = false;
@ -105,6 +111,10 @@ struct SBurningShaderEyeSpace
f32 fog_scale; // 1 / (fog.end-fog.start)
size_t TL_Flag; // eTransformLightFlags
// objectspace
core::matrix4 mvi; // inverse Model*View
sVec4 leye; //eye vector unprojected
};
enum eBurningCullFlag
@ -137,6 +147,7 @@ enum eBurningVertexShader
STK_958_0xa048973b, /* supertuxkart motion_blur.vert */
STK_1204_0x072a4094, /* supertuxkart splatting.vert */
STK_1309_0x1fd689c2, /* supertuxkart normalmap.vert */
STK_1303_0xd872cdb6, /* supertuxkart water.vert */
};
struct SBurningShaderMaterial
@ -195,6 +206,7 @@ enum EBurningFFShader
ETR_TEXTURE_GOURAUD_ALPHA_NOZ_NOPERSPECTIVE_CORRECT,
ETR_NORMAL_MAP_SOLID,
ETR_PARALLAX_MAP_SOLID,
ETR_STENCIL_SHADOW,
ETR_TEXTURE_BLEND,
@ -235,7 +247,7 @@ struct BurningUniform
bool operator==(const BurningUniform& other) const
{
return tiny_istoken(name, other.name);
return ((type & 3) == (other.type & 3)) && tiny_istoken(name, other.name);
}
};
@ -250,11 +262,11 @@ struct PushShaderData
};
class CBurningVideoDriver;
class IBurningShader : public IMaterialRenderer, public IMaterialRendererServices
class IBurningShader : public IMaterialRenderer, public IMaterialRendererServices, public IShaderConstantSetCallBack
{
public:
//! Constructor
IBurningShader(CBurningVideoDriver* driver);
IBurningShader(CBurningVideoDriver* driver, E_MATERIAL_TYPE baseMaterial );
//! Constructor
IBurningShader(
@ -303,8 +315,10 @@ public:
void setStencilOp(eBurningStencilOp sfail, eBurningStencilOp dpfail, eBurningStencilOp dppass);
//IMaterialRenderer
//IShaderConstantSetCallBack
virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData) IRR_OVERRIDE {};
//IMaterialRenderer
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) IRR_OVERRIDE;
@ -380,21 +394,13 @@ public:
}
u32 fragment_draw_count;
/*
const core::matrix4& uniform_mat4(const c8* name);
video::sVec4 uniform_vec4(const c8* name);
video::sVec4 uniform_vec3(const c8* name);
core::matrix4& varying_mat4(const c8* name);
video::sVec4 varying_vec4(const c8* name);
video::sVec4 varying_vec3(const c8* name);
*/
const f32* getUniform(const c8* name, EBurningUniformFlags flags) const;
protected:
//friend class CBurningVideoDriver;
void constructor_IBurningShader(CBurningVideoDriver* driver);
void constructor_IBurningShader(CBurningVideoDriver* driver, E_MATERIAL_TYPE baseMaterial);
CBurningVideoDriver* Driver;
IShaderConstantSetCallBack* CallBack;
@ -462,7 +468,6 @@ IBurningShader* createTriangleRendererTextureVertexAlpha2(CBurningVideoDriver* d
IBurningShader* createTriangleRendererTextureGouraudWire2(CBurningVideoDriver* driver);
IBurningShader* createTriangleRendererGouraud2(CBurningVideoDriver* driver);
IBurningShader* createTriangleRendererGouraudNoZ2(CBurningVideoDriver* driver);
IBurningShader* createTriangleRendererGouraudAlpha2(CBurningVideoDriver* driver);
IBurningShader* createTRGouraudAlphaNoZ2(CBurningVideoDriver* driver);
IBurningShader* createTriangleRendererGouraudWire2(CBurningVideoDriver* driver);
IBurningShader* createTriangleRendererTextureFlat2(CBurningVideoDriver* driver);
@ -478,7 +483,8 @@ IBurningShader* createTRTextureGouraudAlphaNoZ(CBurningVideoDriver* driver);
IBurningShader* createTRTextureBlend(CBurningVideoDriver* driver);
IBurningShader* createTRTextureInverseAlphaBlend(CBurningVideoDriver* driver);
IBurningShader* createTRNormalMap(CBurningVideoDriver* driver);
IBurningShader* createTRNormalMap(CBurningVideoDriver* driver, s32& outMaterialTypeNr, E_MATERIAL_TYPE baseMaterial);
IBurningShader* createTRParallaxMap(CBurningVideoDriver* driver, s32& outMaterialTypeNr, E_MATERIAL_TYPE baseMaterial);
IBurningShader* createTRStencilShadow(CBurningVideoDriver* driver);
IBurningShader* createTriangleRendererReference(CBurningVideoDriver* driver);

@ -239,7 +239,6 @@
5E34CB931B7F6EC500F212E8 /* CSoftwareDriver2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C9641B7F6A7600F212E8 /* CSoftwareDriver2.cpp */; };
5E34CB951B7F6EC500F212E8 /* CSoftwareTexture2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C9661B7F6A7600F212E8 /* CSoftwareTexture2.cpp */; };
5E34CB971B7F6EC500F212E8 /* CTRGouraud2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C9681B7F6A7600F212E8 /* CTRGouraud2.cpp */; };
5E34CB981B7F6EC500F212E8 /* CTRGouraudAlpha2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C9691B7F6A7600F212E8 /* CTRGouraudAlpha2.cpp */; };
5E34CB991B7F6EC500F212E8 /* CTRGouraudAlphaNoZ2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C96A1B7F6A7600F212E8 /* CTRGouraudAlphaNoZ2.cpp */; };
5E34CB9A1B7F6EC500F212E8 /* CTRNormalMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C96B1B7F6A7600F212E8 /* CTRNormalMap.cpp */; };
5E34CB9B1B7F6EC500F212E8 /* CTRStencilShadow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E34C96C1B7F6A7600F212E8 /* CTRStencilShadow.cpp */; };
@ -308,6 +307,7 @@
5E79089B1C10FEF900DFE7FE /* CB3DMeshWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E7908981C10FE4A00DFE7FE /* CB3DMeshWriter.cpp */; };
5E8570BC1B7F9AC400B267D2 /* CIrrDeviceConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E8570BA1B7F9AC400B267D2 /* CIrrDeviceConsole.cpp */; };
5E8570BD1B7F9AC400B267D2 /* CIrrDeviceConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E8570BB1B7F9AC400B267D2 /* CIrrDeviceConsole.h */; };
65E74BB3282193B50004CA1D /* CTRParallaxMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E74BB2282193B40004CA1D /* CTRParallaxMap.cpp */; };
8493BC02249DEBB30092813E /* IOctreeSceneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 8493BC01249DEBB20092813E /* IOctreeSceneNode.h */; };
8493BC04249DED3F0092813E /* IMemoryReadFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8493BC03249DED3F0092813E /* IMemoryReadFile.h */; };
84A219A5249F823900E189FC /* SOverrideMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A219A4249F823800E189FC /* SOverrideMaterial.h */; };
@ -926,7 +926,6 @@
5E34C9661B7F6A7600F212E8 /* CSoftwareTexture2.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSoftwareTexture2.cpp; sourceTree = "<group>"; };
5E34C9671B7F6A7600F212E8 /* CSoftwareTexture2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSoftwareTexture2.h; sourceTree = "<group>"; };
5E34C9681B7F6A7600F212E8 /* CTRGouraud2.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraud2.cpp; sourceTree = "<group>"; };
5E34C9691B7F6A7600F212E8 /* CTRGouraudAlpha2.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraudAlpha2.cpp; sourceTree = "<group>"; };
5E34C96A1B7F6A7600F212E8 /* CTRGouraudAlphaNoZ2.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CTRGouraudAlphaNoZ2.cpp; sourceTree = "<group>"; };
5E34C96B1B7F6A7600F212E8 /* CTRNormalMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CTRNormalMap.cpp; sourceTree = "<group>"; };
5E34C96C1B7F6A7600F212E8 /* CTRStencilShadow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CTRStencilShadow.cpp; sourceTree = "<group>"; };
@ -1047,6 +1046,7 @@
5E8570BA1B7F9AC400B267D2 /* CIrrDeviceConsole.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CIrrDeviceConsole.cpp; sourceTree = "<group>"; };
5E8570BB1B7F9AC400B267D2 /* CIrrDeviceConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CIrrDeviceConsole.h; sourceTree = "<group>"; };
5EC24F5E1B8B861200DCA615 /* exampleHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = exampleHelper.h; path = ../../include/exampleHelper.h; sourceTree = "<group>"; };
65E74BB2282193B40004CA1D /* CTRParallaxMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTRParallaxMap.cpp; sourceTree = "<group>"; };
8493BC01249DEBB20092813E /* IOctreeSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOctreeSceneNode.h; path = ../../include/IOctreeSceneNode.h; sourceTree = "<group>"; };
8493BC03249DED3F0092813E /* IMemoryReadFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IMemoryReadFile.h; path = ../../include/IMemoryReadFile.h; sourceTree = "<group>"; };
84A219A4249F823800E189FC /* SOverrideMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SOverrideMaterial.h; path = ../../include/SOverrideMaterial.h; sourceTree = "<group>"; };
@ -1918,10 +1918,10 @@
5E34C9661B7F6A7600F212E8 /* CSoftwareTexture2.cpp */,
5E34C9671B7F6A7600F212E8 /* CSoftwareTexture2.h */,
5E34C9681B7F6A7600F212E8 /* CTRGouraud2.cpp */,
5E34C9691B7F6A7600F212E8 /* CTRGouraudAlpha2.cpp */,
5E34C96A1B7F6A7600F212E8 /* CTRGouraudAlphaNoZ2.cpp */,
84A219B8249F834000E189FC /* CTRGouraudNoZ2.cpp */,
5E34C96B1B7F6A7600F212E8 /* CTRNormalMap.cpp */,
65E74BB2282193B40004CA1D /* CTRParallaxMap.cpp */,
5E34C96C1B7F6A7600F212E8 /* CTRStencilShadow.cpp */,
5E34C96D1B7F6A7600F212E8 /* CTRTextureBlend.cpp */,
5E34C96E1B7F6A7600F212E8 /* CTRTextureDetailMap2.cpp */,
@ -2410,7 +2410,6 @@
5E34CB931B7F6EC500F212E8 /* CSoftwareDriver2.cpp in Sources */,
5E34CB951B7F6EC500F212E8 /* CSoftwareTexture2.cpp in Sources */,
5E34CB971B7F6EC500F212E8 /* CTRGouraud2.cpp in Sources */,
5E34CB981B7F6EC500F212E8 /* CTRGouraudAlpha2.cpp in Sources */,
5E34CB991B7F6EC500F212E8 /* CTRGouraudAlphaNoZ2.cpp in Sources */,
5E34CB9A1B7F6EC500F212E8 /* CTRNormalMap.cpp in Sources */,
5E34CB9B1B7F6EC500F212E8 /* CTRStencilShadow.cpp in Sources */,
@ -2418,6 +2417,7 @@
5E34CB9D1B7F6EC500F212E8 /* CTRTextureDetailMap2.cpp in Sources */,
5E34CB9E1B7F6EC500F212E8 /* CTRTextureGouraud2.cpp in Sources */,
5E34CB9F1B7F6EC500F212E8 /* CTRTextureGouraudAdd2.cpp in Sources */,
65E74BB3282193B50004CA1D /* CTRParallaxMap.cpp in Sources */,
5E34CBA01B7F6EC500F212E8 /* CTRTextureGouraudAddNoZ2.cpp in Sources */,
5E34CBA11B7F6EC500F212E8 /* CTRTextureGouraudAlpha.cpp in Sources */,
5E34CBA21B7F6EC500F212E8 /* CTRTextureGouraudAlphaNoZ.cpp in Sources */,

@ -849,30 +849,30 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\EDeviceTypes.h" />
<ClInclude Include="..\..\include\EDeviceTypes.h" />
<ClInclude Include="..\..\include\EDriverFeatures.h" />
<ClInclude Include="..\..\include\EHardwareBufferFlags.h" />
<ClInclude Include="..\..\include\EHardwareBufferFlags.h" />
<ClInclude Include="..\..\include\EMaterialFlags.h" />
<ClInclude Include="..\..\include\EMaterialTypes.h" />
<ClInclude Include="..\..\include\EReadFileType.h" />
<ClInclude Include="..\..\include\EShaderTypes.h" />
<ClInclude Include="..\..\include\fast_atof.h" />
<ClInclude Include="..\..\include\fast_atof.h" />
<ClInclude Include="..\..\include\IAnimatedMeshMD3.h" />
<ClInclude Include="..\..\include\IBillboardTextSceneNode.h" />
<ClInclude Include="..\..\include\IBoneSceneNode.h" />
<ClInclude Include="..\..\include\IColladaMeshWriter.h" />
<ClInclude Include="..\..\include\IBillboardTextSceneNode.h" />
<ClInclude Include="..\..\include\IBoneSceneNode.h" />
<ClInclude Include="..\..\include\IColladaMeshWriter.h" />
<ClInclude Include="..\..\include\IDynamicMeshBuffer.h" />
<ClInclude Include="..\..\include\IEventReceiver.h" />
<ClInclude Include="..\..\include\IFileArchive.h" />
<ClInclude Include="..\..\include\IGUIFontBitmap.h" />
<ClInclude Include="..\..\include\IFileArchive.h" />
<ClInclude Include="..\..\include\IGUIFontBitmap.h" />
<ClInclude Include="..\..\include\IGUITable.h" />
<ClInclude Include="..\..\include\IImageWriter.h" />
<ClInclude Include="..\..\include\IIndexBuffer.h" />
<ClInclude Include="..\..\include\ILightManager.h" />
<ClInclude Include="..\..\include\ILightManager.h" />
<ClInclude Include="..\..\include\IOctreeSceneNode.h" />
<ClInclude Include="..\..\include\IProfiler.h" />
<ClInclude Include="..\..\include\ILogger.h" />
<ClInclude Include="..\..\include\IMemoryReadFile.h" />
<ClInclude Include="..\..\include\IMemoryReadFile.h" />
<ClInclude Include="..\..\include\IOSOperator.h" />
<ClInclude Include="..\..\include\IRandomizer.h" />
<ClInclude Include="..\..\include\IReferenceCounted.h" />
@ -882,9 +882,9 @@
<ClInclude Include="..\..\include\leakHunter.h" />
<ClInclude Include="..\..\include\IrrlichtDevice.h" />
<ClInclude Include="..\..\include\irrTypes.h" />
<ClInclude Include="..\..\include\ISceneUserDataSerializer.h" />
<ClInclude Include="..\..\include\ISceneUserDataSerializer.h" />
<ClInclude Include="..\..\include\ITimer.h" />
<ClInclude Include="..\..\include\IVertexBuffer.h" />
<ClInclude Include="..\..\include\IVertexBuffer.h" />
<ClInclude Include="..\..\include\Keycodes.h" />
<ClInclude Include="..\..\include\SIrrCreationParameters.h" />
<ClInclude Include="..\..\include\SKeyMap.h" />
@ -926,7 +926,7 @@
<ClInclude Include="..\..\include\SOverrideMaterial.h" />
<ClInclude Include="..\..\include\SSharedMeshBuffer.h" />
<ClInclude Include="..\..\include\SVertexIndex.h" />
<ClInclude Include="..\..\include\SVertexManipulator.h" />
<ClInclude Include="..\..\include\SVertexManipulator.h" />
<ClInclude Include="..\..\include\triangle3d.h" />
<ClInclude Include="..\..\include\vector2d.h" />
<ClInclude Include="..\..\include\vector3d.h" />
@ -1068,7 +1068,7 @@
<ClInclude Include="COpenGLSLMaterialRenderer.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="CWGLManager.h" />
<ClInclude Include="ISceneNodeAnimatorFinishing.h" />
<ClInclude Include="ISceneNodeAnimatorFinishing.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
<ClInclude Include="C3DSMeshFileLoader.h" />
@ -1342,6 +1342,7 @@
<ClCompile Include="CSkinnedMesh.cpp" />
<ClCompile Include="CSTLMeshFileLoader.cpp" />
<ClCompile Include="CTRGouraudNoZ2.cpp" />
<ClCompile Include="CTRParallaxMap.cpp" />
<ClCompile Include="CTR_transparent_reflection_2_layer.cpp" />
<ClCompile Include="CWGLManager.cpp" />
<ClCompile Include="CXMeshFileLoader.cpp" />
@ -1445,7 +1446,6 @@
<ClCompile Include="CSoftwareDriver2.cpp" />
<ClCompile Include="CSoftwareTexture2.cpp" />
<ClCompile Include="CTRGouraud2.cpp" />
<ClCompile Include="CTRGouraudAlpha2.cpp" />
<ClCompile Include="CTRGouraudAlphaNoZ2.cpp" />
<ClCompile Include="CTRNormalMap.cpp" />
<ClCompile Include="CTRStencilShadow.cpp" />

@ -1282,7 +1282,7 @@
<ClInclude Include="..\..\include\EMaterialFlags.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SSharedMeshBuffer.h">
<ClInclude Include="..\..\include\SSharedMeshBuffer.h">
<Filter>include\scene</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IRenderTarget.h">
@ -1372,7 +1372,7 @@
<ClInclude Include="CBlit.h">
<Filter>Irrlicht\video\Null</Filter>
</ClInclude>
<ClInclude Include="..\..\include\fast_atof.h">
<ClInclude Include="..\..\include\fast_atof.h">
<Filter>include\core</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ILightManager.h">
@ -1437,7 +1437,7 @@
</ClInclude>
<ClInclude Include="..\..\include\EDeviceTypes.h">
<Filter>include</Filter>
</ClInclude>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -1838,9 +1838,6 @@
<ClCompile Include="CTRGouraud2.cpp">
<Filter>Irrlicht\video\Burning Video</Filter>
</ClCompile>
<ClCompile Include="CTRGouraudAlpha2.cpp">
<Filter>Irrlicht\video\Burning Video</Filter>
</ClCompile>
<ClCompile Include="CTRGouraudAlphaNoZ2.cpp">
<Filter>Irrlicht\video\Burning Video</Filter>
</ClCompile>
@ -2384,6 +2381,9 @@
<ClCompile Include="CTRGouraudNoZ2.cpp">
<Filter>Irrlicht\video\Burning Video</Filter>
</ClCompile>
<ClCompile Include="CTRParallaxMap.cpp">
<Filter>Irrlicht\video\Burning Video</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />

@ -1343,6 +1343,7 @@
<ClCompile Include="CSkinnedMesh.cpp" />
<ClCompile Include="CSTLMeshFileLoader.cpp" />
<ClCompile Include="CTRGouraudNoZ2.cpp" />
<ClCompile Include="CTRParallaxMap.cpp" />
<ClCompile Include="CTR_transparent_reflection_2_layer.cpp" />
<ClCompile Include="CWGLManager.cpp" />
<ClCompile Include="CXMeshFileLoader.cpp" />
@ -1446,7 +1447,6 @@
<ClCompile Include="CSoftwareDriver2.cpp" />
<ClCompile Include="CSoftwareTexture2.cpp" />
<ClCompile Include="CTRGouraud2.cpp" />
<ClCompile Include="CTRGouraudAlpha2.cpp" />
<ClCompile Include="CTRGouraudAlphaNoZ2.cpp" />
<ClCompile Include="CTRNormalMap.cpp" />
<ClCompile Include="CTRStencilShadow.cpp" />

@ -48,13 +48,15 @@ IRRDRVROBJ = CNullDriver.o COpenGLCacheHandler.o COpenGLDriver.o COpenGLNormalMa
IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderPVR.o CImageLoaderTGA.o CImageLoaderPPM.o CImageLoaderWAL.o CImageLoaderRGB.o \
CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o
IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRNormalMap.o \
CTRStencilShadow.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o \
CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o \
CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o \
CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o \
CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o \
CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o CTR_transparent_reflection_2_layer.o CTRGouraudNoZ2.o burning_shader_color.o
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o \
CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o \
CTRTextureGouraudWire.o CZBuffer.o
IRRBURNINGOBJ = CSoftwareDriver2.o CSoftwareTexture2.o CDepthBuffer.o IBurningShader.o CTRNormalMap.o CTRParallaxMap.o \
CTRStencilShadow.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o \
CTRTextureLightMap2_M1.o CTRTextureLightMapGouraud2_M4.o CTRTextureLightMap2_M4.o CTRTextureGouraud2.o CTRGouraud2.o \
CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o \
CTRTextureLightMap2_Add.o CTRTextureBlend.o CTRTextureGouraudAlpha.o burning_shader_color.o \
CTRTextureGouraudAlphaNoZ.o CBurningShader_Raster_Reference.o CTR_transparent_reflection_2_layer.o CTRGouraudNoZ2.o
IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CWADReader.o CZipReader.o CPakReader.o CNPKReader.o CTarReader.o CMountPointReader.o irrXML.o CAttributes.o lzma/LzmaDec.o
IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceConsole.o CIrrDeviceStub.o CIrrDeviceWin32.o CIrrDeviceFB.o CLogger.o COSOperator.o Irrlicht.o os.o leakHunter.o CProfiler.o utf8.o
IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUITable.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o CGUIImageList.o CGUITreeView.o CGUIProfiler.o
@ -67,7 +69,7 @@ BZIP2OBJ = bzip2/blocksort.o bzip2/huffman.o bzip2/crctable.o bzip2/randtable.o
# Next variable is for additional scene nodes etc. of customized Irrlicht versions
EXTRAOBJ =
LINKOBJ = $(IRRMESHOBJ) $(IRROBJ) $(IRRPARTICLEOBJ) $(IRRANIMOBJ) \
$(IRRVIDEOOBJ) $(IRRSWRENDEROBJ) $(IRRIOOBJ) $(IRROTHEROBJ) \
$(IRRVIDEOOBJ) $(IRRSWRENDEROBJ) $(IRRBURNINGOBJ) $(IRRIOOBJ) $(IRROTHEROBJ) \
$(IRRGUIOBJ) $(ZLIBOBJ) $(JPEGLIBOBJ) $(LIBPNGOBJ) $(LIBAESGM) \
$(BZIP2OBJ) $(EXTRAOBJ)

@ -166,9 +166,15 @@ struct ALIGN(16) sVec4
struct { f32 s, t, p, q; };
};
sVec4() {}
sVec4(f32 _x, f32 _y, f32 _z, f32 _w)
#if __GNUC__
//have one warning i can't find
sVec4(f32 _x = 0.f, f32 _y = 0.f, f32 _z = 0.f, f32 _w = 0.f)
: x(_x), y(_y), z(_z), w(_w) {}
#else
sVec4() {}
sVec4(f32 _x, f32 _y, f32 _z, f32 _w=0.f)
: x(_x), y(_y), z(_z), w(_w) {}
#endif
// f = a * t + b * ( 1 - t )
REALINLINE void interpolate(const sVec4& burning_restrict a, const sVec4& burning_restrict b, const ipoltype t)
@ -244,6 +250,11 @@ struct ALIGN(16) sVec4
return x * other.x + y * other.y + z * other.z;
}
REALINLINE f32 dot(const irr::core::vector3df& other) const
{
return x * other.X + y * other.Y + z * other.Z;
}
REALINLINE f32 dot_minus_xyz(const sVec4& other) const
{
return x * -other.x + y * -other.y + z * -other.z;
@ -315,19 +326,19 @@ struct ALIGN(16) sVec4
//const f32 l = len * core::reciprocal_squareroot ( r * r + g * g + b * b );
f32 l = x * x + y * y + z * z;
l = l > 0.0000001f ? len / sqrtf(l) : 0.f;
l = l > 0.00000001f ? len / sqrtf(l) : 0.f;
out.x = (x * l) + ofs;
out.y = (y * l) + ofs;
out.z = (z * l) + ofs;
}
//shader suppport
sVec4(const sVec4& a, double w)
sVec4(const sVec4& a, double _w)
{
x = a.x;
y = a.y;
z = a.z;
this->w = (float)w;
w = (float)_w;
}
sVec4 xyz() const
{
@ -385,15 +396,15 @@ struct ALIGN(16) sVec4
}
//sVec4 is a,r,g,b, alpha pass
/*
void sat(sVec4& dest, const u32 argb) const
#if 0
void sat_alpha_pass(sVec4& dest, const u32 argb) const
{
dest.a = ((argb & 0xFF000000) >> 24) * (1.f / 255.f);
dest.r = r <= 1.f ? r : 1.f;
dest.g = g <= 1.f ? g : 1.f;
dest.b = b <= 1.f ? b : 1.f;
}
*/
#endif
void sat_alpha_pass(sVec4& dest, const f32 vertex_alpha) const
{
dest.a = vertex_alpha;
@ -434,81 +445,7 @@ typedef sVec4 sVec3Pack_unpack;
typedef sVec4 sVec3Color;
#if 0
//!sVec4 is argb. sVec3Color is rgba
struct sVec3Color
{
f32 r, g, b, a;
void set(const f32 s)
{
r = s;
g = s;
b = s;
a = s;
}
void setColorf(const video::SColorf& color)
{
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
void add_rgb(const sVec3Color& other)
{
r += other.r;
g += other.g;
b += other.b;
}
void mad_rgb(const sVec3Color& other, const f32 v)
{
r += other.r * v;
g += other.g * v;
b += other.b * v;
}
void mad_rgbv(const sVec3Color& v0, const sVec3Color& v1)
{
r += v0.r * v1.r;
g += v0.g * v1.g;
b += v0.b * v1.b;
}
//sVec4 is a,r,g,b, alpha pass
void sat(sVec4& dest, const u32 argb) const
{
dest.a = ((argb & 0xFF000000) >> 24) * (1.f / 255.f);
dest.r = r <= 1.f ? r : 1.f;
dest.g = g <= 1.f ? g : 1.f;
dest.b = b <= 1.f ? b : 1.f;
}
void sat_xyz(sVec3Pack& dest, const sVec3Color& v1) const
{
f32 v;
v = r * v1.r; dest.x = v < 1.f ? v : 1.f;
v = g * v1.g; dest.y = v < 1.f ? v : 1.f;
v = b * v1.b; dest.z = v < 1.f ? v : 1.f;
}
void sat_xyz(sVec4& dest, const sVec3Color& v1) const
{
f32 v;
dest.a = 1.f;
v = r * v1.r; dest.r = v < 1.f ? v : 1.f;
v = g * v1.g; dest.g = v < 1.f ? v : 1.f;
v = b * v1.b; dest.b = v < 1.f ? v : 1.f;
}
};
#endif
//internal BurningShaderFlag for a Vertex
//internal BurningShaderFlag for a Vertex (Attributes)
enum e4DVertexFlag
{
VERTEX4D_CLIPMASK = 0x0000003F,
@ -526,25 +463,26 @@ enum e4DVertexFlag
VERTEX4D_FORMAT_MASK = 0xFFFF0000,
VERTEX4D_FORMAT_MASK_TEXTURE = 0x000F0000,
VERTEX4D_FORMAT_TEXTURE_1 = 0x00010000,
VERTEX4D_FORMAT_TEXTURE_2 = 0x00020000,
VERTEX4D_FORMAT_TEXTURE_3 = 0x00030000,
VERTEX4D_FORMAT_TEXTURE_4 = 0x00040000,
VERTEX4D_FORMAT_MASK_TEXTURE = 0x000F0000,
VERTEX4D_FORMAT_TEXTURE_1 = 0x00010000,
VERTEX4D_FORMAT_TEXTURE_2 = 0x00020000,
VERTEX4D_FORMAT_TEXTURE_3 = 0x00030000,
VERTEX4D_FORMAT_TEXTURE_4 = 0x00040000,
VERTEX4D_FORMAT_MASK_COLOR = 0x00F00000,
VERTEX4D_FORMAT_COLOR_1 = 0x00100000,
VERTEX4D_FORMAT_MASK_COLOR = 0x00F00000,
VERTEX4D_FORMAT_COLOR_1 = 0x00100000,
VERTEX4D_FORMAT_COLOR_2_FOG = 0x00200000,
VERTEX4D_FORMAT_COLOR_3 = 0x00300000,
VERTEX4D_FORMAT_COLOR_4 = 0x00400000,
VERTEX4D_FORMAT_COLOR_3 = 0x00300000,
VERTEX4D_FORMAT_COLOR_4 = 0x00400000,
VERTEX4D_FORMAT_MASK_LIGHT = 0x0F000000,
VERTEX4D_FORMAT_LIGHT_1 = 0x01000000,
VERTEX4D_FORMAT_LIGHT_2 = 0x02000000,
VERTEX4D_FORMAT_MASK_LIGHT = 0x0F000000,
VERTEX4D_FORMAT_LIGHT_1 = 0x01000000,
//VERTEX4D_FORMAT_LIGHT_2 = 0x02000000,
VERTEX4D_FORMAT_MASK_TANGENT = 0xF0000000,
VERTEX4D_FORMAT_BUMP_DOT3 = 0x10000000,
VERTEX4D_FORMAT_SPECULAR = 0x20000000,
VERTEX4D_FORMAT_MASK_TANGENT = 0xF0000000,
VERTEX4D_FORMAT_BUMP_DOT3 = 0x10000000,
VERTEX4D_FORMAT_PARALLAX = 0x20000000,
//VERTEX4D_FORMAT_SPECULAR = 0x20000000,
};
@ -554,10 +492,13 @@ enum e4DVertexType
E4VT_STANDARD = 0, // EVT_STANDARD, video::S3DVertex.
E4VT_2TCOORDS = 1, // EVT_2TCOORDS, video::S3DVertex2TCoords.
E4VT_TANGENTS = 2, // EVT_TANGENTS, video::S3DVertexTangents
E4VT_REFLECTION_MAP = 3,
E4VT_SHADOW = 4, // float * 3
E4VT_NO_TEXTURE = 5, // runtime if texture missing
E4VT_LINE = 6,
//encode attributes
E4VT_TANGENTS_PARALLAX = 4,
E4VT_REFLECTION_MAP = 5,
E4VT_SHADOW = 6, // float * 3
E4VT_NO_TEXTURE = 7, // runtime if texture missing
E4VT_LINE = 8,
E4VT_COUNT
};
@ -873,13 +814,14 @@ static REALINLINE void memcpy_s4DVertexPair(void* burning_restrict dst, const vo
}
//! hold info for different Vertex Types
//! hold info for different Vertex Types (Attribute mapping)
struct SVSize
{
u32 Format; // e4DVertexFlag VERTEX4D_FORMAT_MASK_TEXTURE
u32 Pitch; // sizeof Vertex
u32 TexSize; // amount Textures
u32 TexCooSize; // sizeof TextureCoordinates
u32 TexCooSize; // amount TextureCoordinates
u32 ColSize; // amount Color Interpolators
};
@ -898,9 +840,6 @@ struct SVertexShader
SVertexShader() {}
~SVertexShader() {}
//VertexType
SVSize vSize[E4VT_COUNT];
// Transformed and lite, clipping state
// + Clipped, Projected
SAligned4DVertex mem;
@ -919,6 +858,9 @@ struct SVertexShader
u32 primitiveHasVertex;
u32 primitiveRun;
//VertexType
SVSize vSize[E4VT_COUNT];
e4DVertexType vType; //E_VERTEX_TYPE
scene::E_PRIMITIVE_TYPE pType; //scene::E_PRIMITIVE_TYPE
e4DIndexType iType; //E_INDEX_TYPE iType

@ -1154,6 +1154,57 @@ static REALINLINE void getSample_texture(tFixPoint& a, tFixPoint& r, tFixPoint&
}
// get Sample bilinear
static REALINLINE void getSample_texture(tFixPoint& a,
const sInternalTexture* burning_restrict tex, const tFixPointu tx, const tFixPointu ty
)
{
tFixPointu a00;
tFixPointu a01;
tFixPointu a10;
tFixPointu a11;
size_t o0, o1, o2, o3;
tVideoSample t00;
o0 = (((ty)&tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2;
o1 = (((ty + FIX_POINT_ONE) & tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2;
o2 = ((tx)&tex->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY);
o3 = ((tx + FIX_POINT_ONE) & tex->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY);
t00 = *((tVideoSample*)((u8*)tex->data + (o0 + o2)));
a00 = (t00 & MASK_A) >> SHIFT_A;
t00 = *((tVideoSample*)((u8*)tex->data + (o0 + o3)));
a10 = (t00 & MASK_A) >> SHIFT_A;
t00 = *((tVideoSample*)((u8*)tex->data + (o1 + o2)));
a01 = (t00 & MASK_A) >> SHIFT_A;
t00 = *((tVideoSample*)((u8*)tex->data + (o1 + o3)));
a11 = (t00 & MASK_A) >> SHIFT_A;
const tFixPointu txFract = tx & FIX_POINT_FRACT_MASK;
const tFixPointu txFractInv = FIX_POINT_ONE - txFract;
const tFixPointu tyFract = ty & FIX_POINT_FRACT_MASK;
const tFixPointu tyFractInv = FIX_POINT_ONE - tyFract;
const tFixPointu w00 = imulFixu(txFractInv, tyFractInv);
const tFixPointu w10 = imulFixu(txFract, tyFractInv);
const tFixPointu w01 = imulFixu(txFractInv, tyFract);
const tFixPointu w11 = imulFixu(txFract, tyFract);
a = (a00 * w00) +
(a01 * w01) +
(a10 * w10) +
(a11 * w11);
fix_alpha_color_max(a);
}
#else // SOFTWARE_DRIVER_2_BILINEAR
// get Sample linear == getSample_fixpoint

@ -1,4 +1,4 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
// Copyright (C) 2022 Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

@ -36,7 +36,7 @@ private:
//! constructor
burning_shader_class::burning_shader_class(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver,EMT_SOLID)
{
#ifdef _DEBUG
setDebugName(burning_stringify(burning_shader_class) );

@ -1,4 +1,4 @@
Tests finished. 72 tests of 72 passed.
Compiled as DEBUG
Test suite pass at GMT Mon May 2 16:15:12 2022
Tests finished. 72 tests of 72 passed.
Compiled as RELEASE
Test suite pass at GMT Tue May 3 20:01:55 2022