PDA

View Full Version : problem binding matrix from shader



noeska
29-12-2009, 11:13 PM
System: Vista/WindowsXP | Ati HD4800 driver version 09.12
Compiler/IDE: Delphi2009
Libraries: OpenGL 3.x / GLSL

On making a bones example it struggled upon the fact that my normalMatrix is not willing to be bound anymore.

This is a part of the shader:

#version 150

uniform mat3 normalMatrix;
uniform mat4 boneMatrices[2];
uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;

This is how i call it:

g_projectionLocation := glslsimpleprog.GetUniformLocation('projectionMatri x');
g_modelViewLocation := glslsimpleprog.GetUniformLocation('modelViewMatrix ');
g_normalMatrixLocation := glslsimpleprog.GetUniformLocation('normalMatrix');
g_location_boneMatrices_0 := glslsimpleprog.GetUniformLocation('boneMatrices[0]');
g_location_boneMatrices_1 := glslsimpleprog.GetUniformLocation('boneMatrices[1]');

All other matrices do work and so has the normalMatrix

Here is the complete code:
http://www.noeska.net/downloads/ogl3bones1.zip

What am i missing here?

noeska
30-12-2009, 11:04 AM
On the delphigl forum is pointed to the fact that when a uniform is not used in an shader it is not availeable. Next to that somewhere during the day something on my pc became corrupted as source that did not work yesterday now works :-)

Here is the bugfixed version: http://www.noeska.net/downloads/ogl3bones3.zip and for those who are interested the original: http://www.codesampler.com/oglsrc/oglsrc_11.htm#ogl_skinning

phibermon
27-02-2010, 06:53 PM
that's quite a slow method, much better to upload all per vertex data into a VBO, one array after another, bind the VBO and then use glVertexAttribPointer with an offset into the VBO for each attribute (message me for an example).

Then you only have to pass the bone matricies or positons and Quaternions in as uniforms. Bone ID's, weights, normals, vertices etc etc can all live in the VBO.

noeska
28-02-2010, 11:21 AM
It is an example helping me to understand what is going on. Moving slowly away from doing such things on the cpu.

Do provide an example how to do things efficiently. So me and other can learn from that.