Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7535325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:16:42+00:00 2026-05-30T06:16:42+00:00

I’m currently trying to set up a GPU skinning (with glsl) but it’s not

  • 0

I’m currently trying to set up a GPU skinning (with glsl) but it’s not working the way I would 🙂 Actually it’s not working at all. My mesh disappear when I try this glsl code :

layout(location = 0) in vec3    vertexPos;
layout(location = 1) in vec2    vertexUv;
layout(location = 2) in vec3    vertexNor;
layout(location = 5) in ivec4   joints_influences;
layout(location = 6) in vec4    weights_influences;

uniform mat4    ViewProj, View, Proj, Model;
out vec3        vertexPosEye;
out vec3        vertexNorEye;

const int       MAX_INFLUENCES = 4;
const int       MAX_BONES = 50;
uniform mat4    animation_matrices[MAX_BONES];
uniform mat4    inv_bind_matrices[MAX_BONES];

void main()
{
    vertexPosEye = (View * Model * vec4(vertexPos, 1)).xyz;     // Position
    vertexNorEye = (View * Model * vec4(vertexNor, 0)).xyz;     // Normal matrix

    vec4 final_v = vec4(0, 0, 0, 0);

    for (int i = 0; i < MAX_INFLUENCES; i++)
    {
        vec4 v =        vec4(vertexPos, 1)
                    *   inv_bind_matrices[joints_influences[i]]
                    *   animation_matrices[joints_influences[i]]
                    *   weights_influences[i];

        final_v += v;
    }
    gl_Position =  ViewProj * Model * final_v;
}

when I try this :

gl_Position =  ViewProj * Model * vertexPos;

My mesh is back 🙂 but no animations anymore of course…

Here’s my application (c++) code when I set VBO attributes :

// Vertex position
glGenBuffers(1, &buffer[0]);
glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glBufferData(GL_ARRAY_BUFFER, vertices.pos.size() * sizeof(bVector3), &vertices.pos[0], GL_STATIC_DRAW);

// Ibid for uv, normals, tangents and bitangents.

// Skinning : joints index
glGenBuffers(1, &buffer[5]);
glBindBuffer(GL_ARRAY_BUFFER, buffer[5]);
glBufferData(GL_ARRAY_BUFFER, vertices.joints.size() * sizeof(SkinningJoints), &vertices.joints[0], GL_STATIC_DRAW);

// Skinning : weights
glGenBuffers(1, &buffer[6]);
glBindBuffer(GL_ARRAY_BUFFER, buffer[6]);
glBufferData(GL_ARRAY_BUFFER, vertices.weights.size() * sizeof(SkinningWeights), &vertices.weights[0], GL_STATIC_DRAW);

// Indices
glGenBuffers(1, &buffer[7]);
glBindBuffer(GL_ARRAY_BUFFER, buffer[7]);
glBufferData(GL_ARRAY_BUFFER, vertices.indices.size() * sizeof(bUshort), &vertices.indices[0], GL_STATIC_DRAW);

In the main loop :

glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, m->GetBuffer(0));
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));

glEnableVertexAttribArray(for uv, normals, tangents and bitangents)...

glEnableVertexAttribArray(5);
glBindBuffer(GL_ARRAY_BUFFER, m->GetBuffer(5));
glVertexAttribPointer(5, 4, GL_INT, GL_FALSE, 0, BUFFER_OFFSET(0));

glEnableVertexAttribArray(6);
glBindBuffer(GL_ARRAY_BUFFER, m->GetBuffer(6));
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m->GetBuffer(7));
glDrawElements(GL_TRIANGLES, m->vertices.indices.size(), GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));

Here is my RenderingVertices struct (after Barr’s recomendations):

struct RenderingVertices
{
    // std::vector<Vec3>
    vVec3                       pos, nor, tang, btan;
    vVec2                       uv;
    vUshort                     indices;

    vector<SkinningJoints>      joints;
    vector<SkinningWeights>     weights;
};

And here is my SkinningJoints struct :

struct SkinningJoints
{
    int         j[MAX_BONES_PER_VERT];

    SkinningJoints(Vertex::Weights weights[MAX_BONES_PER_VERT])
    {
        for (bUint i = 0; i < MAX_BONES_PER_VERT; i++)
            j[i] = weights[i].jid;
    }
};

My SkinningWeights struct is almost the same, with an array of float instead of int.

Now when I try to debug the joints index, weights values and final vertex as colors, here is what I get :

// Shader
color_debug = joints_influences;

http://www.images-host.fr/view.php?img=00021800pop.jpg

color_debug = weights_influences;

http://www.images-host.fr/view.php?img=00021800pop2.jpg

Another interesting thing, when I try this :

vec4 pop = vec4(vertexPos, 1) * animation_matrices[1] * inv_bind_matrices[1] * 1.0;
gl_Position =  ViewProj * Model * pop;

My all mesh is actually rotating, which means that my uniform animation_matrices is good.

Anyone can see what i’m doing wrong here ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:16:43+00:00Added an answer on May 30, 2026 at 6:16 am

    Did you try debugging your skinning attributes? Output the vertex weight as colors so that you can confirm you have meaningful values? If everything is black you’ll know where to look.

    From a quick glance at your RenderingVertices I can spot a first problem. You are passing a Vector of pointers to GL which I don’t think is what you want to do.

    Most of the time you will limit skinning influences to 4 joint/weight pairs per vertex. So you can get away with a simple array (ie. SkinningJoints joints[4];).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.