Skip to content

Commit 1e41a58

Browse files
Patches from tests
- GL functional - DX still does not render anything when bloom enabled
1 parent 1910f7f commit 1e41a58

File tree

8 files changed

+34
-12
lines changed

8 files changed

+34
-12
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
#define PS_SHADERMODEL ps_4_0_level_9_1
1212
#endif
1313

14-
texture BloomTexture;
15-
texture BaseTexture;
14+
Texture2D BloomTexture;
15+
Texture2D BaseTexture;
1616

17-
sampler2D BloomSampler = sampler_state
17+
SamplerState BloomSampler = sampler_state
1818
{
1919
Texture = <BloomTexture>;
2020
Filter = Linear;
2121
AddressU = clamp;
2222
AddressV = clamp;
2323
};
2424

25-
sampler2D BaseSampler = sampler_state
25+
SamplerState BaseSampler = sampler_state
2626
{
2727
Texture = <BaseTexture>;
2828
Filter = Linear;
@@ -56,8 +56,8 @@ float4 AdjustSaturation(float4 color, float saturation)
5656
float4 PixelShaderFunction(VS_OUTPUT input) : SV_TARGET0
5757
{
5858
// Look up the bloom and original base image colors.
59-
float4 bloom = tex2D(BloomSampler, input.TexCoord);
60-
float4 base = tex2D(BaseSampler, input.TexCoord);
59+
float4 bloom = BaseTexture.Sample(BloomSampler, input.TexCoord);
60+
float4 base = BaseTexture.Sample(BaseSampler, input.TexCoord);
6161

6262
// Adjust color saturation and intensity.
6363
bloom = AdjustSaturation(bloom, BloomSaturation) * BloomIntensity;

NeonShooter/NeonShooter.Core/Game/BlackHole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void WasShot()
9696
NeonShooterGame.ParticleManager.CreateParticle(Art.LineParticle, pos, color, 90, 1.5f, state);
9797
}
9898

99-
Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
99+
Sound.Explosion.Play(0.5f * NeonShooterGame.GameVolumeMultiplier, rand.NextFloat(-0.2f, 0.2f), 0);
100100
}
101101

102102
public void Kill()

NeonShooter/NeonShooter.Core/Game/BloomComponent.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.Xna.Framework;
1313
using Microsoft.Xna.Framework.Content;
1414
using Microsoft.Xna.Framework.Graphics;
15+
using NeonShooter;
1516
#endregion
1617

1718
namespace BloomPostprocess
@@ -184,7 +185,15 @@ public override void Draw(GameTime gameTime)
184185
parameters["BaseIntensity"].SetValue(Settings.BaseIntensity);
185186
parameters["BloomSaturation"].SetValue(Settings.BloomSaturation);
186187
parameters["BaseSaturation"].SetValue(Settings.BaseSaturation);
187-
parameters["BaseTexture"].SetValue(sceneRenderTarget);
188+
189+
if (NeonShooterGame.IsDesktopGLBuild)
190+
{
191+
parameters["BaseSampler+BaseTexture"].SetValue(sceneRenderTarget);
192+
}
193+
else
194+
{
195+
parameters["BaseTexture"].SetValue(sceneRenderTarget);
196+
}
188197

189198
Viewport viewport = GraphicsDevice.Viewport;
190199

@@ -311,6 +320,6 @@ float ComputeGaussian(float n)
311320
}
312321

313322

314-
#endregion
323+
#endregion
315324
}
316325
}

NeonShooter/NeonShooter.Core/Game/Enemy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void WasShot()
118118
NeonShooterGame.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
119119
}
120120

121-
Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
121+
Sound.Explosion.Play(0.5f * NeonShooterGame.GameVolumeMultiplier, rand.NextFloat(-0.2f, 0.2f), 0);
122122
}
123123

124124
#region Behaviours

NeonShooter/NeonShooter.Core/Game/GameRoot.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ protected override void Initialize()
5858
if (!OperatingSystem.IsIOS())
5959
{
6060
MediaPlayer.IsRepeating = true;
61+
#if DEBUG
62+
MediaPlayer.Volume = 0f;
63+
#endif
6164
MediaPlayer.Play(Sound.Music);
6265
}
6366
}

NeonShooter/NeonShooter.Core/Game/PlayerShip.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public override void Update()
7171
offset = Vector2.Transform(new Vector2(35, 8), aimQuat);
7272
EntityManager.Add(new Bullet(Position + offset, vel));
7373

74-
Sound.Shot.Play(0.2f, rand.NextFloat(-0.2f, 0.2f), 0);
74+
Sound.Shot.Play(0.2f * NeonShooterGame.GameVolumeMultiplier, rand.NextFloat(-0.2f, 0.2f), 0);
7575
}
7676

7777
if (cooldowmRemaining > 0)

NeonShooter/NeonShooter.Core/NeonShooterGame.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ public class NeonShooterGame: Microsoft.Xna.Framework.Game
2020
public static ParticleManager<ParticleState> ParticleManager { get; private set; }
2121
public static Grid Grid { get; private set; }
2222

23-
GraphicsDeviceManager graphics;
23+
#if DEBUG
24+
public static float GameVolumeMultiplier = 0.1f;
25+
#else
26+
public static float GameVolumeMultiplier = 1f;
27+
#endif
28+
29+
public static bool IsDesktopGLBuild = false;
30+
31+
GraphicsDeviceManager graphics;
2432
SpriteBatch spriteBatch;
2533
BloomComponent bloom;
2634

@@ -78,6 +86,7 @@ protected override void LoadContent()
7886
try
7987
{
8088
MediaPlayer.IsRepeating = true;
89+
MediaPlayer.Volume = NeonShooterGame.GameVolumeMultiplier;
8190
MediaPlayer.Play(Sound.Music);
8291
}
8392
catch { }

NeonShooter/NeonShooter.DesktopGL/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
using NeonShooter;
33

44
using var game = new NeonShooterGame();
5+
NeonShooterGame.IsDesktopGLBuild = true;
56
game.Run();

0 commit comments

Comments
 (0)