@@ -26,8 +26,7 @@ var WebGLPipeline = require('../WebGLPipeline');
2626 *
2727 * The default shader uniforms for this pipeline are:
2828 *
29- * `uProjectionMatrix` (mat4)
30- * `uMainSampler` (sampler2D)
29+ * `uMainSampler` (sampler2D)
3130 *
3231 * @class PostFXPipeline
3332 * @extends Phaser.Renderer.WebGL.WebGLPipeline
@@ -170,32 +169,107 @@ var PostFXPipeline = new Class({
170169 this . bindAndDraw ( renderTarget ) ;
171170 } ,
172171
172+ /**
173+ * Copy the `source` Render Target to the `target` Render Target.
174+ *
175+ * You can optionally set the brightness factor of the copy.
176+ *
177+ * The difference between this method and `drawFrame` is that this method
178+ * uses a faster copy shader, where only the brightness can be modified.
179+ * If you need color level manipulation, see `drawFrame` instead.
180+ *
181+ * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#copyFrame
182+ * @since 3.50.0
183+ *
184+ * @param {Phaser.Renderer.WebGL.RenderTarget } source - The source Render Target.
185+ * @param {Phaser.Renderer.WebGL.RenderTarget } [target] - The target Render Target.
186+ * @param {number } [brightness=1] - The brightness value applied to the frame copy.
187+ * @param {boolean } [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
188+ */
173189 copyFrame : function ( source , target , brightness , clearAlpha )
174190 {
175191 this . manager . copyFrame ( source , target , brightness , clearAlpha ) ;
176192 } ,
177193
194+ /**
195+ * Copy the `source` Render Target to the `target` Render Target, using the
196+ * given Color Matrix.
197+ *
198+ * The difference between this method and `copyFrame` is that this method
199+ * uses a color matrix shader, where you have full control over the luminance
200+ * values used during the copy. If you don't need this, you can use the faster
201+ * `copyFrame` method instead.
202+ *
203+ * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#drawFrame
204+ * @since 3.50.0
205+ *
206+ * @param {Phaser.Renderer.WebGL.RenderTarget } source - The source Render Target.
207+ * @param {Phaser.Renderer.WebGL.RenderTarget } [target] - The target Render Target.
208+ * @param {boolean } [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
209+ */
178210 drawFrame : function ( source , target , clearAlpha )
179211 {
180212 this . manager . drawFrame ( source , target , clearAlpha , this . colorMatrix ) ;
181213 } ,
182214
215+ /**
216+ * Draws the `source1` and `source2` Render Targets to the `target` Render Target
217+ * using a linear blend effect, which is controlled by the `strength` parameter.
218+ *
219+ * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#blendFrames
220+ * @since 3.50.0
221+ *
222+ * @param {Phaser.Renderer.WebGL.RenderTarget } source1 - The first source Render Target.
223+ * @param {Phaser.Renderer.WebGL.RenderTarget } source2 - The second source Render Target.
224+ * @param {Phaser.Renderer.WebGL.RenderTarget } [target] - The target Render Target.
225+ * @param {number } [strength=1] - The strength of the blend.
226+ * @param {boolean } [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
227+ */
183228 blendFrames : function ( source1 , source2 , target , strength , clearAlpha )
184229 {
185230 this . manager . blendFrames ( source1 , source2 , target , strength , clearAlpha ) ;
186231 } ,
187232
233+ /**
234+ * Draws the `source1` and `source2` Render Targets to the `target` Render Target
235+ * using an additive blend effect, which is controlled by the `strength` parameter.
236+ *
237+ * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#blendFramesAdditive
238+ * @since 3.50.0
239+ *
240+ * @param {Phaser.Renderer.WebGL.RenderTarget } source1 - The first source Render Target.
241+ * @param {Phaser.Renderer.WebGL.RenderTarget } source2 - The second source Render Target.
242+ * @param {Phaser.Renderer.WebGL.RenderTarget } [target] - The target Render Target.
243+ * @param {number } [strength=1] - The strength of the blend.
244+ * @param {boolean } [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
245+ */
188246 blendFramesAdditive : function ( source1 , source2 , target , strength , clearAlpha )
189247 {
190248 this . manager . blendFramesAdditive ( source1 , source2 , target , strength , clearAlpha ) ;
191249 } ,
192250
251+ /**
252+ * Binds this pipeline, pops the framebuffer then draws the `source`
253+ * Render Target to the framebuffer currently set in the renderer (after the fbo stack pop).
254+ *
255+ * You can optionally set the shader to be used for the draw here, if this is a multi-shader
256+ * pipeline.
257+ *
258+ * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#bindAndDraw
259+ * @since 3.50.0
260+ *
261+ * @param {Phaser.Renderer.WebGL.RenderTarget } source - The Render Target to draw from.
262+ * @param {Phaser.Renderer.WebGL.WebGLShader } [currentShader] - The shader to use during the draw.
263+ */
193264 bindAndDraw : function ( source , currentShader )
194265 {
195266 this . bind ( currentShader ) ;
196267
197- // Pop out this pipelines renderTarget
198- this . renderer . popFramebuffer ( ) ;
268+ if ( this . currentTarget )
269+ {
270+ // Pop out this pipelines renderTarget
271+ this . renderer . popFramebuffer ( ) ;
272+ }
199273
200274 var gl = this . gl ;
201275
@@ -206,8 +280,6 @@ var PostFXPipeline = new Class({
206280 gl . drawArrays ( gl . TRIANGLES , 0 , 6 ) ;
207281
208282 gl . bindTexture ( gl . TEXTURE_2D , null ) ;
209-
210- // this.renderer.resetTextures();
211283 }
212284
213285} ) ;
0 commit comments