most specifically, indexed vertex blending with number of matrices and influences unlimited , as blender software,
Is efficient transform the vertices one by one?,
How I can optimize it?
most specifically, indexed vertex blending with number of matrices and influences unlimited , as blender software,
Is efficient transform the vertices one by one?,
How I can optimize it?
There is no other way than transforming vertex by vertex. That's the reason why it is done usually with vertex shaders.
Maybe you can optimize a CPU based implementation if you reuse the weighted matrices for the vertices that have the same weights but it is very unlikely that it will improve the performance of skinning by an observable amount.
Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
Technical Blog: http://www.rastergrid.com/blog/
Some pre-shader hardware supports extensions to accelerate vertex blending, such as:
http://oss.sgi.com/projects/ogl-samp...rtex_blend.txt
http://www.khronos.org/registry/gles...ix_palette.txt
If your platform has an extension like that, try it. Otherwise, software transform.
Code :for (int i=0; i < fVertexCount; i++) { // determine transform Vector3 pos(0,0,0); Vector3 nor(0,0,0); for (int bone = 0; bone < MAX_BONES_PER_VERTEX; bone++) { Matrix4 &m44 = mBones[(int)src->mBoneIndices[bone]]->mTransformMatrix; Vector3 offset = m44.Transform((Vector3&)src->mPosition); offset *= src->mWeights[bone]; pos += offset; // update normals Matrix3 m33 = Matrix3(m44[0].Column(0), m44[1].Column(1), m44[2].Column[2]); nor += m33 * src->mNormal * src->mWeights[bone]; } // update geometry float *p = dst->mPosition; *p++ = pos.x; *p++ = pos.y; *p++ = pos.z; // update normals float *n = dst->mNormals; *n++ = nor.x; *n++ = nor.y; *n++ = nor.z; src++; dst++; }
thank's, I'll do some experiments to determinate the processing time, i know the best way is the vertex shaders, but not all video cards allow this, and vertex shaders involve limitations at time to define matrices and influences.
by the by, every vertex have a influences number, so i have not to transform vertices 4 times every time. in this regard, it is more efficient than shaders