diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index b00ce59..02b30e4 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -356,6 +356,9 @@ // reset the render session data.. this.renderSession.drawCount = 0; + // make sure to flip the Y if using a render texture.. + this.renderSession.flipY = buffer ? -1 : 1; + // set the default projection this.renderSession.projection = projection; diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index b00ce59..02b30e4 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -356,6 +356,9 @@ // reset the render session data.. this.renderSession.drawCount = 0; + // make sure to flip the Y if using a render texture.. + this.renderSession.flipY = buffer ? -1 : 1; + // set the default projection this.renderSession.projection = projection; diff --git a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js index b745bb4..bbd3259 100644 --- a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -60,13 +60,13 @@ 'uniform vec3 tint;', 'uniform float alpha;', 'uniform vec3 color;', - + 'uniform float flipY;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = vec4(color * alpha * tint, alpha);',//" * vec4(tint * alpha, alpha);', '}' ]; @@ -93,6 +93,7 @@ this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); this.color = gl.getUniformLocation(program, 'color'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index b00ce59..02b30e4 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -356,6 +356,9 @@ // reset the render session data.. this.renderSession.drawCount = 0; + // make sure to flip the Y if using a render texture.. + this.renderSession.flipY = buffer ? -1 : 1; + // set the default projection this.renderSession.projection = projection; diff --git a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js index b745bb4..bbd3259 100644 --- a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -60,13 +60,13 @@ 'uniform vec3 tint;', 'uniform float alpha;', 'uniform vec3 color;', - + 'uniform float flipY;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = vec4(color * alpha * tint, alpha);',//" * vec4(tint * alpha, alpha);', '}' ]; @@ -93,6 +93,7 @@ this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); this.color = gl.getUniformLocation(program, 'color'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index 685f76a..bdaab89 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -55,13 +55,14 @@ 'uniform vec2 projectionVector;', 'uniform vec2 offsetVector;', 'uniform float alpha;', + 'uniform float flipY;', 'uniform vec3 tint;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = aColor * vec4(tint * alpha, alpha);', '}' ]; @@ -87,6 +88,7 @@ this.projectionVector = gl.getUniformLocation(program, 'projectionVector'); this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index b00ce59..02b30e4 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -356,6 +356,9 @@ // reset the render session data.. this.renderSession.drawCount = 0; + // make sure to flip the Y if using a render texture.. + this.renderSession.flipY = buffer ? -1 : 1; + // set the default projection this.renderSession.projection = projection; diff --git a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js index b745bb4..bbd3259 100644 --- a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -60,13 +60,13 @@ 'uniform vec3 tint;', 'uniform float alpha;', 'uniform vec3 color;', - + 'uniform float flipY;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = vec4(color * alpha * tint, alpha);',//" * vec4(tint * alpha, alpha);', '}' ]; @@ -93,6 +93,7 @@ this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); this.color = gl.getUniformLocation(program, 'color'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index 685f76a..bdaab89 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -55,13 +55,14 @@ 'uniform vec2 projectionVector;', 'uniform vec2 offsetVector;', 'uniform float alpha;', + 'uniform float flipY;', 'uniform vec3 tint;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = aColor * vec4(tint * alpha, alpha);', '}' ]; @@ -87,6 +88,7 @@ this.projectionVector = gl.getUniformLocation(program, 'projectionVector'); this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 2598ffb..710383c 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -60,7 +60,9 @@ renderSession.shaderManager.setShader( shader );//activatePrimitiveShader(); shader = renderSession.shaderManager.primitiveShader; gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); - + + gl.uniform1f(shader.flipY, 1); + gl.uniform2f(shader.projectionVector, projection.x, -projection.y); gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); @@ -349,6 +351,8 @@ var triangles = PIXI.PolyK.Triangulate(recPoints); + // + var i = 0; for (i = 0; i < triangles.length; i+=3) { @@ -359,6 +363,7 @@ indices.push(triangles[i+2] + vecPos); } + for (i = 0; i < recPoints.length; i++) { verts.push(recPoints[i], recPoints[++i], r, g, b, alpha); diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index b00ce59..02b30e4 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -356,6 +356,9 @@ // reset the render session data.. this.renderSession.drawCount = 0; + // make sure to flip the Y if using a render texture.. + this.renderSession.flipY = buffer ? -1 : 1; + // set the default projection this.renderSession.projection = projection; diff --git a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js index b745bb4..bbd3259 100644 --- a/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -60,13 +60,13 @@ 'uniform vec3 tint;', 'uniform float alpha;', 'uniform vec3 color;', - + 'uniform float flipY;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = vec4(color * alpha * tint, alpha);',//" * vec4(tint * alpha, alpha);', '}' ]; @@ -93,6 +93,7 @@ this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); this.color = gl.getUniformLocation(program, 'color'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index 685f76a..bdaab89 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -55,13 +55,14 @@ 'uniform vec2 projectionVector;', 'uniform vec2 offsetVector;', 'uniform float alpha;', + 'uniform float flipY;', 'uniform vec3 tint;', 'varying vec4 vColor;', 'void main(void) {', ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);', ' v -= offsetVector.xyx;', - ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);', + ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);', ' vColor = aColor * vec4(tint * alpha, alpha);', '}' ]; @@ -87,6 +88,7 @@ this.projectionVector = gl.getUniformLocation(program, 'projectionVector'); this.offsetVector = gl.getUniformLocation(program, 'offsetVector'); this.tintColor = gl.getUniformLocation(program, 'tint'); + this.flipY = gl.getUniformLocation(program, 'flipY'); // get and store the attributes this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition'); diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 2598ffb..710383c 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -60,7 +60,9 @@ renderSession.shaderManager.setShader( shader );//activatePrimitiveShader(); shader = renderSession.shaderManager.primitiveShader; gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); - + + gl.uniform1f(shader.flipY, 1); + gl.uniform2f(shader.projectionVector, projection.x, -projection.y); gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); @@ -349,6 +351,8 @@ var triangles = PIXI.PolyK.Triangulate(recPoints); + // + var i = 0; for (i = 0; i < triangles.length; i+=3) { @@ -359,6 +363,7 @@ indices.push(triangles[i+2] + vecPos); } + for (i = 0; i < recPoints.length; i++) { verts.push(recPoints[i], recPoints[++i], r, g, b, alpha); diff --git a/src/pixi/renderers/webgl/utils/WebGLStencilManager.js b/src/pixi/renderers/webgl/utils/WebGLStencilManager.js index 367d7dc..989d8cf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLStencilManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLStencilManager.js @@ -143,6 +143,8 @@ renderSession.shaderManager.setShader( shader ); + gl.uniform1f(shader.flipY, renderSession.flipY); + gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); gl.uniform2f(shader.projectionVector, projection.x, -projection.y); @@ -170,6 +172,7 @@ gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniform1f(shader.flipY, renderSession.flipY); gl.uniform2f(shader.projectionVector, projection.x, -projection.y); gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);