Author Topic: Shader uniforms  (Read 2074 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Shader uniforms
« on: May 10, 2013, 09:04:49 pm »
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 ???

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Shader uniforms
« Reply #1 on: May 12, 2013, 08:28:09 pm »
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

Code: [Select]
GLES20.glUniform1fv(...)

for float-arrays and

Code: [Select]
GLES20.glUniform4f(...)

for the float/vec variant.