|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | /** |
8 | | -* This is a base Filter template to use for any Phaser filter development. |
| 8 | +* This is a base Filter class to use for any Phaser filter development. |
9 | 9 | * |
10 | 10 | * @class Phaser.Filter |
11 | 11 | * @constructor |
@@ -52,17 +52,38 @@ Phaser.Filter = function (game, uniforms, fragmentSrc) { |
52 | 52 | */ |
53 | 53 | this.padding = 0; |
54 | 54 |
|
| 55 | + /* |
| 56 | + * The supported types are: 1f, 1fv, 1i, 2f, 2fv, 2i, 2iv, 3f, 3fv, 3i, 3iv, 4f, 4fv, 4i, 4iv, mat2, mat3, mat4 and sampler2D. |
| 57 | + */ |
| 58 | + |
| 59 | + var d = new Date(); |
| 60 | + |
55 | 61 | /** |
56 | | - * @property {object} uniforms - Default uniform mappings. |
| 62 | + * @property {object} uniforms - Default uniform mappings. Compatible with ShaderToy and GLSLSandbox. |
57 | 63 | */ |
58 | 64 | this.uniforms = { |
59 | 65 |
|
60 | | - time: { type: '1f', value: 0 }, |
61 | 66 | resolution: { type: '2f', value: { x: 256, y: 256 }}, |
62 | | - mouse: { type: '2f', value: { x: 0.0, y: 0.0 }} |
| 67 | + time: { type: '1f', value: 0 }, |
| 68 | + mouse: { type: '2f', value: { x: 0.0, y: 0.0 } }, |
| 69 | + date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() *60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] }, |
| 70 | + sampleRate: { type: '1f', value: 44100.0 }, |
| 71 | + iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } }, |
| 72 | + iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } }, |
| 73 | + iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } }, |
| 74 | + iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } } |
63 | 75 |
|
64 | 76 | }; |
65 | 77 |
|
| 78 | + // Copy over/replace any passed in the constructor |
| 79 | + if (uniforms) |
| 80 | + { |
| 81 | + for (var key in uniforms) |
| 82 | + { |
| 83 | + this.uniforms[key] = uniforms[key]; |
| 84 | + } |
| 85 | + } |
| 86 | + |
66 | 87 | /** |
67 | 88 | * @property {array} fragmentSrc - The fragment shader code. |
68 | 89 | */ |
|
0 commit comments