Skip to content

Commit efb5eb0

Browse files
committed
Starting refactor
1 parent 0598541 commit efb5eb0

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ var ForwardDiffuseLightPipeline = new Class({
3939
},
4040

4141
/**
42-
* This function binds it's base class resources and this lights 2D resources.
42+
* This function binds its base class resources and this lights 2D resources.
4343
*
4444
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind
4545
* @override
4646
* @since 3.0.0
47+
*
48+
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
4749
*
4850
* @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description]
4951
*/
50-
onBind: function ()
52+
onBind: function (gameObject)
5153
{
5254
TextureTintPipeline.prototype.onBind.call(this);
5355

@@ -59,6 +61,11 @@ var ForwardDiffuseLightPipeline = new Class({
5961
renderer.setInt1(program, 'uNormSampler', 1);
6062
renderer.setFloat2(program, 'uResolution', this.width, this.height);
6163

64+
if (gameObject)
65+
{
66+
this.setNormalMap(gameObject);
67+
}
68+
6269
return this;
6370
},
6471

@@ -226,6 +233,26 @@ var ForwardDiffuseLightPipeline = new Class({
226233
}
227234
},
228235

236+
setNormalMap: function (gameObject)
237+
{
238+
if (!this.active || !gameObject || !gameObject.texture)
239+
{
240+
return;
241+
}
242+
243+
var normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex];
244+
245+
if (normalTexture)
246+
{
247+
// Should already be set!
248+
// this.renderer.setPipeline(this);
249+
250+
this.setTexture2D(normalTexture.glTexture, 1);
251+
252+
this.renderer.setPipeline(gameObject.defaultPipeline);
253+
}
254+
},
255+
229256
/**
230257
* [description]
231258
*
@@ -236,7 +263,6 @@ var ForwardDiffuseLightPipeline = new Class({
236263
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
237264
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
238265
*
239-
*/
240266
batchSprite: function (sprite, camera, parentTransformMatrix)
241267
{
242268
if (!this.active)
@@ -258,6 +284,7 @@ var ForwardDiffuseLightPipeline = new Class({
258284
this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera, parentTransformMatrix);
259285
}
260286
},
287+
*/
261288

262289
/**
263290
* [description]

0 commit comments

Comments
 (0)