GLSL matrix storage
To summarize I print the matrix (projection*modelview) to a file. In the shader I use a static mat4 with those printed numbers, but the results are not the same as using gl_ModelViewProjectionMatrix;
In software, I did this (in pseudocode):
float model[16], projection[16], final[16];
glGetMatrix(GL_MODELVIEW, model);
glGetMatrix(GL_PROJECTION, projection);
glLoadIdentity();
glMultMatrix(projection);
glMultMatrix(model);
glGetMatrix(GL_MODELVIEW, final); <<----I saved the final as (projection*model);
In the shader I use:
//modelview is actually (projection*modelview) as previous line above shows.
gl_Position = gl_ModelViewMatrix*gl_Vertex;
This works perfectly fine. But if I print final to a txt file, and use a static mat4 final = mat4{final[0], final[1].......), then this code doesnt work:
gl_Position = final*gl_Vertex;
What happens if you use 'final' in your shader? Nothing gets displayed or the object being rendered is not proper?
How are you passing the array 'final' to your shader ?
Is it passed correctly ? I dont see any other reason.
How are you passing the array 'final' to your shader ?
Is it passed correctly ? I dont see any other reason.
I don't see anything wrong with your code.
Anyway, is there a particular reason you are doing it this way?
It's best to upload you projection matrix to GL_PROJECTION and modelview to GL_MODELVIEW
and in your shader, just stick a
gl_Position = ftransform();
Anyway, is there a particular reason you are doing it this way?
It's best to upload you projection matrix to GL_PROJECTION and modelview to GL_MODELVIEW
and in your shader, just stick a
gl_Position = ftransform();
When I use final, I'm not sure exactly what it does but its not right.
I can't use ftransform() as its for skeletal animation. Which btw, What is the proper way to send a mat4 to a shader?
I can't use ftransform() as its for skeletal animation. Which btw, What is the proper way to send a mat4 to a shader?
Put this in shader
uniform mat4 mymatrix;
and get the location and then
glUniformMatrix(location, FALSE, array_with_matrix, 1);
uniform mat4 mymatrix;
and get the location and then
glUniformMatrix(location, FALSE, array_with_matrix, 1);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement