View Full Version : debuggin matrices in shader
12-09-2004, 03:19 PM
any tips on determining if matrices are being uploaded with correct values?
what i have is this:
uniform mat4 transform;
mat4 trans = gl_ModelViewProjectionMatrix * transform;
gl_Position = trans * gl_Vertex;
gl_FrontColor = weight;
}i tried loading identity matrix in to all of the transform array, so my model should be at the same location as if the first line was:
mat4 trans = gl_ModelViewProjectionMatrix;
but when i multiply by transform (which should be identity) i cant see me model any more.
12-09-2004, 06:02 PM
Try writing each row of the matrix to the output color (and test a different row on each run)
12-09-2004, 06:40 PM
ah okay so somehow my matrices arent being set, is there a way i can see if glUniformMatrix4fvARB has failed?
i tried calling "glGetError" and the error code i get back is 1281 : "invalid value", what does this mean?
it seems not to like setting more than 1 matrix!
glUniformMatrix4fvARB works fine untill i use a count of more than 1?
even though its an array in my shader:
uniform mat4 transform;
any ideas why this would be happening?
12-09-2004, 08:13 PM
glGetError() to test if the load failed..
Try posting the code that you use to determine the uniform location and uploading the uniform.
Also what card/driver etc...
12-09-2004, 08:18 PM
uh you must have missed my edit (read my above post i edited)
also just read this:
"If the number of values specified by count would exceed the declared extent of the indicated uniform variable, a GL_INVALID_VALUE error is generated and the specified uniform variable will remain unchanged."
but if i set a count of 2, and in my shader the size is 4 it still fails?
ps. i get the handle to the uniform param like this:
p.handle = glGetUniformLocationARB(program, "transform");
static Matrix4 transforms;
glUniformMatrix4fvARB(handle, 4, false, (GLfloat*)transforms);
this will only work if i change 4 to 1 :-/
12-09-2004, 10:28 PM
I'm willing to bet the shader compiler sees that you are not accessing the other matrices and is optimizing them out. From my understanding of the spec, if one array variable is used, they all have to be valid. This may be a bug. What card/driver?
12-09-2004, 10:59 PM
radeon 9600xt driver v4.11
okay i found soem improvement. if i use the last transform in the array, it will allow me to set the transforms.
seems your right. it looks likes its optimising out the transforms array :-/
so i emailed the ATI guys about it. as what im trying to do is to have a dynamic branch so not all transforms will be accessed which may cause issues.
just got everything working. :)
thx 4 your help.
12-10-2004, 12:55 AM
Just found this in the spec:
Uniform xxx .....
When loading N elements starting at an arbitrary position k in a uniform declared
as an array, elements k through k + N − 1 in the array will be replaced
with the new values. Values for any array element that exceeds the highest array
element index used, as reported by GetActiveUniform, will be ignored by the GL.
So it looks like a bug (or most likely ATI have not implemented the GL2.0 spec yet.)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.