more .X much more decrease FPS.
Making progress on the loaders( X mesh and DDS textures ), here's a screenshot in IrrSpintz of the dwarf mesh from the DX Dec 2006 SDK( without normal mapping )
DDS Loader can load R8G8B8, B8G8R8, A8R8G8B8, A8B8G8R8 and DXT1 formats so far, is all I needed, I'll add more to it as I come across the need to. It also loads 8-bit volume/3d textures, but as I mentioned, those texture types aren't supported in Irrlicht.
DDS Loader can load R8G8B8, B8G8R8, A8R8G8B8, A8B8G8R8 and DXT1 formats so far, is all I needed, I'll add more to it as I come across the need to. It also loads 8-bit volume/3d textures, but as I mentioned, those texture types aren't supported in Irrlicht.
-
- Posts: 5
- Joined: Fri Feb 16, 2007 10:00 am
Bug for this topic
Hello! I am using Irrlicht SVN (last).
Without .x model (tyny.x and it's optimized to 2K poly's version) FPS~=160. With model, FPS ~=40.
I'm fix some leaks in modifySkin() and animateSkeleton(), but FPS stil be very slow (~50). Two matrix transform in modifySkin() executed many (~7000) times at one call. It' dificult to reduce/
P/S/
I think that another fast order of weights are exists.
Without .x model (tyny.x and it's optimized to 2K poly's version) FPS~=160. With model, FPS ~=40.
I'm fix some leaks in modifySkin() and animateSkeleton(), but FPS stil be very slow (~50). Two matrix transform in modifySkin() executed many (~7000) times at one call. It' dificult to reduce/
P/S/
I think that another fast order of weights are exists.
-
- Posts: 5
- Joined: Fri Feb 16, 2007 10:00 am
Some optimizations increase FPS to (max, in Debug) 70 (+30).
CXAnimationPlayer.cpp:
matrix4.h:
CXAnimationPlayer.cpp:
Code: Select all
void CXAnimationPlayer::modifySkin()
{
// set animated vertices to zero
#ifdef _XREADER_DEBUG
for (s32 k=0; k<(s32)Joints.size(); ++k)
{
for (s32 w=0; w<(s32)Joints[k].Weights.size(); ++w)
{
SWeightData& wd = Joints[k].Weights[w];
if (wd.buffer >= AnimatedMesh->getMeshBufferCount() ||
wd.vertex >= AnimatedMesh->getMeshBuffer(wd.buffer)->getVertexCount())
os::Printer::log("CXAnimationPlayer: Invalid Weights");
video::S3DVertex* nv = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(wd.buffer)->getVertices();
nv[wd.vertex].Pos.set(0,0,0);
/*This two code lines in xreader-debug only! */
}
}
#endif
#ifdef _XREADER_DEBUG
bool somethingIsWrong = false;
// check if all vertices are set to zero
for (u32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
{
video::S3DVertex* v = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices();
s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount();
for (s32 vt=0; vt<c; ++vt)
if (v[vt].Pos != core::vector3df(0,0,0))
{
char tmp[255];
sprintf(tmp, "CXAnimationPlayer: Vertex not null. Buf:%d Vtx:%d", mb, vt);
// this can happen if something is wrong with the vertex weights,
// not all vertices have a weight attached.
os::Printer::log(tmp);
somethingIsWrong = true;
}
}
if (somethingIsWrong)
{
// write out mesh informations
char tmp[255];
sprintf(tmp, "CXAnimationPlayer: Meshbuffers:%d", AnimatedMesh->getMeshBufferCount());
os::Printer::log(tmp);
for (u32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
{
sprintf(tmp, "CXAnimationPlayer: Meshbuffer #%d: %d vertices", mb, AnimatedMesh->getMeshBuffer(mb)->getVertexCount());
os::Printer::log(tmp);
}
}
#endif
core::vector3df orig;
core::matrix4 mat;
s32 w;
for (s32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
{
video::S3DVertex* av = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices();
video::S3DVertex* ov = (video::S3DVertex*)OriginalMesh.getMeshBuffer(mb)->getVertices();
const s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount();
for (s32 vt=0; vt<c; ++vt)
{
orig = ov[vt].Pos;
const SVertexWeight& weight = Weights[mb].pointer()[vt];
memset(mat.M,0,16*4);
for (w=0; w<weight.weightCount; ++w)
{
//mat += combined*weight
mat.set_summ_with_weight
(Joints[weight.joint[w]].CombinedAnimationMatrix,weight.weight[w]);
}
mat.transformVect(av[vt].Pos,orig);
// yin nadie: let's modify the normals
orig += ov[vt].Normal;
mat.transformVect(av[vt].Normal,orig);
av[vt].Normal -= av[ vt ].Pos;
av[vt].Normal.normalize();
}
}
}
Code: Select all
//! multiply by scalar
matrix4 operator*(const f32 scalar) const;
//! summ to another matrix
matrix4 operator+(const matrix4& other) const;
//! add this to another matrix
inline void operator+=(const matrix4& other);
//! add to another with weight
inline void set_summ_with_weight(const matrix4& other, const f32 weight);
Code: Select all
//! multiply by scalar
inline matrix4 matrix4::operator*(const f32 scalar) const
{
matrix4 tmtrx ( EM4CONST_NOTHING );
const f32 *m1 = M;
f32 *m3 = tmtrx.M;
m3[0] = m1[0]*scalar; m3[1] = m1[1]*scalar;
m3[2] = m1[2]*scalar; m3[3] = m1[3]*scalar;
m3[4] = m1[4]*scalar; m3[5] = m1[5]*scalar;
m3[6] = m1[6]*scalar; m3[7] = m1[7]*scalar;
m3[8] = m1[8]*scalar; m3[9] = m1[9]*scalar;
m3[10] = m1[10]*scalar; m3[11] = m1[11]*scalar;
m3[12] = m1[12]*scalar; m3[13] = m1[13]*scalar;
m3[14] = m1[14]*scalar; m3[15] = m1[15]*scalar;
return tmtrx;
}
//! summ to another matrix
inline matrix4 matrix4::operator+(const matrix4& other) const
{
matrix4 tmtrx ( EM4CONST_NOTHING );
const f32 *m1 = M;
const f32 *m2 = other.M;
f32 *m3 = tmtrx.M;
m3[0] = m1[0] + m2[0]; m3[1] = m1[1] + m2[1];
m3[2] = m1[2] + m2[2]; m3[3] = m1[3] + m2[3];
m3[4] = m2[4] + m1[4]; m3[5] = m1[5] + m2[5];
m3[6] = m1[6] + m2[6]; m3[7] = m1[7] + m2[7];
m3[8] = m2[8] + m1[8]; m3[9] = m2[9] + m1[9];
m3[10] = m1[10] + m2[10]; m3[11] = m1[11] + m2[11];
m3[12] = m2[12] + m1[12]; m3[13] = m2[13] + m1[13];
m3[14] = m2[14] + m1[14]; m3[15] = m1[15] + m2[15];
return tmtrx;
}
//! add this to another matrix
inline void matrix4::operator+=(const matrix4& other)
{
const f32 *m2 = other.M;
M[0] += m2[0]; M[1] += m2[1];
M[2] += m2[2]; M[3] += m2[3];
M[4] += m2[4]; M[5] += m2[5];
M[6] += m2[6]; M[7] += m2[7];
M[8] += m2[8]; M[9] += m2[9];
M[10] += m2[10]; M[11] += m2[11];
M[12] += m2[12]; M[13] += m2[13];
M[14] += m2[14]; M[15] += m2[15];
}
//! add to another with weight
inline void matrix4::set_summ_with_weight(const matrix4& other, const f32 weight)
{
const f32 *m2 = other.M;
M[0] += m2[0]*weight; M[1] += m2[1]*weight;
M[2] += m2[2]*weight; M[3] += m2[3]*weight;
M[4] += m2[4]*weight; M[5] += m2[5]*weight;
M[6] += m2[6]*weight; M[7] += m2[7]*weight;
M[8] += m2[8]*weight; M[9] += m2[9]*weight;
M[10] += m2[10]*weight; M[11] += m2[11]*weight;
M[12] += m2[12]*weight; M[13] += m2[13]*weight;
M[14] += m2[14]*weight; M[15] += m2[15]*weight;
}
-
- Posts: 5
- Joined: Fri Feb 16, 2007 10:00 am
operator*(scalar) и operator+(matrix4) is typical matrix operations.
Threefold count of verices
it's error in CXAnimationPlayer::addFacesToBuffer always return -1
Threefold count of verices
it's error in CXAnimationPlayer::addFacesToBuffer
Code: Select all
buf->Vertices.linear_reverse_search(v);
Last edited by Ки&am on Tue Mar 06, 2007 7:05 pm, edited 4 times in total.
-
- Posts: 5
- Joined: Fri Feb 16, 2007 10:00 am
To fix threefold count of verices remove
irrMath.h:
by
// (-tolerance;+tolerance) -> [-tolerance;+tolerance]
------
max 110 FPS in Debug!
irrMath.h:
Code: Select all
inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
{
return (a + tolerance > b) && (a - tolerance < b);
}
Code: Select all
inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
{
return (a + tolerance >= b) && (a - tolerance <= b);
}
------
max 110 FPS in Debug!
-
- Posts: 5
- Joined: Fri Feb 16, 2007 10:00 am
It's correct. Tolerance can be 0, also rounding errors of tolerance does not influence result.
Spintz:
It depends on model (from average quantity of weights on one vertex). And uselessness of the first nulling cycle on all vertices in not a debugging mode is obvious.
P.S. I'm use VC++6.0 (SP5), DX9 SDK feb.
I test results of the optimization in a debugging mode, i.e. by the switched off machine optimization.
Spintz:
It depends on model (from average quantity of weights on one vertex). And uselessness of the first nulling cycle on all vertices in not a debugging mode is obvious.
P.S. I'm use VC++6.0 (SP5), DX9 SDK feb.
I test results of the optimization in a debugging mode, i.e. by the switched off machine optimization.