Html5 - bind additional uniform textures to shader

Html5 - bind additional uniform textures to shader

Hello! I have trouble passing multiple textures to my fragment shader. I create shader like this:
this.shader = new cc.GLProgram();

In my fragment there is second sampler:
uniform sampler2D CC_Texture1;

Now Texture0 is bound to my sprite’s texture object, but how do I bind additional textures (TEXTURE1, TEXTURE2, etc)?
I can set unitform like this:
but I also need to tell webgl that it needs to bind additional textures when rendering my sprite:
gl.bindTexture(gl.TEXTURE_2D, this.tex1.getName());, however I don’t know where I should put this line. My sprite.draw function is never called by engine.

Can you help me?

How to pass a uniform sampler2D (texture) to a shader program on HTML5?

hi @unreal_world, how did you solved your issue? I need the same thing: passing a second texture to a shader… please share your solution. thks!


Hi guys. I have made a component for Cocos Creator 1.9.3 for very similar purpose. Couldn’t set second texture for WebGL. Did you solve it?

Here is my topic: