patriciogonzalezvivo / glslCanvas

Simple tool to load GLSL shaders on HTML Canvas using WebGL
http://patriciogonzalezvivo.github.io/glslCanvas/
MIT License
1.99k stars 183 forks source link

slow call to getUniformLocation on every uniform update. #15

Open bejayoharen opened 7 years ago

bejayoharen commented 7 years ago

I noticed that every time you update a uniform value the code calls this:

this.gl.getUniformLocation(this.program, name);

It's my understanding that this is (or can be) a pretty slow call. An easy fix would be to lazy initialize the value.

see for example: http://nical.github.io/onGameStart2013/ (slide 7)

If you like I supply a patch.

patriciogonzalezvivo commented 7 years ago

Please do, not sure what you mean by that. But any optimization is always wellcome

bejayoharen commented 7 years ago

Sorry I can't test it at the moment, but I thought I'd send a pull request anyway so even if it's wrong you can see what I'm talking about:

https://github.com/patriciogonzalezvivo/glslCanvas/pull/16

patriciogonzalezvivo commented 7 years ago

Sorry for the double replay... may be here is better.

GlslCanvas (that is use by glslEditor) have as main feature, allowing you to reload different vert/frag shaders. Seams like keeping a record of the location will prevent access for future locations in case the code change and new shader programs are running.