Skip to content

Commit a7209c7

Browse files
Merge branch '3.8.4' of https://github.com/MonoGame/MonoGame.Samples into 3.8.5
2 parents 0b838f7 + 598bed0 commit a7209c7

77 files changed

Lines changed: 441 additions & 375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NeonShooter/NeonShooter.Core/Content/Shaders/BloomCombine.fx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
///-------------------------------------------------------------------------------------------------
2+
/// <remarks>
3+
/// Charles Humphrey, 12/07/2025.
4+
/// Fixes for DX implementation.
5+
/// </remarks>
6+
///-------------------------------------------------------------------------------------------------
7+
#include "PPVertexShader.fxh"
8+
19
// Pixel shader combines the bloom image with the original
210
// scene, using tweakable intensity levels and saturation.
311
// This is the final step in applying a bloom postprocess.
@@ -22,12 +30,17 @@ float4 AdjustSaturation(float4 color, float saturation)
2230
return lerp(grey, color, saturation);
2331
}
2432

33+
///-------------------------------------------------------------------------------------------------
34+
/// <summary> Function now uses correct vertex input structure for both OGL and DX </summary>
35+
///
36+
/// <remarks> Charles Humphrey, 12/07/2025. </remarks>
37+
///-------------------------------------------------------------------------------------------------
2538

26-
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
39+
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
2740
{
2841
// Look up the bloom and original base image colors.
29-
float4 bloom = tex2D(BloomSampler, texCoord);
30-
float4 base = tex2D(BaseSampler, texCoord);
42+
float4 bloom = tex2D(BloomSampler, input.TexCoord);
43+
float4 base = tex2D(BaseSampler, input.TexCoord);
3144

3245
// Adjust color saturation and intensity.
3346
bloom = AdjustSaturation(bloom, BloomSaturation) * BloomIntensity;
@@ -46,10 +59,6 @@ technique BloomCombine
4659
{
4760
pass Pass1
4861
{
49-
#if SM4
50-
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
51-
#else
52-
PixelShader = compile ps_2_0 PixelShaderFunction();
53-
#endif
62+
PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
5463
}
5564
}
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
// Pixel shader extracts the brighter areas of an image.
2-
// This is the first step in applying a bloom postprocess.
1+
///-------------------------------------------------------------------------------------------------
2+
/// <remarks>
3+
/// Charles Humphrey, 12/07/2025.
4+
/// Fixes for DX implementation.
5+
/// </remarks>
6+
///-------------------------------------------------------------------------------------------------
7+
#include "PPVertexShader.fxh"
38

49
sampler TextureSampler : register(s0);
510

611
float BloomThreshold;
712

8-
9-
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
13+
///-------------------------------------------------------------------------------------------------
14+
/// <summary> Function now uses correct vertex input structure for both OGL and DX </summary>
15+
///
16+
/// <remarks> Charles Humphrey, 12/07/2025. </remarks>
17+
///-------------------------------------------------------------------------------------------------
18+
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
1019
{
11-
// Look up the original image color.
12-
float4 c = tex2D(TextureSampler, texCoord);
13-
14-
// Adjust it to keep only values brighter than the specified threshold.
20+
float4 c = tex2D(TextureSampler, input.TexCoord);
1521
return saturate((c - BloomThreshold) / (1 - BloomThreshold));
1622
}
1723

18-
1924
technique BloomExtract
2025
{
2126
pass Pass1
2227
{
23-
#if SM4
24-
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
25-
#else
26-
PixelShader = compile ps_2_0 PixelShaderFunction();
27-
#endif
28+
PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
2829
}
2930
}

NeonShooter/NeonShooter.Core/Content/Shaders/GaussianBlur.fx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
///-------------------------------------------------------------------------------------------------
2+
/// <remarks>
3+
/// Charles Humphrey, 12/07/2025.
4+
/// Fixes for DX implementation.
5+
/// </remarks>
6+
///-------------------------------------------------------------------------------------------------
7+
#include "PPVertexShader.fxh"
8+
19
// Pixel shader applies a one dimensional gaussian blur filter.
210
// This is used twice by the bloom postprocess, first to
311
// blur horizontally, and then again to blur vertically.
@@ -10,14 +18,24 @@ float2 SampleOffsets[SAMPLE_COUNT];
1018
float SampleWeights[SAMPLE_COUNT];
1119

1220

13-
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
21+
///-------------------------------------------------------------------------------------------------
22+
/// <summary> Function now uses correct vertex input structure for both OGL and DX </summary>
23+
///
24+
/// <remarks> Charles Humphrey, 12/07/2025. </remarks>
25+
///-------------------------------------------------------------------------------------------------
26+
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
1427
{
1528
float4 c = 0;
1629

1730
// Combine a number of weighted image filter taps.
1831
for (int i = 0; i < SAMPLE_COUNT; i++)
1932
{
20-
c += tex2D(TextureSampler, texCoord + SampleOffsets[i]) * SampleWeights[i];
33+
// Charles Humphrey, altered this to give a better effect with the blur. Was too heavy before.
34+
// This should really be done where the offsets and weights are calculated.
35+
c += tex2D(TextureSampler, input.TexCoord + SampleOffsets[i] * .0125) * SampleWeights[i] * 5;
36+
37+
// Was:
38+
//c += tex2D(TextureSampler, input.TexCoord + SampleOffsets[i]) * SampleWeights[i];
2139
}
2240

2341
return c;
@@ -28,10 +46,6 @@ technique GaussianBlur
2846
{
2947
pass Pass1
3048
{
31-
#if SM4
32-
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
33-
#else
34-
PixelShader = compile ps_2_0 PixelShaderFunction();
35-
#endif
49+
PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
3650
}
3751
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
///-------------------------------------------------------------------------------------------------
2+
/// <summary>
3+
/// This header file is for used to ensure vertex patching in the DX build.
4+
/// </summary>
5+
///
6+
/// <remarks> Charles Humphrey, 12/07/2025. </remarks>
7+
///-------------------------------------------------------------------------------------------------
8+
9+
10+
#if OPENGL
11+
#define SV_POSITION POSITION
12+
#define VS_SHADERMODEL vs_3_0
13+
#define PS_SHADERMODEL ps_3_0
14+
#else
15+
#define VS_SHADERMODEL vs_4_0_level_9_1
16+
#define PS_SHADERMODEL ps_4_0_level_9_1
17+
#endif
18+
19+
struct VertexShaderOutput
20+
{
21+
float4 Position : SV_POSITION;
22+
float4 Color : COLOR0;
23+
float2 TexCoord : TEXCOORD0;
24+
};

Tutorials/learn-monogame-2d/src/11-Input-Management/DungeonSlime/Game1.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ protected override void LoadContent()
5050

5151
protected override void Update(GameTime gameTime)
5252
{
53-
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
54-
Exit();
55-
5653
// Update the slime animated sprite.
5754
_slime.Update(gameTime);
5855

Tutorials/learn-monogame-2d/src/11-Input-Management/MonoGameLibrary/Core.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public Core(string title, int width, int height, bool fullScreen)
8787

8888
// Mouse is visible by default
8989
IsMouseVisible = true;
90+
91+
// Exit on escape is true by default
92+
ExitOnEscape = true;
9093
}
9194

9295
protected override void Initialize()

Tutorials/learn-monogame-2d/src/12-Collision-Detection/DungeonSlime/Game1.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ protected override void LoadContent()
6161

6262
protected override void Update(GameTime gameTime)
6363
{
64-
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
65-
Exit();
66-
6764
// Update the slime animated sprite.
6865
_slime.Update(gameTime);
6966

@@ -154,6 +151,7 @@ protected override void Update(GameTime gameTime)
154151
// normal.
155152
if (normal != Vector2.Zero)
156153
{
154+
normal.Normalize();
157155
_batVelocity = Vector2.Reflect(_batVelocity, normal);
158156
}
159157

Tutorials/learn-monogame-2d/src/12-Collision-Detection/MonoGameLibrary/Core.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public Core(string title, int width, int height, bool fullScreen)
8787

8888
// Mouse is visible by default
8989
IsMouseVisible = true;
90+
91+
// Exit on escape is true by default
92+
ExitOnEscape = true;
9093
}
9194

9295
protected override void Initialize()

Tutorials/learn-monogame-2d/src/13-Tilemap/DungeonSlime/Game1.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ protected override void LoadContent()
8484

8585
protected override void Update(GameTime gameTime)
8686
{
87-
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
88-
Exit();
89-
9087
// Update the slime animated sprite.
9188
_slime.Update(gameTime);
9289

@@ -169,6 +166,7 @@ protected override void Update(GameTime gameTime)
169166
// normal.
170167
if (normal != Vector2.Zero)
171168
{
169+
normal.Normalize();
172170
_batVelocity = Vector2.Reflect(_batVelocity, normal);
173171
}
174172

Tutorials/learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public Core(string title, int width, int height, bool fullScreen)
8787

8888
// Mouse is visible by default
8989
IsMouseVisible = true;
90+
91+
// Exit on escape is true by default
92+
ExitOnEscape = true;
9093
}
9194

9295
protected override void Initialize()

0 commit comments

Comments
 (0)