mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Modify Tile Shader to produce scaled layers that look identical to the Canvas renderer scaling (add uCentreOffset, scale the drawing coordinates, subtract uCentreOffset).
This commit is contained in:
parent
0b392e19a2
commit
fdb80f1a55
1 changed files with 6 additions and 4 deletions
|
@ -41,12 +41,13 @@ PIXI.TilemapShader = function(gl)
|
||||||
|
|
||||||
this.vertexSrc = [
|
this.vertexSrc = [
|
||||||
" precision lowp float;",
|
" precision lowp float;",
|
||||||
" uniform vec2 uScrollOffset;",
|
" uniform vec2 uCentreOffset;",
|
||||||
|
" uniform vec2 uScale;",
|
||||||
" attribute vec4 aPosition;",
|
" attribute vec4 aPosition;",
|
||||||
" varying vec2 vTexCoord;",
|
" varying vec2 vTexCoord;",
|
||||||
" void main(void) {",
|
" void main(void) {",
|
||||||
" gl_Position.zw = vec2(1, 1);",
|
" gl_Position.zw = vec2(1, 1);",
|
||||||
" gl_Position.xy = aPosition.xy - uScrollOffset;",
|
" gl_Position.xy = (aPosition.xy + uCentreOffset) * uScale - uCentreOffset;",
|
||||||
" vTexCoord = aPosition.zw;",
|
" vTexCoord = aPosition.zw;",
|
||||||
" }"
|
" }"
|
||||||
];
|
];
|
||||||
|
@ -79,11 +80,12 @@ PIXI.TilemapShader.prototype.init = function()
|
||||||
// get and store the attributes
|
// get and store the attributes
|
||||||
this.aPosition = gl.getAttribLocation(program, 'aPosition');
|
this.aPosition = gl.getAttribLocation(program, 'aPosition');
|
||||||
this.uSampler = gl.getUniformLocation(program, 'uImageSampler');
|
this.uSampler = gl.getUniformLocation(program, 'uImageSampler');
|
||||||
this.uScrollOffset = gl.getUniformLocation(program, 'uScrollOffset');
|
this.uCentreOffset = gl.getUniformLocation(program, 'uCentreOffset');
|
||||||
this.uAlpha = gl.getUniformLocation(program, 'uAlpha');
|
this.uAlpha = gl.getUniformLocation(program, 'uAlpha');
|
||||||
|
this.uScale = gl.getUniformLocation(program, 'uScale');
|
||||||
|
|
||||||
this.attributes = [this.aPosition, this.uSampler];
|
this.attributes = [this.aPosition, this.uSampler];
|
||||||
this.uniforms = [this.uScrollOffset, this.uAlpha];
|
this.uniforms = [this.uCentreOffset, this.uAlpha, this.uScale];
|
||||||
|
|
||||||
this.program = program;
|
this.program = program;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue