mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
Added a few new uniforms and tidied things up.
This commit is contained in:
parent
86cfc7111e
commit
967497c572
2 changed files with 26 additions and 5 deletions
|
@ -10,7 +10,7 @@ Phaser.Filter.SampleFilter = function (game) {
|
||||||
*
|
*
|
||||||
* uniform float time - The current number of elapsed milliseconds in the game.
|
* uniform float time - The current number of elapsed milliseconds in the game.
|
||||||
* uniform vec2 resolution - The dimensions of the filter. Can be set via setSize(width, height)
|
* uniform vec2 resolution - The dimensions of the filter. Can be set via setSize(width, height)
|
||||||
* uniform vec4 mouse - The mouse / touch coordinates taken from the pointer given to the update function, if any.
|
* uniform vec2 mouse - The mouse / touch coordinates taken from the pointer given to the update function, if any.
|
||||||
* uniform sampler2D uSampler - The current texture (usually the texture of the Sprite the shader is bound to)
|
* uniform sampler2D uSampler - The current texture (usually the texture of the Sprite the shader is bound to)
|
||||||
*
|
*
|
||||||
* Add in any additional vars you require. Here is a new one called 'wobble' that is a 2f:
|
* Add in any additional vars you require. Here is a new one called 'wobble' that is a 2f:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a base Filter template to use for any Phaser filter development.
|
* This is a base Filter class to use for any Phaser filter development.
|
||||||
*
|
*
|
||||||
* @class Phaser.Filter
|
* @class Phaser.Filter
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -52,17 +52,38 @@ Phaser.Filter = function (game, uniforms, fragmentSrc) {
|
||||||
*/
|
*/
|
||||||
this.padding = 0;
|
this.padding = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The supported types are: 1f, 1fv, 1i, 2f, 2fv, 2i, 2iv, 3f, 3fv, 3i, 3iv, 4f, 4fv, 4i, 4iv, mat2, mat3, mat4 and sampler2D.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var d = new Date();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {object} uniforms - Default uniform mappings.
|
* @property {object} uniforms - Default uniform mappings. Compatible with ShaderToy and GLSLSandbox.
|
||||||
*/
|
*/
|
||||||
this.uniforms = {
|
this.uniforms = {
|
||||||
|
|
||||||
time: { type: '1f', value: 0 },
|
|
||||||
resolution: { type: '2f', value: { x: 256, y: 256 }},
|
resolution: { type: '2f', value: { x: 256, y: 256 }},
|
||||||
mouse: { type: '2f', value: { x: 0.0, y: 0.0 }}
|
time: { type: '1f', value: 0 },
|
||||||
|
mouse: { type: '2f', value: { x: 0.0, y: 0.0 } },
|
||||||
|
date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() *60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] },
|
||||||
|
sampleRate: { type: '1f', value: 44100.0 },
|
||||||
|
iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } },
|
||||||
|
iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } },
|
||||||
|
iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } },
|
||||||
|
iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Copy over/replace any passed in the constructor
|
||||||
|
if (uniforms)
|
||||||
|
{
|
||||||
|
for (var key in uniforms)
|
||||||
|
{
|
||||||
|
this.uniforms[key] = uniforms[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {array} fragmentSrc - The fragment shader code.
|
* @property {array} fragmentSrc - The fragment shader code.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue