Jump to content

  • Log In with Google      Sign In   
  • Create Account

changing uniforms expensive?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 bimm   Members   -  Reputation: 102

Like
0Likes
Like

Posted 18 February 2012 - 09:22 AM

I have around 4000 buffers that need to be drawn, and I change my shader uniform 'translation' value before each drawing. Should I just store the entire translation+position in the vertex position instead to avoid changing that uniform rapidly? (it would require a larger position datatype to hold the range)

Sponsor:

#2 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 18 February 2012 - 09:26 AM

If storing the transform in the vertex data is an option then why not simply store the transformed vertices to begin with?

#3 V-man   Members   -  Reputation: 805

Like
0Likes
Like

Posted 20 February 2012 - 03:36 PM

You can store the positions in a GL_RGBA32F texture.
Send a texcoord value (1 dimentionsal) to read the GL_RGBA32F texture from your vertex shader.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS