Wip fixing filter issue with multitexture

This commit is contained in:
Felipe Alfonso 2016-09-12 23:17:25 -03:00
parent c8f7761cc9
commit 34cb845ac8
4 changed files with 11 additions and 3 deletions

View file

@ -529,7 +529,9 @@ PIXI.DisplayObject.prototype = {
if (!this._cachedSprite)
{
var renderTexture = new PIXI.RenderTexture(bounds.width, bounds.height);
var textureUnit = 0;
var renderTexture = new PIXI.RenderTexture(bounds.width, bounds.height, null, null, null, textureUnit);
this._cachedSprite = new PIXI.Sprite(renderTexture);
this._cachedSprite.worldTransform = this.worldTransform;
}

View file

@ -67,7 +67,7 @@ PIXI.PixiFastShader = function (gl) {
'varying float vTextureIndex;',
'uniform sampler2D uSampler;',
'void main(void) {',
' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;'
' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;',
'}'
];
}

View file

@ -38,6 +38,8 @@ PIXI.FilterTexture = function(gl, width, height, scaleMode)
*/
scaleMode = scaleMode || PIXI.scaleModes.DEFAULT;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);

View file

@ -32,8 +32,9 @@
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
* @param resolution {Number} The resolution of the texture being generated
*/
PIXI.RenderTexture = function(width, height, renderer, scaleMode, resolution)
PIXI.RenderTexture = function(width, height, renderer, scaleMode, resolution, textureUnit)
{
textureUnit = typeof textureUnit == 'number' ? textureUnit : 0;
/**
* The with of the render texture
*
@ -107,6 +108,8 @@ PIXI.RenderTexture = function(width, height, renderer, scaleMode, resolution)
if (this.renderer.type === PIXI.WEBGL_RENDERER)
{
var gl = this.renderer.gl;
// gl.activeTexture(gl.TEXTURE0 + textureUnit);
this.baseTexture.textureIndex = textureUnit;
this.baseTexture._dirty[gl.id] = false;
this.textureBuffer = new PIXI.FilterTexture(gl, this.width, this.height, this.baseTexture.scaleMode);
@ -245,6 +248,7 @@ PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, matrix, clear
this.renderer.spriteBatch.dirty = true;
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
};
/**