View Full Version : how i can do vertex blending without shaders?
12-25-2010, 09:28 AM
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?
12-26-2010, 06:12 AM
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.
12-28-2010, 10:12 AM
Some pre-shader hardware supports extensions to accelerate vertex blending, such as:
If your platform has an extension like that, try it. Otherwise, software transform.
12-29-2010, 06:47 AM
for (int i=0; i < fVertexCount; i++)
// determine transform
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.Column(0), m44.Column(1), m44.Column);
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;
12-29-2010, 03:57 PM
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
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.