Author Topic: Shaders, possible optimization?  (Read 441 times)

Offline lawless_c

  • int
  • **
  • Posts: 91
    • View Profile
Shaders, possible optimization?
« on: September 08, 2014, 03:28:42 pm »
This is just thought i haven't had a chance to try yet.

But i have multiple floats being sent to a shader, at the moment i do them one at a time.
Would it make more sense to simply add all these floats to an array and send them in one setUniform command?

So instead of using

setUniform(String name, float val) ;
setUniform(String name, float val) ;
setUniform(String name, float val) ;
setUniform(String name, float val) ;


I would use setUniform(String name, float[] val) ;
« Last Edit: September 08, 2014, 04:54:19 pm by lawless_c »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Shaders, possible optimization?
« Reply #1 on: September 08, 2014, 08:53:11 pm »
It might be faster, but i never noticed that setting uniforms is any kind of bottleneck. I wouldn't sacrifice the comfort of having distinct uniforms for some mystical gain that most likely doesn't really exist.