@@ -45,6 +45,7 @@ var PostFXPipeline = new Class({
4545
4646 function PostFXPipeline ( config )
4747 {
48+ config . renderTarget = GetFastValue ( config , 'renderTarget' , 1 ) ;
4849 config . fragShader = GetFastValue ( config , 'fragShader' , ShaderSourceFS ) ;
4950 config . vertShader = GetFastValue ( config , 'vertShader' , ShaderSourceVS ) ;
5051 config . uniforms = GetFastValue ( config , 'uniforms' , [
@@ -74,20 +75,99 @@ var PostFXPipeline = new Class({
7475
7576 WebGLPipeline . call ( this , config ) ;
7677
78+ /**
79+ * A Color Matrix instance belonging to this pipeline.
80+ *
81+ * Used during calls to the `drawFrame` method.
82+ *
83+ * @name Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#colorMatrix
84+ * @type {Phaser.Display.ColorMatrix }
85+ * @since 3.50.0
86+ */
7787 this . colorMatrix = new ColorMatrix ( ) ;
88+
89+ /**
90+ * A reference to the Full Frame 1 Render Target that belongs to the
91+ * Utility Pipeline. This property is set during the `boot` method.
92+ *
93+ * This Render Target is the full size of the renderer.
94+ *
95+ * You can use this directly in Post FX Pipelines for multi-target effects.
96+ * However, be aware that these targets are shared between all post fx pipelines.
97+ *
98+ * @name Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#fullFrame1
99+ * @type {Phaser.Renderer.WebGL.RenderTarget }
100+ * @default null
101+ * @since 3.50.0
102+ */
103+ this . fullFrame1 ;
104+
105+ /**
106+ * A reference to the Full Frame 2 Render Target that belongs to the
107+ * Utility Pipeline. This property is set during the `boot` method.
108+ *
109+ * This Render Target is the full size of the renderer.
110+ *
111+ * You can use this directly in Post FX Pipelines for multi-target effects.
112+ * However, be aware that these targets are shared between all post fx pipelines.
113+ *
114+ * @name Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#fullFrame2
115+ * @type {Phaser.Renderer.WebGL.RenderTarget }
116+ * @default null
117+ * @since 3.50.0
118+ */
119+ this . fullFrame2 ;
120+
121+ /**
122+ * A reference to the Half Frame 1 Render Target that belongs to the
123+ * Utility Pipeline. This property is set during the `boot` method.
124+ *
125+ * This Render Target is half the size of the renderer.
126+ *
127+ * You can use this directly in Post FX Pipelines for multi-target effects.
128+ * However, be aware that these targets are shared between all post fx pipelines.
129+ *
130+ * @name Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#halfFrame1
131+ * @type {Phaser.Renderer.WebGL.RenderTarget }
132+ * @default null
133+ * @since 3.50.0
134+ */
135+ this . halfFrame1 ;
136+
137+ /**
138+ * A reference to the Half Frame 2 Render Target that belongs to the
139+ * Utility Pipeline. This property is set during the `boot` method.
140+ *
141+ * This Render Target is half the size of the renderer.
142+ *
143+ * You can use this directly in Post FX Pipelines for multi-target effects.
144+ * However, be aware that these targets are shared between all post fx pipelines.
145+ *
146+ * @name Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#halfFrame2
147+ * @type {Phaser.Renderer.WebGL.RenderTarget }
148+ * @default null
149+ * @since 3.50.0
150+ */
151+ this . halfFrame2 ;
78152 } ,
79153
80154 boot : function ( )
81155 {
82156 WebGLPipeline . prototype . boot . call ( this ) ;
83157
158+ var utility = this . manager . UTILITY_PIPELINE ;
159+
160+ this . fullFrame1 = utility . fullFrame1 ;
161+ this . fullFrame2 = utility . fullFrame2 ;
162+ this . halfFrame1 = utility . halfFrame1 ;
163+ this . halfFrame2 = utility . halfFrame2 ;
164+
84165 this . set1i ( 'uMainSampler' , 0 ) ;
85166 } ,
86167
87168 onDraw : function ( renderTarget )
88169 {
89- // Draws from the RenderTarget (which usually belongs to this pipeline) to the target (usually the game canvas)
90- this . draw ( renderTarget ) ;
170+ this . bindAndDraw ( renderTarget ) ;
91171 } ,
92172
93173 copyFrame : function ( source , target , brightness , clearAlpha )
@@ -110,21 +190,24 @@ var PostFXPipeline = new Class({
110190 this . manager . blendFramesAdditive ( source1 , source2 , target , strength , clearAlpha ) ;
111191 } ,
112192
113- bindAndDraw : function ( renderTarget , currentShader )
193+ bindAndDraw : function ( source , currentShader )
114194 {
115195 this . bind ( currentShader ) ;
116196
117- renderTarget . unbind ( ) ;
197+ // Pop out this pipelines renderTarget
198+ this . renderer . popFramebuffer ( ) ;
118199
119200 var gl = this . gl ;
120201
121202 gl . activeTexture ( gl . TEXTURE0 ) ;
122- gl . bindTexture ( gl . TEXTURE_2D , renderTarget . texture ) ;
203+ gl . bindTexture ( gl . TEXTURE_2D , source . texture ) ;
123204
124205 gl . bufferData ( gl . ARRAY_BUFFER , this . vertexData , gl . STATIC_DRAW ) ;
125206 gl . drawArrays ( gl . TRIANGLES , 0 , 6 ) ;
126207
127208 gl . bindTexture ( gl . TEXTURE_2D , null ) ;
209+
210+ // this.renderer.resetTextures();
128211 }
129212
130213} ) ;
0 commit comments