Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


CookedBird

Member Since 18 Dec 2012
Offline Last Active Nov 14 2013 03:32 PM

Posts I've Made

In Topic: Help: Telling one mesh from another in the vertex shader

18 December 2012 - 02:10 PM

Okay, I think I realized what my problem was. I didn't realize that you could change uniforms between draw calls, I thought everything was drawn once glFlush was called or something like that, so I thought it would be pointless to change the uniform. But if I understand right I can do something like this...

glBindBuffer(GL_ARRAY_BUFFER, vbo_1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_1);
glUniform1fv(uniform_ skeleton, 10, skeleton_1);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));

glBindBuffer(GL_ARRAY_BUFFER, vbo_2);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_2);
glUniform1fv(uniform_ skeleton, 10, skeleton_2);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));

glutSwapBuffers();


...If that is true then everything just made a whole lot more sense.

In Topic: Help: Telling one mesh from another in the vertex shader

18 December 2012 - 12:53 PM

I understand that, but what I'm confused about is how you tell each skeleton apart, what I have is

uniform mat4 skeleton[][];
uniform vec4 worldpos[];

in int joint;
void main(void)
{
mat4 mjoint = skeleton[meshID][joint];
vec4 new_vertex = gl_vertex + worldpos[meshID];
....
}


but I don't know where to get the meshID from to tell the skeletons and worldpos apart, should it just be a vector attribute, or am I doing this wrong?

In Topic: Help: Telling one mesh from another in the vertex shader

18 December 2012 - 11:30 AM

Well I was also hoping to add more then just the position vector and also give it information about the mesh's skeleton. Where if I have 200 vertices per mesh and only 10 bones per mesh it would be a waist of memory to repeat the bones for each vertex. I'm trying to minimize the about of information I have to update and store on the graphics card.

I did got the idea from instance rendering.

PARTNERS