Shader uniforms

Started by Thomas., May 10, 2013, 09:04:49 PM

Previous topic - Next topic

Thomas.

What differences are between these two methods? GLSLShader.setUniform(String name, float[] array) and GLSLShader.setFloatArrayUniform(...). I think you have added a second one for me, but I can not remember why. I came across a strange behavior. When I set number into shader, performance goes up from 33 to 44 fps. But if I set this number into array  uniform, fps is 33. How is this possible? I've never seen such a large drop in the fps for one array uniform ???

EgonOlsen

The former supports only 1..4 entries and was meant to be used to set float/vec uniforms, not float arrays. I don't see a reason, why it should be slower. It all comes down to a single gl call to set the values, which is


GLES20.glUniform1fv(...)


for float-arrays and


GLES20.glUniform4f(...)


for the float/vec variant.