i have two shaders that use different vertexarrays and different uniform values but they use the same texture (spritesheet/atlas). is it possible for them to share the same texture (without causing the texture to be sent to the gpu twice)?
background: My game has some serious performance issues on my laptop and they seem to be gpu related. My current implementation uses two canvases, one for my background and one for my foreground. they then get composed for the final image (draw onto 3rd canvas). My background uses 4 textures, whereas my foreground has one large spritesheet. both foreground and background only use one draw call.
I'm hoping to improve performance by drawing everything to one canvas and also by combining all textures into one spritesheet. its absolutely possible this will result in no improvement. my background uses noise to blend textures and its very possible that the main issue is the complexity of the shader.
Yes
Texture's are only sent to the GPU when you call
gl.texImage2D
orgl.texSubImage2D
.The most common form of setting a WebGL program is
At Init time
At Render Time
For textures the "at init time part" generally means calling
At runtime
As far as combing your textures into a texture atlas, yes, that will likely make your program run faster. That's not because you're uploading textures less though it's because you can draw more things with less draw calls. See the cube example near the bottom of this article.