I'm wondering if this API method used to load a shader program is expensive or not to call? Im considering making this call per object in my 3D scene.
gl.useProgram(shaderProgram);
thanks
glUseProgram
than is to glAttachShader
+glLinkProgram
glUseProgram
is least heavySo, conslusion: use it moderately. If you don't have much objects - great, if you do - try optimizing shader switching, or reusing shaders multiple times, or use same shader that utilizes branching somehow.
useProgram
has got medium performance hit. It's not super-light, neither it's super-heavy like linkProgram
and compileShader
.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With