Skip to content

Commit 0f63bfa

Browse files
committed
Fixed problem with filters. If filters are used multi-texture batching support is dropped.
1 parent e67830f commit 0f63bfa

2 files changed

Lines changed: 18 additions & 27 deletions

File tree

src/pixi/renderers/webgl/shaders/PixiShader.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ PIXI.PixiShader = function(gl)
7373
PIXI.PixiShader.prototype.constructor = PIXI.PixiShader;
7474

7575
PIXI.PixiShader.prototype.initMultitexShader = function () {
76+
if (this.fragmentSrc != null) {
77+
// Can't run multi-texture batching with filters
78+
PIXI._enableMultiTextureToggle = false;
79+
this.initDefaultShader();
80+
}
7681
var gl = this.gl;
7782
this.MAX_TEXTURES = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
7883
var dynamicIfs = '\tif (vTextureIndex == 0.0) gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n'
@@ -156,16 +161,19 @@ PIXI.PixiShader.prototype.initMultitexShader = function () {
156161
};
157162

158163
PIXI.PixiShader.prototype.initDefaultShader = function () {
159-
this.fragmentSrc = [
160-
'precision lowp float;',
161-
'varying vec2 vTextureCoord;',
162-
'varying vec4 vColor;',
163-
'varying float vTextureIndex;',
164-
'uniform sampler2D uSampler;',
165-
'void main(void) {',
166-
' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;',
167-
'}'
168-
];
164+
165+
if (this.fragmentSrc === null) {
166+
this.fragmentSrc = [
167+
'precision lowp float;',
168+
'varying vec2 vTextureCoord;',
169+
'varying vec4 vColor;',
170+
'varying float vTextureIndex;',
171+
'uniform sampler2D uSampler;',
172+
'void main(void) {',
173+
' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;',
174+
'}'
175+
];
176+
}
169177

170178
var gl = this.gl;
171179

@@ -391,7 +399,6 @@ PIXI.PixiShader.prototype.syncUniforms = function()
391399
for (var key in this.uniforms)
392400
{
393401
uniform = this.uniforms[key];
394-
395402
if (uniform.glValueLength === 1)
396403
{
397404
if (uniform.glMatrix === true)

src/pixi/renderers/webgl/utils/FilterTexture.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ PIXI.FilterTexture = function(gl, width, height, scaleMode, textureUnit)
6363
* @type WebGLContext
6464
*/
6565
this.gl = gl;
66-
var glUniform1f = gl.uniform1f.bind(gl);
67-
var glGetUniformLocation = gl.getUniformLocation.bind(gl);
68-
gl.uniform1f = function (location, value) {
69-
//console.log('uniform1f', location, value);
70-
glUniform1f(location, value);
71-
// debugger;
72-
};
73-
gl.getUniformLocation = function (program, name) {
74-
console.log('getUniformLocation', program, name);
75-
if (name === 'blur') {
76-
debugger;
77-
}
78-
return glGetUniformLocation(program, name);
79-
//debugger;
80-
};
81-
8266
// next time to create a frame buffer and texture
8367

8468
/**

0 commit comments

Comments
 (0)