webgl - How often do I have to update my uniforms? -


all of webgl sample code i've seen calls gl.useprogram(), , sets every uniform program, once per frame. thing is, 2 costly things can in webgl project run lines of javascript , copy stuff javascript shader, , here's doing both sixty times second. also, know of uniforms, in own program, not change frame frame. (it's light positions , such, stuff could mess don't.)

my question is, webgl specification have how long uniforms' values preserved? if call gl.useprogram(), might program i've stopped using lose uniforms? if calling gl.useprogram() scrambles uniforms, can not call every frame, , have uniforms preserved?

if force users run firefox 22.0 forever, write , run test code, , have figured out in jiffy. sadly...

a uniform's value associated particular program. not go away because switched program. (i don't have spec reference handy.)

probably code you're seeing setting uniforms every frame 1 of these reasons:

  • simple laziness: work, other things require thought.

  • copying code other cases uniform does need set every frame.

  • complex laziness: it's hard define circumstances under correct value of parameter does change, recompute every frame. or, may more computationally expensive figure out whether needs change!

also, doing uniforms every frame isn't bad, because there's few uniforms , they're not data. computing or copying vertex arrays or other per-scene-object stuff sort of thing should worry first.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -