2929using  JetBrains . Annotations ; 
3030using  Microsoft . Xna . Framework ; 
3131using  Microsoft . Xna . Framework . Graphics ; 
32- using  MonoGameDemoTools ; 
32+ using  ShaderTools ; 
3333
3434namespace  BloomEffectRenderer 
3535{ 
@@ -169,16 +169,14 @@ public void Render(GraphicsDevice gd, SpriteBatch sb, string name, Texture2D irt
169169            // Pass 1: draw the scene into render-target 1, using a 
170170            // shader that extracts only the brightest parts of the image. 
171171            ExtractEffect . Parameters [ "BloomThreshold" ] . SetValue ( ( float )  s . BloomThreshold . Value ) ; 
172-             DrawFullscreenQuad ( gd ,   sb ,   irt ,  BloomRenderTarget1 ,  ExtractEffect ) ; 
172+             sb . DrawFullscreenQuad ( irt ,  BloomRenderTarget1 ,  ExtractEffect ) ; 
173173            debugDelegate ? . Invoke ( name ,  BloomRenderTarget1 ,  RenderPhase . EXTRACT ) ; 
174174
175175            // Pass 2: draw from render-target 1 into render-target 2, 
176176            // using a shader to apply a horizontal Gaussian blur filter. 
177177            SetBlurEffectParameters ( 1.0f  /  BloomRenderTarget1 . Width ,  0 ,  s ) ; 
178178            // The Sampler has to be on anisotropic lookup to smooth the pixels for the blur correctly. 
179-             DrawFullscreenQuad ( gd , 
180-                 sb , 
181-                 BloomRenderTarget1 , 
179+             sb . DrawFullscreenQuad ( BloomRenderTarget1 , 
182180                BloomRenderTarget2 , 
183181                GaussianBlurEffect , 
184182                null , 
@@ -189,9 +187,7 @@ public void Render(GraphicsDevice gd, SpriteBatch sb, string name, Texture2D irt
189187            // using a shader to apply a vertical Gaussian blur filter. 
190188            SetBlurEffectParameters ( 0 ,  1.0f  /  BloomRenderTarget2 . Height ,  s ) ; 
191189            // The Sampler has to be on anisotropic lookup to smooth the pixels for the blur correctly. 
192-             DrawFullscreenQuad ( gd , 
193-                 sb , 
194-                 BloomRenderTarget2 , 
190+             sb . DrawFullscreenQuad ( BloomRenderTarget2 , 
195191                BloomRenderTarget1 , 
196192                GaussianBlurEffect , 
197193                null , 
@@ -208,87 +204,16 @@ public void Render(GraphicsDevice gd, SpriteBatch sb, string name, Texture2D irt
208204            parameters [ "BaseSaturation" ] . SetValue ( ( float )  s . BaseSaturation . Value ) ; 
209205            parameters [ 5 ] . SetValue ( irt ) ; 
210206
211-             DrawFullscreenQuad ( gd ,   sb ,   BloomRenderTarget1 ,  ort ,  CombineEffect ) ; 
207+             sb . DrawFullscreenQuad ( BloomRenderTarget1 ,  ort ,  CombineEffect ) ; 
212208            debugDelegate ? . Invoke ( name ,  ort ,  RenderPhase . COMBINE ) ; 
213209        } 
214210
215211        private  void  Clear ( GraphicsDevice  graphicsDevice ) 
216212        { 
217-             Clear ( graphicsDevice ,   BloomRenderTarget1 ) ; 
218-             Clear ( graphicsDevice ,   BloomRenderTarget2 ) ; 
213+             graphicsDevice . Clear ( BloomRenderTarget1 ) ; 
214+             graphicsDevice . Clear ( BloomRenderTarget2 ) ; 
219215        } 
220- 
221-         /// <summary> 
222-         ///     Clears the specified <see cref="RenderTarget2D" /> with a given <see cref="Color" />. 
223-         /// </summary> 
224-         /// <param name="graphicsDevice">The <see cref="GraphicsDevice" /> to use for drawing.</param> 
225-         /// <param name="renderTarget">The <see cref="RenderTarget2D" /> to clear.</param> 
226-         /// <param name="clearColor"> 
227-         ///     The <see cref="Color" /> to use when clearing the RenderTarget before drawing (default is 
228-         ///     Color.Black). 
229-         /// </param> 
230-         public  static   void  Clear ( GraphicsDevice  graphicsDevice ,  RenderTarget2D  renderTarget ,  Color ?  clearColor  =  null ) 
231-         { 
232-             graphicsDevice . SetRenderTarget ( renderTarget ) ; 
233-             graphicsDevice . Clear ( Color . Black ) ; 
234-         } 
235- 
236-         /// <summary> 
237-         ///     Draws a whole, arbitrarily sized texture into a whole, arbitrarily sized renderTarget, using a custom shader to 
238-         ///     apply postProcessing effects.<br /> 
239-         ///     Clears the target-rendertarget to black before drawing by default. 
240-         /// </summary> 
241-         /// <param name="graphicsDevice">The <see cref="GraphicsDevice" /> to use for drawing.</param> 
242-         /// <param name="spriteBatch">The <see cref="SpriteBatch" /> to use for drawing.</param> 
243-         /// <param name="texture">The <see cref="Texture2D" /> to draw onto the target.</param> 
244-         /// <param name="renderTarget">The <see cref="RenderTarget2D" /> to draw to.</param> 
245-         /// <param name="effect">The <see cref="Effect" /> to use when beginning the SpriteBatch (default is null -> none).</param> 
246-         /// <param name="blendState">The <see cref="BlendState" /> to use for drawing (default is BlendState.Opaque).</param> 
247-         /// <param name="samplerState">The <see cref="SamplerState" /> to use for drawing (default is SamplerState.PointClamp).</param> 
248-         /// <param name="clearColor"> 
249-         ///     The <see cref="Color" /> to use when clearing the RenderTarget before drawing (default is 
250-         ///     Color.Black). 
251-         /// </param> 
252-         public  static   void  DrawFullscreenQuad ( GraphicsDevice  graphicsDevice ,  SpriteBatch  spriteBatch ,  Texture2D  texture , 
253-             RenderTarget2D  renderTarget ,  Effect  effect  =  null ,  BlendState  blendState  =  null , 
254-             SamplerState  samplerState  =  null ,  Color ?  clearColor  =  null ) 
255-         { 
256-             graphicsDevice . SetRenderTarget ( renderTarget ) ; 
257-             graphicsDevice . Clear ( clearColor  ??  Color . Black ) ; 
258- 
259-             if  ( texture  ==  null ) 
260-                 return ; 
261- 
262-             spriteBatch . Begin ( SpriteSortMode . Immediate , 
263-                 blendState  ??  BlendState . Opaque , 
264-                 samplerState  ??  SamplerState . PointClamp , 
265-                 DepthStencilState . None , 
266-                 RasterizerState . CullNone , 
267-                 effect ) ; 
268- 
269-             int  w ,  h ; 
270-             if  ( renderTarget  ==  null ) 
271-             { 
272-                 w  =  graphicsDevice . PresentationParameters . BackBufferWidth ; 
273-                 h  =  graphicsDevice . PresentationParameters . BackBufferHeight ; 
274-             } 
275-             else 
276-             { 
277-                 w  =  renderTarget . Width ; 
278-                 h  =  renderTarget . Height ; 
279-             } 
280- 
281-             spriteBatch . Draw ( texture , 
282-                 new  Rectangle ( 0 ,  0 ,  w ,  h ) , 
283-                 new  Rectangle ( 0 ,  0 ,  texture . Width ,  texture . Height ) , 
284-                 Color . White , 
285-                 0f , 
286-                 Vector2 . Zero , 
287-                 SpriteEffects . None , 
288-                 1f ) ; 
289-             spriteBatch . End ( ) ; 
290-         } 
291- 
216+         
292217        /// <summary> 
293218        ///     Computes sample weightings and texture coordinate offsets for one pass of a separable Gaussian blur filter. 
294219        /// </summary> 
0 commit comments