Fixed a shader bug
This commit is contained in:
parent
17725973bc
commit
557cc775cb
5 changed files with 61 additions and 13 deletions
|
@ -819,6 +819,13 @@ PIXI.DisplayObject = function()
|
||||||
*/
|
*/
|
||||||
this._interactive = false;
|
this._interactive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the curser that will be used when the mouse is over this object. To enable this the element must have interaction = true and buttonMode = true
|
||||||
|
*
|
||||||
|
* @property defaultCursor
|
||||||
|
* @type String
|
||||||
|
*
|
||||||
|
*/
|
||||||
this.defaultCursor = 'pointer';
|
this.defaultCursor = 'pointer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4008,8 +4015,22 @@ PIXI.PixiShader.prototype.init = function()
|
||||||
|
|
||||||
// get and store the attributes
|
// get and store the attributes
|
||||||
this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
|
this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
|
||||||
this.colorAttribute = gl.getAttribLocation(program, 'aColor');
|
|
||||||
this.aTextureCoord = gl.getAttribLocation(program, 'aTextureCoord');
|
this.aTextureCoord = gl.getAttribLocation(program, 'aTextureCoord');
|
||||||
|
this.colorAttribute = gl.getAttribLocation(program, 'aColor');
|
||||||
|
|
||||||
|
|
||||||
|
// Begin worst hack eva //
|
||||||
|
|
||||||
|
// WHY??? ONLY on my chrome pixel the line above returns -1 when using filters?
|
||||||
|
// maybe its somthing to do with the current state of the gl context.
|
||||||
|
// Im convinced this is a bug in the chrome browser as there is NO reason why this should be returning -1 especially as it only manifests on my chrome pixel
|
||||||
|
// If theres any webGL people that know why could happen please help :)
|
||||||
|
if(this.colorAttribute === -1)
|
||||||
|
{
|
||||||
|
this.colorAttribute = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End worst hack eva //
|
||||||
|
|
||||||
// add those custom shaders!
|
// add those custom shaders!
|
||||||
for (var key in this.uniforms)
|
for (var key in this.uniforms)
|
||||||
|
@ -4236,8 +4257,8 @@ PIXI.PixiShader.defaultVertexSrc = [
|
||||||
|
|
||||||
'uniform vec2 projectionVector;',
|
'uniform vec2 projectionVector;',
|
||||||
'uniform vec2 offsetVector;',
|
'uniform vec2 offsetVector;',
|
||||||
'varying vec2 vTextureCoord;',
|
|
||||||
|
|
||||||
|
'varying vec2 vTextureCoord;',
|
||||||
'varying vec4 vColor;',
|
'varying vec4 vColor;',
|
||||||
|
|
||||||
'const vec2 center = vec2(-1.0, 1.0);',
|
'const vec2 center = vec2(-1.0, 1.0);',
|
||||||
|
@ -6194,7 +6215,7 @@ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea,
|
||||||
filter.uniforms.dimensions.value[3] = this.vertexArray[5];//filterArea.height;
|
filter.uniforms.dimensions.value[3] = this.vertexArray[5];//filterArea.height;
|
||||||
// console.log(this.vertexArray[5])
|
// console.log(this.vertexArray[5])
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.syncUniforms();
|
shader.syncUniforms();
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
||||||
|
@ -6204,7 +6225,7 @@ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea,
|
||||||
gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
||||||
gl.vertexAttribPointer(shader.colorAttribute, 1, gl.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(shader.colorAttribute, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||||
|
|
||||||
|
@ -6249,7 +6270,10 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
|
||||||
this.uvArray,
|
this.uvArray,
|
||||||
gl.STATIC_DRAW);
|
gl.STATIC_DRAW);
|
||||||
|
|
||||||
this.colorArray = new Float32Array([1.0, 1.0 , 1.0, 1.0]);
|
this.colorArray = new Float32Array([1.0, 0xFFFFFF,
|
||||||
|
1.0, 0xFFFFFF,
|
||||||
|
1.0, 0xFFFFFF,
|
||||||
|
1.0, 0xFFFFFF]);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
||||||
gl.bufferData(
|
gl.bufferData(
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -122,6 +122,13 @@ PIXI.DisplayObject = function()
|
||||||
*/
|
*/
|
||||||
this._interactive = false;
|
this._interactive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the curser that will be used when the mouse is over this object. To enable this the element must have interaction = true and buttonMode = true
|
||||||
|
*
|
||||||
|
* @property defaultCursor
|
||||||
|
* @type String
|
||||||
|
*
|
||||||
|
*/
|
||||||
this.defaultCursor = 'pointer';
|
this.defaultCursor = 'pointer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,8 +59,22 @@ PIXI.PixiShader.prototype.init = function()
|
||||||
|
|
||||||
// get and store the attributes
|
// get and store the attributes
|
||||||
this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
|
this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
|
||||||
this.colorAttribute = gl.getAttribLocation(program, 'aColor');
|
|
||||||
this.aTextureCoord = gl.getAttribLocation(program, 'aTextureCoord');
|
this.aTextureCoord = gl.getAttribLocation(program, 'aTextureCoord');
|
||||||
|
this.colorAttribute = gl.getAttribLocation(program, 'aColor');
|
||||||
|
|
||||||
|
|
||||||
|
// Begin worst hack eva //
|
||||||
|
|
||||||
|
// WHY??? ONLY on my chrome pixel the line above returns -1 when using filters?
|
||||||
|
// maybe its somthing to do with the current state of the gl context.
|
||||||
|
// Im convinced this is a bug in the chrome browser as there is NO reason why this should be returning -1 especially as it only manifests on my chrome pixel
|
||||||
|
// If theres any webGL people that know why could happen please help :)
|
||||||
|
if(this.colorAttribute === -1)
|
||||||
|
{
|
||||||
|
this.colorAttribute = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End worst hack eva //
|
||||||
|
|
||||||
// add those custom shaders!
|
// add those custom shaders!
|
||||||
for (var key in this.uniforms)
|
for (var key in this.uniforms)
|
||||||
|
@ -287,8 +301,8 @@ PIXI.PixiShader.defaultVertexSrc = [
|
||||||
|
|
||||||
'uniform vec2 projectionVector;',
|
'uniform vec2 projectionVector;',
|
||||||
'uniform vec2 offsetVector;',
|
'uniform vec2 offsetVector;',
|
||||||
'varying vec2 vTextureCoord;',
|
|
||||||
|
|
||||||
|
'varying vec2 vTextureCoord;',
|
||||||
'varying vec4 vColor;',
|
'varying vec4 vColor;',
|
||||||
|
|
||||||
'const vec2 center = vec2(-1.0, 1.0);',
|
'const vec2 center = vec2(-1.0, 1.0);',
|
||||||
|
|
|
@ -323,7 +323,7 @@ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea,
|
||||||
filter.uniforms.dimensions.value[3] = this.vertexArray[5];//filterArea.height;
|
filter.uniforms.dimensions.value[3] = this.vertexArray[5];//filterArea.height;
|
||||||
// console.log(this.vertexArray[5])
|
// console.log(this.vertexArray[5])
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.syncUniforms();
|
shader.syncUniforms();
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
||||||
|
@ -333,7 +333,7 @@ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea,
|
||||||
gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
||||||
gl.vertexAttribPointer(shader.colorAttribute, 1, gl.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(shader.colorAttribute, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||||
|
|
||||||
|
@ -378,7 +378,10 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
|
||||||
this.uvArray,
|
this.uvArray,
|
||||||
gl.STATIC_DRAW);
|
gl.STATIC_DRAW);
|
||||||
|
|
||||||
this.colorArray = new Float32Array([1.0, 1.0 , 1.0, 1.0]);
|
this.colorArray = new Float32Array([1.0, 0xFFFFFF,
|
||||||
|
1.0, 0xFFFFFF,
|
||||||
|
1.0, 0xFFFFFF,
|
||||||
|
1.0, 0xFFFFFF]);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
||||||
gl.bufferData(
|
gl.bufferData(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue