This topic is now archived and is closed to further replies.


OpenGL Realtime Skin deformation with OpenGL

Recommended Posts

H0rsen    122
Hi there! I would like to know if someone has already made a realtime skin deformation renderer in OpenGL, and know the code/theory behind it? I''ve been working on my own renderer for a few weeks now, and I can''t manage to have the correct result. I''ve made my own exporter plug-in for 3DS Max 4, and it works pretty well. I can get all the info I need in my renderer from my exported file (Skin, Bones, Weight etc...). But I think I don''t understand how to compute the correct transformations. I''ve read many papers, but they all stay very general and don''t help me much. For the moment I''m able to render correctly some very simple animations (a cylinder with 2 or 3 bones that controle it). But since I''m trying with a whole body and a dozen of bones, it doesn''t work any more. I should be missing something, but I''ve spent many hours trying to solve the probleme and I still don''t know what. I know there is a support for skin with DX. But how to do it with OpenGL ? Is there some kind of hardware acceleration for that ? I can post some parts of my code and some screen shots of what I get if needed. So if someone could answer my questions or send me an example, I would be very grateful.

Share this post

Link to post
Share on other sites
Yann L    1802
Not enough information.

The basic idea is to compute a matrix hierarchy, as in simple, non-skinned animation. Each bone gets a local matrix. You would then walk from the root through the hierarchy, push/pop and multiply matrices as you come along, and draw the individual body parts. That would be without skinning.

With skinning, you walk through the whole hierarchy, and do the matrix concatenation. But you don''t render anything, just save the matrices. Once done, you load all those intermediate matrices into constant vertex program registers. Be careful about the reference coordinate frame you use. Different approaches are possible here, but your matrices need some kind of common reference frame.

In the vertex program itself, you transform a vertex by all the matrices he has been assigned to, and weight the results accordingly. Here again, depending on your approach, you might have to compensate for your reference coordinate frame or bone origin.


I know there is a support for skin with DX. But how to do it with OpenGL ? Is there some kind of hardware acceleration for that ?

There are some dedicated extensions, but the best and most flexible way is to use a vertex shader (ARB_vertex_program).


I can post some parts of my code and some screen shots of what I get if needed.

That would be a good idea

Share this post

Link to post
Share on other sites
H0rsen    122
Yeah, thanx a lot for your answer!!

So I was completly wrong :/
I had already heard of vertex program, but never used it.
Now it''s ok, but I still got a few questions. I''ve found some example of skinning programs, but they are all for the NV extension. I tryed to translate it for the ARB, and this is what I get:

For the moment I only use one bone/vertex. If it works, it won''t be difficult to manage the other cases.
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 4, TM[0] , TM[1] , TM[2] , TM[3] );
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 5, TM[4] , TM[5] , TM[6] , TM[7] );
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 6, TM[8] , TM[9] , TM[10], TM[11]);
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 7, TM[12], TM[13], TM[14], TM[15]);
TM is the bone transformation matrix (in the same order as opengl matrix)

And now my vertex program:


PARAM mvp[4]={state.matrix.mvp};
PARAM Matrix2[4] = { program.local[4..7] };
PARAM Pivot = program.local[8];

ATTRIB VertexInitCoord=vertex.position;

OUTPUT VertexFinalCoord=result.position;

TEMP r0, r1, r2;

#Transform the vertex to clip space.
DP4 r0.x, mvp[0], VertexInitCoord;
DP4 r0.y, mvp[1], VertexInitCoord;
DP4 r0.z, mvp[2], VertexInitCoord;
DP4 r0.w, mvp[3], VertexInitCoord;

SUB r2, r0, Pivot;

DP4 r1.x, Matrix2[4], r2;
DP4 r1.y, Matrix2[5], r2;
DP4 r1.z, Matrix2[6], r2;
DP4 r1.w, Matrix2[7], r2;

ADD r0, Pivot, r1;

MOV VertexFinalCoord, r0;


Of course it doesn''t work. I get nothing on the screen. When I remove the 4 last DP4 lines the model is back, but w/o animation.
I tryed to pass an identity matrix instead of the bone TM to the local parameter, but the screen stay black too. So I don''t what''s wrong :/

Share this post

Link to post
Share on other sites

  • Similar Content

    • By povilaslt2
      Hello. I'm Programmer who is in search of 2D game project who preferably uses OpenGL and C++. You can see my projects in GitHub. Project genre doesn't matter (except MMO's :D).
    • By ZeldaFan555
      Hello, My name is Matt. I am a programmer. I mostly use Java, but can use C++ and various other languages. I'm looking for someone to partner up with for random projects, preferably using OpenGL, though I'd be open to just about anything. If you're interested you can contact me on Skype or on here, thank you!
      Skype: Mangodoor408
    • By tyhender
      Hello, my name is Mark. I'm hobby programmer. 
      So recently,I thought that it's good idea to find people to create a full 3D engine. I'm looking for people experienced in scripting 3D shaders and implementing physics into engine(game)(we are going to use the React physics engine). 
      And,ye,no money =D I'm just looking for hobbyists that will be proud of their work. If engine(or game) will have financial succes,well,then maybe =D
      Sorry for late replies.
      I mostly give more information when people PM me,but this post is REALLY short,even for me =D
      So here's few more points:
      Engine will use openGL and SDL for graphics. It will use React3D physics library for physics simulation. Engine(most probably,atleast for the first part) won't have graphical fron-end,it will be a framework . I think final engine should be enough to set up an FPS in a couple of minutes. A bit about my self:
      I've been programming for 7 years total. I learned very slowly it as "secondary interesting thing" for like 3 years, but then began to script more seriously.  My primary language is C++,which we are going to use for the engine. Yes,I did 3D graphics with physics simulation before. No, my portfolio isn't very impressive. I'm working on that No,I wasn't employed officially. If anybody need to know more PM me. 
    • By Zaphyk
      I am developing my engine using the OpenGL 3.3 compatibility profile. It runs as expected on my NVIDIA card and on my Intel Card however when I tried it on an AMD setup it ran 3 times worse than on the other setups. Could this be a AMD driver thing or is this probably a problem with my OGL code? Could a different code standard create such bad performance?
    • By Kjell Andersson
      I'm trying to get some legacy OpenGL code to run with a shader pipeline,
      The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information.
      I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent.
      I've got a version 330 vertex shader to somewhat work:
      #version 330 uniform mat4 osg_ModelViewProjectionMatrix; uniform mat4 osg_ModelViewMatrix; layout(location = 0) in vec4 Vertex; layout(location = 2) in vec4 Normal; // Velocity layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location? out VertexData { vec4 color; vec3 velocity; float size; } VertexOut; void main(void) { vec4 p0 = Vertex; vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f); vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz; VertexOut.velocity = velocity; VertexOut.size = TexCoord.y; gl_Position = osg_ModelViewMatrix * Vertex; } What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine.
      What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++.
      What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined?
      Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
  • Popular Now