mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +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 = [
|
||||
" precision lowp float;",
|
||||
" uniform vec2 uScrollOffset;",
|
||||
" uniform vec2 uCentreOffset;",
|
||||
" uniform vec2 uScale;",
|
||||
" attribute vec4 aPosition;",
|
||||
" varying vec2 vTexCoord;",
|
||||
" void main(void) {",
|
||||
" gl_Position.zw = vec2(1, 1);",
|
||||
" gl_Position.xy = aPosition.xy - uScrollOffset;",
|
||||
" gl_Position.xy = (aPosition.xy + uCentreOffset) * uScale - uCentreOffset;",
|
||||
" vTexCoord = aPosition.zw;",
|
||||
" }"
|
||||
];
|
||||
|
@ -79,11 +80,12 @@ PIXI.TilemapShader.prototype.init = function()
|
|||
// get and store the attributes
|
||||
this.aPosition = gl.getAttribLocation(program, 'aPosition');
|
||||
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.uScale = gl.getUniformLocation(program, 'uScale');
|
||||
|
||||
this.attributes = [this.aPosition, this.uSampler];
|
||||
this.uniforms = [this.uScrollOffset, this.uAlpha];
|
||||
this.uniforms = [this.uCentreOffset, this.uAlpha, this.uScale];
|
||||
|
||||
this.program = program;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue