diff --git a/src/core/renderers/webgl/shaders/FastShader.js b/src/core/renderers/webgl/shaders/FastShader.js index 46e7c8e..bd2e29a 100644 --- a/src/core/renderers/webgl/shaders/FastShader.js +++ b/src/core/renderers/webgl/shaders/FastShader.js @@ -13,7 +13,7 @@ [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', - 'attribute vec4 aColor;', + 'attribute float aColor;', 'attribute vec2 aPositionCoord;', 'attribute vec2 aScale;', @@ -24,7 +24,7 @@ 'uniform mat3 uMatrix;', 'varying vec2 vTextureCoord;', - 'varying vec4 vColor;', + 'varying float vColor;', 'const vec2 center = vec2(-1.0, 1.0);', @@ -41,7 +41,18 @@ '}' ].join('\n'), // fragment shader, use default - null, + [ + 'precision lowp float;', + + 'varying vec2 vTextureCoord;', + 'varying float vColor;', + + 'uniform sampler2D uSampler;', + + 'void main(void) {', + ' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;', + '}' + ].join('\n'), // custom uniforms { uMatrix: { type: 'mat3', value: new Float32Array(9) } diff --git a/src/core/renderers/webgl/shaders/FastShader.js b/src/core/renderers/webgl/shaders/FastShader.js index 46e7c8e..bd2e29a 100644 --- a/src/core/renderers/webgl/shaders/FastShader.js +++ b/src/core/renderers/webgl/shaders/FastShader.js @@ -13,7 +13,7 @@ [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', - 'attribute vec4 aColor;', + 'attribute float aColor;', 'attribute vec2 aPositionCoord;', 'attribute vec2 aScale;', @@ -24,7 +24,7 @@ 'uniform mat3 uMatrix;', 'varying vec2 vTextureCoord;', - 'varying vec4 vColor;', + 'varying float vColor;', 'const vec2 center = vec2(-1.0, 1.0);', @@ -41,7 +41,18 @@ '}' ].join('\n'), // fragment shader, use default - null, + [ + 'precision lowp float;', + + 'varying vec2 vTextureCoord;', + 'varying float vColor;', + + 'uniform sampler2D uSampler;', + + 'void main(void) {', + ' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;', + '}' + ].join('\n'), // custom uniforms { uMatrix: { type: 'mat3', value: new Float32Array(9) } diff --git a/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js b/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js index 18727e1..c4721e9 100644 --- a/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js +++ b/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js @@ -424,10 +424,10 @@ // set the projection var projection = this.renderer.projection; - gl.uniform2f(this.shader.projectionVector, projection.x, projection.y); + gl.uniform2f(this.shader.uniforms.projectionVector._location, projection.x, projection.y); // set the matrix - gl.uniformMatrix3fv(this.shader.uMatrix, false, this.matrix); + gl.uniformMatrix3fv(this.shader.uniforms.uMatrix._location, false, this.matrix); // set the pointers var stride = this.vertByteSize;