Skip to content

Commit 38d8ae7

Browse files
committed
Uniforms properly applied
1 parent e5d944b commit 38d8ae7

2 files changed

Lines changed: 5 additions & 20 deletions

File tree

src/display/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
Bounds: require('./bounds'),
1515
Canvas: require('./canvas'),
1616
Color: require('./color'),
17-
Masks: require('./mask')
17+
Masks: require('./mask'),
18+
Shader: require('./shader/Shader')
1819

1920
};

src/gameobjects/shader/Shader.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var TransformMatrix = require('../components/TransformMatrix');
1818
* TODO:
1919
*
2020
* Test with sampler2D shader
21-
* Load v/f source from file
2221
*
2322
* @class Shader
2423
* @extends Phaser.GameObjects.GameObject
@@ -82,6 +81,7 @@ var Shader = new Class({
8281

8382
/**
8483
* The underlying shader object being used.
84+
* Empty by default and set during a call to the `setShader` method.
8585
*
8686
* @name Phaser.GameObjects.Shader#shader
8787
* @type {Phaser.Display.Shader}
@@ -333,33 +333,17 @@ var Shader = new Class({
333333

334334
var d = new Date();
335335

336-
/*
337336
this.uniforms = Merge(this.shader.uniforms, {
338337
resolution: { type: '2f', value: { x: this.width, y: this.height }},
339338
time: { type: '1f', value: 0 },
340-
mouse: { type: '2f', value: { x: 0.0, y: 0.0 } },
339+
mouse: { type: '2f', value: { x: this.width / 2, y: this.height / 2 } },
341340
date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() * 60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] },
342341
sampleRate: { type: '1f', value: 44100.0 },
343342
iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } },
344343
iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } },
345344
iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } },
346345
iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } }
347346
});
348-
*/
349-
350-
this.uniforms = {
351-
resolution: { type: '2f', value: { x: this.width, y: this.height }},
352-
time: { type: '1f', value: 0 },
353-
mouse: { type: '2f', value: { x: 0.0, y: 0.0 } },
354-
date: { type: '4fv', value: [ d.getFullYear(), d.getMonth(), d.getDate(), d.getHours() * 60 * 60 + d.getMinutes() * 60 + d.getSeconds() ] },
355-
sampleRate: { type: '1f', value: 44100.0 },
356-
iChannel0: { type: 'sampler2D', value: null, textureData: { repeat: true } },
357-
iChannel1: { type: 'sampler2D', value: null, textureData: { repeat: true } },
358-
iChannel2: { type: 'sampler2D', value: null, textureData: { repeat: true } },
359-
iChannel3: { type: 'sampler2D', value: null, textureData: { repeat: true } }
360-
};
361-
362-
console.log(this.uniforms);
363347

364348
this.initUniforms();
365349

@@ -474,7 +458,7 @@ var Shader = new Class({
474458
{
475459
var gl = this.gl;
476460

477-
var uniforms;
461+
var uniforms = this.uniforms;
478462
var uniform;
479463
var length;
480464
var glFunc;

0 commit comments

Comments
 (0)