WebGL Render Bug Fix
This commit is contained in:
parent
953a19ff5c
commit
c6e6f7458e
36 changed files with 729 additions and 340 deletions
|
@ -168,6 +168,7 @@ PIXI.shaderVertexSrc = [
|
|||
"attribute vec2 aTextureCoord;",
|
||||
"attribute float aColor;",
|
||||
//"uniform mat4 uMVMatrix;",
|
||||
|
||||
"uniform vec2 projectionVector;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
|
@ -182,6 +183,20 @@ PIXI.shaderVertexSrc = [
|
|||
/*
|
||||
* the triangle strip shader..
|
||||
*/
|
||||
|
||||
PIXI.stripShaderFragmentSrc = [
|
||||
"precision mediump float;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
"uniform float alpha;",
|
||||
"uniform sampler2D uSampler;",
|
||||
"void main(void) {",
|
||||
"gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));",
|
||||
"gl_FragColor = gl_FragColor * alpha;",
|
||||
"}"
|
||||
];
|
||||
|
||||
|
||||
PIXI.stripShaderVertexSrc = [
|
||||
"attribute vec2 aVertexPosition;",
|
||||
"attribute vec2 aTextureCoord;",
|
||||
|
@ -216,16 +231,18 @@ PIXI.primitiveShaderVertexSrc = [
|
|||
"attribute vec4 aColor;",
|
||||
"uniform mat3 translationMatrix;",
|
||||
"uniform vec2 projectionVector;",
|
||||
"uniform float alpha;",
|
||||
"varying vec4 vColor;",
|
||||
"void main(void) {",
|
||||
"vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);",
|
||||
"gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);",
|
||||
"vColor = aColor;",
|
||||
"vColor = aColor * alpha;",
|
||||
"}"
|
||||
];
|
||||
|
||||
PIXI.initPrimitiveShader = function()
|
||||
{
|
||||
return;
|
||||
var gl = PIXI.gl;
|
||||
|
||||
var shaderProgram = PIXI.compileProgram(PIXI.primitiveShaderVertexSrc, PIXI.primitiveShaderFragmentSrc)
|
||||
|
@ -234,8 +251,11 @@ PIXI.initPrimitiveShader = function()
|
|||
|
||||
shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
|
||||
shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor");
|
||||
|
||||
shaderProgram.projectionVector = gl.getUniformLocation(shaderProgram, "projectionVector");
|
||||
shaderProgram.translationMatrix = gl.getUniformLocation(shaderProgram, "translationMatrix");
|
||||
|
||||
shaderProgram.alpha = gl.getUniformLocation(shaderProgram, "alpha");
|
||||
|
||||
PIXI.primitiveProgram = shaderProgram;
|
||||
}
|
||||
|
@ -252,7 +272,7 @@ PIXI.initDefaultShader = function()
|
|||
shaderProgram.textureCoordAttribute = gl.getAttribLocation(shaderProgram, "aTextureCoord");
|
||||
shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor");
|
||||
|
||||
shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
|
||||
// shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
|
||||
shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler");
|
||||
|
||||
PIXI.shaderProgram = shaderProgram;
|
||||
|
@ -261,7 +281,7 @@ PIXI.initDefaultShader = function()
|
|||
PIXI.initDefaultStripShader = function()
|
||||
{
|
||||
var gl = this.gl;
|
||||
var shaderProgram = PIXI.compileProgram(PIXI.stripShaderVertexSrc, PIXI.shaderFragmentSrc)
|
||||
var shaderProgram = PIXI.compileProgram(PIXI.stripShaderVertexSrc, PIXI.stripShaderFragmentSrc)
|
||||
|
||||
gl.useProgram(shaderProgram);
|
||||
|
||||
|
@ -269,6 +289,7 @@ PIXI.initDefaultStripShader = function()
|
|||
shaderProgram.projectionVector = gl.getUniformLocation(shaderProgram, "projectionVector");
|
||||
shaderProgram.textureCoordAttribute = gl.getAttribLocation(shaderProgram, "aTextureCoord");
|
||||
shaderProgram.translationMatrix = gl.getUniformLocation(shaderProgram, "translationMatrix");
|
||||
shaderProgram.alpha = gl.getUniformLocation(shaderProgram, "alpha");
|
||||
|
||||
shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor");
|
||||
|
||||
|
@ -311,9 +332,13 @@ PIXI.activateDefaultShader = function()
|
|||
|
||||
gl.useProgram(shaderProgram);
|
||||
|
||||
|
||||
gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);
|
||||
gl.enableVertexAttribArray(shaderProgram.textureCoordAttribute);
|
||||
gl.enableVertexAttribArray(shaderProgram.colorAttribute);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
PIXI.compileProgram = function(vertexSrc, fragmentSrc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue