changing uniforms expensive?

Started by
1 comment, last by V-man 12 years, 2 months ago
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)
Advertisement
If storing the transform in the vertex data is an option then why not simply store the transformed vertices to begin with?
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);

This topic is closed to new replies.

Advertisement