Jump to content
  • Advertisement
Sign in to follow this  
dpadam450

GLSL matrix storage

This topic is 4001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!