Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: how i can do vertex blending without shaders?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    9

    how i can do vertex blending without shaders?

    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?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    941

    Re: how i can do vertex blending without shaders?

    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/

  3. #3
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    676

    Re: how i can do vertex blending without shaders?

    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.

  4. #4
    Intern Contributor Zenja's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, Australia
    Posts
    50

    Re: how i can do vertex blending without shaders?

    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 &amp;m44 = mBones[(int)src->mBoneIndices[bone]]->mTransformMatrix;
    		Vector3 offset = m44.Transform((Vector3&amp;)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++;
    }

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    9

    Re: how i can do vertex blending without shaders?

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •