Skip to content

Commit 6419893

Browse files
committed
New project setup (nuget packages)
1 parent b026da3 commit 6419893

File tree

3 files changed

+13
-88
lines changed

3 files changed

+13
-88
lines changed

BloomEffectRenderer/BloomEffectRenderer.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@
6969
<HintPath>..\packages\MonoGame.Framework.Portable.3.6.0.1625\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
7070
<Private>True</Private>
7171
</Reference>
72-
<Reference Include="MonoGameDemoTools, Version=1.1.0.5, Culture=neutral, processorArchitecture=MSIL">
73-
<HintPath>..\packages\MonoGameDemoTools.1.1.0.5\lib\portable45-net45+win8+wpa81\MonoGameDemoTools.dll</HintPath>
74-
<Private>True</Private>
75-
</Reference>
7672
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
7773
<HintPath>..\packages\NUnit.3.6.1\lib\portable-net45+win8+wp8+wpa81\nunit.framework.dll</HintPath>
7874
<Private>True</Private>
7975
</Reference>
76+
<Reference Include="ShaderTools, Version=1.0.1.1, Culture=neutral, processorArchitecture=MSIL">
77+
<HintPath>..\packages\ShaderTools.1.0.1.1\lib\portable45-net45+win8+wpa81\ShaderTools.dll</HintPath>
78+
<Private>True</Private>
79+
</Reference>
8080
</ItemGroup>
8181
<ItemGroup>
8282
<Content Include="Effects\Resources\BloomCombine.fx" />

BloomEffectRenderer/Renderer.cs

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
using JetBrains.Annotations;
3030
using Microsoft.Xna.Framework;
3131
using Microsoft.Xna.Framework.Graphics;
32-
using MonoGameDemoTools;
32+
using ShaderTools;
3333

3434
namespace 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>

BloomEffectRenderer/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<package id="InputStateManager" version="1.1.0.2" targetFramework="portable45-net45+win8+wpa81" />
55
<package id="JetBrains.Annotations" version="11.1.0" targetFramework="portable45-net45+win8+wpa81" />
66
<package id="MonoGame.Framework.Portable" version="3.6.0.1625" targetFramework="portable45-net45+win8+wpa81" />
7-
<package id="MonoGameDemoTools" version="1.1.0.5" targetFramework="portable45-net45+win8+wpa81" />
87
<package id="NUnit" version="3.6.1" targetFramework="portable45-net45+win8+wpa81" />
8+
<package id="ShaderTools" version="1.0.1.1" targetFramework="portable45-net45+win8+wpa81" />
99
<package id="System.Runtime" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" />
1010
</packages>

0 commit comments

Comments
 (0)