Sign in to follow this  
dpadam450

GLSL matrix storage

Recommended Posts

dpadam450    2357
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;

Share this post


Link to post
Share on other sites
KumGame07    145
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.


Share this post


Link to post
Share on other sites
V-man    813
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();

Share this post


Link to post
Share on other sites
dpadam450    2357
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?

Share this post


Link to post
Share on other sites
V-man    813
Put this in shader
uniform mat4 mymatrix;
and get the location and then
glUniformMatrix(location, FALSE, array_with_matrix, 1);


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this