@@ -10,6 +10,35 @@ var PointLightShaderSourceFS = require('../shaders/PointLight-frag.js');
1010var PointLightShaderSourceVS = require ( '../shaders/PointLight-vert.js' ) ;
1111var WebGLPipeline = require ( '../WebGLPipeline' ) ;
1212
13+ /**
14+ * @classdesc
15+ * The Point Light Pipeline handles rendering the Point Light Game Objects in WebGL.
16+ *
17+ * The fragment shader it uses can be found in `shaders/src/BitmapMask.frag`.
18+ * The vertex shader it uses can be found in `shaders/src/BitmapMask.vert`.
19+ *
20+ * The default shader attributes for this pipeline are:
21+ *
22+ * `inPosition` (vec2)
23+ * `inLightPosition` (vec2)
24+ * `inLightRadius` (float)
25+ * `inLightAttenuation` (float)
26+ * `inLightColor` (vec4)
27+ *
28+ * The default shader uniforms for this pipeline are:
29+ *
30+ * `uProjectionMatrix` (mat4)
31+ * `uResolution` (vec2)
32+ * `uCameraZoom` (sampler2D)
33+ *
34+ * @class PointLightPipeline
35+ * @extends Phaser.Renderer.WebGL.WebGLPipeline
36+ * @memberof Phaser.Renderer.WebGL.Pipelines
37+ * @constructor
38+ * @since 3.50.0
39+ *
40+ * @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig } config - The configuration options for this pipeline.
41+ */
1342var PointLightPipeline = new Class ( {
1443
1544 Extends : WebGLPipeline ,
@@ -32,9 +61,6 @@ var PointLightPipeline = new Class({
3261 {
3362 name : 'inLightRadius'
3463 } ,
35- {
36- name : 'inLightFalloff'
37- } ,
3864 {
3965 name : 'inLightAttenuation'
4066 } ,
@@ -53,12 +79,30 @@ var PointLightPipeline = new Class({
5379 this . set1f ( 'uCameraZoom' , camera . zoom ) ;
5480 } ,
5581
82+ /**
83+ * Adds a Point Light Game Object to the batch, flushing if required.
84+ *
85+ * @method Phaser.Renderer.WebGL.Pipelines.PointLightPipeline#batchPointLight
86+ * @since 3.50.0
87+ *
88+ * @param {Phaser.GameObjects.PointLight } light - The Point Light Game Object.
89+ * @param {Phaser.Cameras.Scene2D.Camera } camera - The camera rendering the Point Light.
90+ * @param {number } x0 - The top-left x position.
91+ * @param {number } y0 - The top-left y position.
92+ * @param {number } x1 - The bottom-left x position.
93+ * @param {number } y1 - The bottom-left y position.
94+ * @param {number } x2 - The bottom-right x position.
95+ * @param {number } y2 - The bottom-right y position.
96+ * @param {number } x3 - The top-right x position.
97+ * @param {number } y3 - The top-right y position.
98+ * @param {number } lightX - The horizontal center of the light.
99+ * @param {number } lightY - The vertical center of the light.
100+ */
56101 batchPointLight : function ( light , camera , x0 , y0 , x1 , y1 , x2 , y2 , x3 , y3 , lightX , lightY )
57102 {
58103 var color = light . color ;
59104 var intensity = light . intensity ;
60105 var radius = light . radius ;
61- var falloff = light . falloff ;
62106 var attenuation = light . attenuation ;
63107
64108 var r = color . r * intensity ;
@@ -71,15 +115,35 @@ var PointLightPipeline = new Class({
71115 this . flush ( ) ;
72116 }
73117
74- this . batchLightVert ( x0 , y0 , lightX , lightY , radius , falloff , attenuation , r , g , b , a ) ;
75- this . batchLightVert ( x1 , y1 , lightX , lightY , radius , falloff , attenuation , r , g , b , a ) ;
76- this . batchLightVert ( x2 , y2 , lightX , lightY , radius , falloff , attenuation , r , g , b , a ) ;
77- this . batchLightVert ( x0 , y0 , lightX , lightY , radius , falloff , attenuation , r , g , b , a ) ;
78- this . batchLightVert ( x2 , y2 , lightX , lightY , radius , falloff , attenuation , r , g , b , a ) ;
79- this . batchLightVert ( x3 , y3 , lightX , lightY , radius , falloff , attenuation , r , g , b , a ) ;
118+ this . batchLightVert ( x0 , y0 , lightX , lightY , radius , attenuation , r , g , b , a ) ;
119+ this . batchLightVert ( x1 , y1 , lightX , lightY , radius , attenuation , r , g , b , a ) ;
120+ this . batchLightVert ( x2 , y2 , lightX , lightY , radius , attenuation , r , g , b , a ) ;
121+ this . batchLightVert ( x0 , y0 , lightX , lightY , radius , attenuation , r , g , b , a ) ;
122+ this . batchLightVert ( x2 , y2 , lightX , lightY , radius , attenuation , r , g , b , a ) ;
123+ this . batchLightVert ( x3 , y3 , lightX , lightY , radius , attenuation , r , g , b , a ) ;
80124 } ,
81125
82- batchLightVert : function ( x , y , lightX , lightY , radius , falloff , attenuation , r , g , b , a )
126+ /**
127+ * Adds a single Point Light vertex to the current vertex buffer and increments the
128+ * `vertexCount` property by 1.
129+ *
130+ * This method is called directly by `batchPointLight`.
131+ *
132+ * @method Phaser.Renderer.WebGL.Pipelines.PointLightPipeline#batchLightVert
133+ * @since 3.50.0
134+ *
135+ * @param {number } x - The vertex x position.
136+ * @param {number } y - The vertex y position.
137+ * @param {number } lightX - The horizontal center of the light.
138+ * @param {number } lightY - The vertical center of the light.
139+ * @param {number } radius - The radius of the light.
140+ * @param {number } attenuation - The attenuation of the light.
141+ * @param {number } r - The red color channel of the light.
142+ * @param {number } g - The green color channel of the light.
143+ * @param {number } b - The blue color channel of the light.
144+ * @param {number } a - The alpha color channel of the light.
145+ */
146+ batchLightVert : function ( x , y , lightX , lightY , radius , attenuation , r , g , b , a )
83147 {
84148 var vertexViewF32 = this . vertexViewF32 ;
85149
@@ -90,7 +154,6 @@ var PointLightPipeline = new Class({
90154 vertexViewF32 [ ++ vertexOffset ] = lightX ;
91155 vertexViewF32 [ ++ vertexOffset ] = lightY ;
92156 vertexViewF32 [ ++ vertexOffset ] = radius ;
93- vertexViewF32 [ ++ vertexOffset ] = falloff ;
94157 vertexViewF32 [ ++ vertexOffset ] = attenuation ;
95158 vertexViewF32 [ ++ vertexOffset ] = r ;
96159 vertexViewF32 [ ++ vertexOffset ] = g ;
0 commit comments