|
1 | 1 | module.exports = { |
2 | 2 | vert: [ |
3 | | - 'uniform mat4 u_view_matrix;', |
4 | | - 'uniform vec2 u_scroll;', |
5 | | - 'uniform vec2 u_scroll_factor;', |
6 | | - 'uniform vec2 u_tilemap_position;', |
7 | | - 'attribute vec2 a_position;', |
8 | | - 'attribute vec2 a_tex_coord;', |
9 | | - 'varying vec2 v_tex_coord;', |
10 | | - 'void main () {', |
11 | | - ' gl_Position = u_view_matrix * vec4(u_tilemap_position + a_position + (u_scroll * u_scroll_factor), 1.0, 1.0);', |
12 | | - ' v_tex_coord = a_tex_coord;', |
13 | | - '}' |
| 3 | + 'precision mediump float;', |
| 4 | + '', |
| 5 | + 'uniform mat4 u_view_matrix;', |
| 6 | + 'uniform mat3 u_camera_matrix;', |
| 7 | + 'uniform vec2 u_scroll;', |
| 8 | + 'uniform vec2 u_scroll_factor;', |
| 9 | + 'uniform vec2 u_tilemap_position;', |
| 10 | + '', |
| 11 | + 'attribute vec2 a_position;', |
| 12 | + 'attribute vec2 a_tex_coord;', |
| 13 | + 'varying vec2 v_tex_coord;', |
| 14 | + '', |
| 15 | + 'void main()', |
| 16 | + '{', |
| 17 | + ' vec2 position = u_tilemap_position + a_position;', |
| 18 | + ' ', |
| 19 | + ' position = position - (u_scroll * u_scroll_factor);', |
| 20 | + ' position = (u_camera_matrix * vec3(position, 1.0)).xy;', |
| 21 | + ' ', |
| 22 | + ' gl_Position = u_view_matrix * vec4(position, 1.0, 1.0);', |
| 23 | + ' v_tex_coord = a_tex_coord;', |
| 24 | + '}', |
| 25 | + '' |
14 | 26 | ].join('\n'), |
15 | 27 | frag: [ |
16 | | - 'precision mediump float;', |
17 | | - 'uniform sampler2D u_sampler2D;', |
18 | | - 'varying vec2 v_tex_coord;', |
19 | | - 'void main() {', |
20 | | - ' gl_FragColor = texture2D(u_sampler2D, v_tex_coord);', |
21 | | - '}' |
| 28 | + 'precision mediump float;', |
| 29 | + 'uniform sampler2D u_sampler2D;', |
| 30 | + 'varying vec2 v_tex_coord;', |
| 31 | + 'void main()', |
| 32 | + '{', |
| 33 | + ' gl_FragColor = texture2D(u_sampler2D, v_tex_coord);', |
| 34 | + '}' |
22 | 35 | ].join('\n') |
23 | 36 | }; |
0 commit comments