Skip to content

Commit a694590

Browse files
committed
Fixed for 3.50 Beta 12
1 parent 1868a74 commit a694590

1 file changed

Lines changed: 18 additions & 52 deletions

File tree

src/renderer/webgl/pipelines/LightPipeline.js

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var Class = require('../../../utils/Class');
99
var GetFastValue = require('../../../utils/object/GetFastValue');
1010
var LightShaderSourceFS = require('../shaders/Light-frag.js');
1111
var SinglePipeline = require('./SinglePipeline');
12-
var TransformMatrix = require('../../../gameobjects/components/TransformMatrix');
1312
var WebGLPipeline = require('../WebGLPipeline');
1413

1514
var LIGHT_COUNT = 10;
@@ -76,33 +75,6 @@ var LightPipeline = new Class({
7675

7776
SinglePipeline.call(this, config);
7877

79-
/**
80-
* A temporary Transform Matrix, re-used internally during batching.
81-
*
82-
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tempMatrix1
83-
* @type {Phaser.GameObjects.Components.TransformMatrix}
84-
* @since 3.11.0
85-
*/
86-
this.tempMatrix1 = new TransformMatrix();
87-
88-
/**
89-
* A temporary Transform Matrix, re-used internally during batching.
90-
*
91-
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tempMatrix2
92-
* @type {Phaser.GameObjects.Components.TransformMatrix}
93-
* @since 3.11.0
94-
*/
95-
this.tempMatrix2 = new TransformMatrix();
96-
97-
/**
98-
* A temporary Transform Matrix, re-used internally during batching.
99-
*
100-
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tempMatrix3
101-
* @type {Phaser.GameObjects.Components.TransformMatrix}
102-
* @since 3.11.0
103-
*/
104-
this.tempMatrix3 = new TransformMatrix();
105-
10678
/**
10779
* Inverse rotation matrix for normal map rotations.
10880
*
@@ -189,56 +161,50 @@ var LightPipeline = new Class({
189161
*
190162
* @param {Phaser.Scene} scene - The Scene being rendered.
191163
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera being rendered with.
192-
*
193-
* @return {this} This WebGLPipeline instance.
194164
*/
195165
onRender: function (scene, camera)
196166
{
197-
this.active = false;
198-
199167
var lightManager = scene.sys.lights;
200168

201169
if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active)
202170
{
203-
// Passthru
204-
return this;
171+
return;
205172
}
206173

207174
var lights = lightManager.cull(camera);
208175
var lightCount = Math.min(lights.length, LIGHT_COUNT);
209176

210177
if (lightCount === 0)
211178
{
212-
return this;
179+
return;
213180
}
214181

215-
this.active = true;
216-
217182
var renderer = this.renderer;
218-
var program = this.program;
219183
var cameraMatrix = camera.matrix;
220-
var point = {x: 0, y: 0};
184+
var point = { x: 0, y: 0 };
221185
var height = renderer.height;
222186
var i;
223187

224188
if (lightCount !== this.lightCount)
225189
{
190+
// Reset lights
226191
for (i = 0; i < LIGHT_COUNT; i++)
227192
{
228-
// Reset lights
229-
renderer.setFloat1(program, 'uLights[' + i + '].radius', 0);
193+
this.set1f('uLights[' + i + '].radius', 0);
194+
195+
// renderer.setFloat1(program, 'uLights[' + i + '].radius', 0);
230196
}
231197

232198
this.lightCount = lightCount;
233199
}
234200

201+
235202
if (camera.dirty)
236203
{
237-
renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom);
204+
this.set4f('uCamera', camera.x, camera.y, camera.rotation, camera.zoom);
238205
}
239206

240-
// TODO - Only if dirty! and cache the location
241-
renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b);
207+
this.set3f('uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b);
242208

243209
for (i = 0; i < lightCount; i++)
244210
{
@@ -247,21 +213,21 @@ var LightPipeline = new Class({
247213

248214
cameraMatrix.transformPoint(light.x, light.y, point);
249215

250-
// TODO - Cache the uniform locations!!!
251-
renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom));
216+
this.set2f(lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom));
217+
218+
// renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom));
252219

253220
if (light.dirty)
254221
{
255-
renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b);
256-
renderer.setFloat1(program, lightName + 'intensity', light.intensity);
257-
renderer.setFloat1(program, lightName + 'radius', light.radius);
222+
this.set3f(lightName + 'color', light.r, light.g, light.b);
223+
this.set1f(lightName + 'intensity', light.intensity);
224+
this.set1f(lightName + 'radius', light.radius);
225+
258226
light.dirty = false;
259227
}
260228
}
261229

262230
this.currentNormalMapRotation = null;
263-
264-
return this;
265231
},
266232

267233
/**
@@ -300,7 +266,7 @@ var LightPipeline = new Class({
300266
inverseRotationMatrix[1] = inverseRotationMatrix[3] = 0;
301267
}
302268

303-
this.renderer.setMatrix3(this.program, 'uInverseRotationMatrix', false, inverseRotationMatrix);
269+
this.setMatrix3fv('uInverseRotationMatrix', false, inverseRotationMatrix);
304270

305271
this.currentNormalMapRotation = rotation;
306272
}

0 commit comments

Comments
 (0)