www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Thomas. on May 10, 2013, 09:04:49 PM

Title: Shader uniforms
Post by: Thomas. 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 ???
Title: Re: Shader uniforms
Post by: EgonOlsen 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


GLES20.glUniform1fv(...)


for float-arrays and


GLES20.glUniform4f(...)


for the float/vec variant.