@@ -36,12 +36,14 @@ PIXI.PixiShader = function(gl)
3636 * @type Array
3737 */
3838 this . fragmentSrc = [
39+ '// PixiShader Fragment Shader.' ,
3940 'precision lowp float;' ,
4041 'varying vec2 vTextureCoord;' ,
4142 'varying vec4 vColor;' ,
42- 'uniform sampler2D uSampler;' ,
43+ 'varying float vTextureIndex;' ,
44+ 'uniform sampler2D uSamplerArray[16];' ,
4345 'void main(void) {' ,
44- ' gl_FragColor = texture2D(uSampler , vTextureCoord) * vColor ;' ,
46+ ' gl_FragColor = texture2D(uSamplerArray[0] , vTextureCoord) * vColor ;' ,
4547 '}'
4648 ] ;
4749
@@ -219,7 +221,8 @@ PIXI.PixiShader.prototype.initSampler2D = function(uniform)
219221
220222 var gl = this . gl ;
221223
222- gl . activeTexture ( gl [ 'TEXTURE' + this . textureCount ] ) ;
224+ // No need to do string manipulation for this.
225+ gl . activeTexture ( gl . TEXTURE0 + this . textureCount ) ;
223226 gl . bindTexture ( gl . TEXTURE_2D , uniform . value . baseTexture . _glTextures [ gl . id ] ) ;
224227
225228 // Extended texture data
@@ -369,21 +372,26 @@ PIXI.PixiShader.prototype.destroy = function()
369372* @type String
370373*/
371374PIXI . PixiShader . defaultVertexSrc = [
375+ '// Default Vertex Shader' ,
376+ '// With multi-texture rendering' ,
372377 'attribute vec2 aVertexPosition;' ,
373378 'attribute vec2 aTextureCoord;' ,
374379 'attribute vec4 aColor;' ,
380+ 'attribute float aTextureIndex;' ,
375381
376382 'uniform vec2 projectionVector;' ,
377383 'uniform vec2 offsetVector;' ,
378384
379385 'varying vec2 vTextureCoord;' ,
380386 'varying vec4 vColor;' ,
387+ 'varying float vTextureIndex;' ,
381388
382389 'const vec2 center = vec2(-1.0, 1.0);' ,
383390
384391 'void main(void) {' ,
385392 ' gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);' ,
386393 ' vTextureCoord = aTextureCoord;' ,
387394 ' vColor = vec4(aColor.rgb * aColor.a, aColor.a);' ,
395+ ' vTextureIndex = aTextureIndex;' ,
388396 '}'
389397] ;
0 commit comments