mirror of
https://github.com/photonstorm/phaser
synced 2024-12-01 08:59:31 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
42738782e0
5 changed files with 45 additions and 20 deletions
|
@ -162,9 +162,19 @@ var StaticTilemap = new Class({
|
||||||
|
|
||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
}
|
}
|
||||||
this.tilemapRenderer.shader.setConstantFloat2(this.tilemapRenderer.scrollLocation, -camera.scrollX, -camera.scrollY);
|
this.tilemapRenderer.shader.setConstantFloat2(this.tilemapRenderer.scrollLocation, camera.scrollX, camera.scrollY);
|
||||||
this.tilemapRenderer.shader.setConstantFloat2(this.tilemapRenderer.scrollFactorLocation, this.scrollFactorX, this.scrollFactorY);
|
this.tilemapRenderer.shader.setConstantFloat2(this.tilemapRenderer.scrollFactorLocation, this.scrollFactorX, this.scrollFactorY);
|
||||||
this.tilemapRenderer.shader.setConstantFloat2(this.tilemapRenderer.tilemapPositionLocation, this.x, this.y);
|
this.tilemapRenderer.shader.setConstantFloat2(this.tilemapRenderer.tilemapPositionLocation, this.x, this.y);
|
||||||
|
var cmat = camera.matrix.matrix;
|
||||||
|
|
||||||
|
this.tilemapRenderer.shader.setConstantMatrix3x3(
|
||||||
|
this.tilemapRenderer.cameraTransformLocation,
|
||||||
|
[
|
||||||
|
cmat[0], cmat[1], 0.0,
|
||||||
|
cmat[2], cmat[3], 0.0,
|
||||||
|
cmat[4], cmat[5], 1.0
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if (this.dirty && !this.gl)
|
else if (this.dirty && !this.gl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ var StaticTilemapCanvasRenderer = function (renderer, gameObject, interpolationP
|
||||||
|
|
||||||
gameObject.upload(camera);
|
gameObject.upload(camera);
|
||||||
|
|
||||||
var tiles = camera.cullTilemap(gameObject);
|
var tiles = gameObject.tiles;
|
||||||
var tileWidth = gameObject.tileWidth;
|
var tileWidth = gameObject.tileWidth;
|
||||||
var tileHeight = gameObject.tileHeight;
|
var tileHeight = gameObject.tileHeight;
|
||||||
var frame = gameObject.frame;
|
var frame = gameObject.frame;
|
||||||
|
|
|
@ -180,7 +180,7 @@ var CanvasRenderer = new Class({
|
||||||
if (!camera.transparent)
|
if (!camera.transparent)
|
||||||
{
|
{
|
||||||
ctx.fillStyle = camera.backgroundColor.rgba;
|
ctx.fillStyle = camera.backgroundColor.rgba;
|
||||||
ctx.fillRect(0, 0, camera.width, camera.height);
|
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentAlpha !== 1)
|
if (this.currentAlpha !== 1)
|
||||||
|
|
|
@ -50,12 +50,14 @@ var TilemapRenderer = new Class({
|
||||||
var scrollLocation = shader.getUniformLocation('u_scroll');
|
var scrollLocation = shader.getUniformLocation('u_scroll');
|
||||||
var scrollFactorLocation = shader.getUniformLocation('u_scroll_factor');
|
var scrollFactorLocation = shader.getUniformLocation('u_scroll_factor');
|
||||||
var tilemapPositionLocation = shader.getUniformLocation('u_tilemap_position');
|
var tilemapPositionLocation = shader.getUniformLocation('u_tilemap_position');
|
||||||
|
var cameraTransformLocation = shader.getUniformLocation('u_camera_matrix');
|
||||||
|
|
||||||
this.shader = shader;
|
this.shader = shader;
|
||||||
this.viewMatrixLocation = viewMatrixLocation;
|
this.viewMatrixLocation = viewMatrixLocation;
|
||||||
this.scrollLocation = scrollLocation;
|
this.scrollLocation = scrollLocation;
|
||||||
this.scrollFactorLocation = scrollFactorLocation;
|
this.scrollFactorLocation = scrollFactorLocation;
|
||||||
this.tilemapPositionLocation = tilemapPositionLocation;
|
this.tilemapPositionLocation = tilemapPositionLocation;
|
||||||
|
this.cameraTransformLocation = cameraTransformLocation;
|
||||||
|
|
||||||
this.resize(this.width, this.height, this.game.config.resolution);
|
this.resize(this.width, this.height, this.game.config.resolution);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,23 +1,36 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
vert: [
|
vert: [
|
||||||
'uniform mat4 u_view_matrix;',
|
'precision mediump float;',
|
||||||
'uniform vec2 u_scroll;',
|
'',
|
||||||
'uniform vec2 u_scroll_factor;',
|
'uniform mat4 u_view_matrix;',
|
||||||
'uniform vec2 u_tilemap_position;',
|
'uniform mat3 u_camera_matrix;',
|
||||||
'attribute vec2 a_position;',
|
'uniform vec2 u_scroll;',
|
||||||
'attribute vec2 a_tex_coord;',
|
'uniform vec2 u_scroll_factor;',
|
||||||
'varying vec2 v_tex_coord;',
|
'uniform vec2 u_tilemap_position;',
|
||||||
'void main () {',
|
'',
|
||||||
' gl_Position = u_view_matrix * vec4(u_tilemap_position + a_position + (u_scroll * u_scroll_factor), 1.0, 1.0);',
|
'attribute vec2 a_position;',
|
||||||
' v_tex_coord = a_tex_coord;',
|
'attribute vec2 a_tex_coord;',
|
||||||
'}'
|
'varying vec2 v_tex_coord;',
|
||||||
|
'',
|
||||||
|
'void main()',
|
||||||
|
'{',
|
||||||
|
' vec2 position = u_tilemap_position + a_position;',
|
||||||
|
' ',
|
||||||
|
' position = position - (u_scroll * u_scroll_factor);',
|
||||||
|
' position = (u_camera_matrix * vec3(position, 1.0)).xy;',
|
||||||
|
' ',
|
||||||
|
' gl_Position = u_view_matrix * vec4(position, 1.0, 1.0);',
|
||||||
|
' v_tex_coord = a_tex_coord;',
|
||||||
|
'}',
|
||||||
|
''
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
frag: [
|
frag: [
|
||||||
'precision mediump float;',
|
'precision mediump float;',
|
||||||
'uniform sampler2D u_sampler2D;',
|
'uniform sampler2D u_sampler2D;',
|
||||||
'varying vec2 v_tex_coord;',
|
'varying vec2 v_tex_coord;',
|
||||||
'void main() {',
|
'void main()',
|
||||||
' gl_FragColor = texture2D(u_sampler2D, v_tex_coord);',
|
'{',
|
||||||
'}'
|
' gl_FragColor = texture2D(u_sampler2D, v_tex_coord);',
|
||||||
|
'}'
|
||||||
].join('\n')
|
].join('\n')
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue