Skip to content

Commit 6309a45

Browse files
Migrated from #84 and updated to be more standard
1 parent caeecee commit 6309a45

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

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

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,45 @@
22
// scene, using tweakable intensity levels and saturation.
33
// This is the final step in applying a bloom postprocess.
44

5-
sampler BloomSampler : register(s0);
6-
sampler BaseSampler : register(s1);
5+
#if OPENGL
6+
#define SV_POSITION POSITION
7+
#define VS_SHADERMODEL vs_3_0
8+
#define PS_SHADERMODEL ps_3_0
9+
#else
10+
#define VS_SHADERMODEL vs_4_0_level_9_1
11+
#define PS_SHADERMODEL ps_4_0_level_9_1
12+
#endif
13+
14+
texture BloomTexture;
15+
texture BaseTexture;
16+
17+
sampler2D BloomSampler = sampler_state
18+
{
19+
Texture = <BloomTexture>;
20+
Filter = Linear;
21+
AddressU = clamp;
22+
AddressV = clamp;
23+
};
24+
25+
sampler2D BaseSampler = sampler_state
26+
{
27+
Texture = <BaseTexture>;
28+
Filter = Linear;
29+
AddressU = clamp;
30+
AddressV = clamp;
31+
};
732

833
float BloomIntensity;
934
float BaseIntensity;
1035

1136
float BloomSaturation;
1237
float BaseSaturation;
1338

39+
struct VS_OUTPUT
40+
{
41+
float4 Position : SV_POSITION0;
42+
float2 TexCoord : TEXCOORD0;
43+
};
1444

1545
// Helper for modifying the saturation of a color.
1646
float4 AdjustSaturation(float4 color, float saturation)
@@ -23,11 +53,11 @@ float4 AdjustSaturation(float4 color, float saturation)
2353
}
2454

2555

26-
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
56+
float4 PixelShaderFunction(VS_OUTPUT input) : SV_TARGET0
2757
{
2858
// Look up the bloom and original base image colors.
29-
float4 bloom = tex2D(BloomSampler, texCoord);
30-
float4 base = tex2D(BaseSampler, texCoord);
59+
float4 bloom = tex2D(BloomSampler, input.TexCoord);
60+
float4 base = tex2D(BaseSampler, input.TexCoord);
3161

3262
// Adjust color saturation and intensity.
3363
bloom = AdjustSaturation(bloom, BloomSaturation) * BloomIntensity;
@@ -46,10 +76,6 @@ technique BloomCombine
4676
{
4777
pass Pass1
4878
{
49-
#if SM4
50-
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
51-
#else
52-
PixelShader = compile ps_2_0 PixelShaderFunction();
53-
#endif
79+
PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
5480
}
5581
}

NeonShooter/NeonShooter.Core/Game/BloomComponent.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ public override void Draw(GameTime gameTime)
184184
parameters["BaseIntensity"].SetValue(Settings.BaseIntensity);
185185
parameters["BloomSaturation"].SetValue(Settings.BloomSaturation);
186186
parameters["BaseSaturation"].SetValue(Settings.BaseSaturation);
187-
188-
GraphicsDevice.Textures[1] = sceneRenderTarget;
187+
parameters["BaseTexture"].SetValue(sceneRenderTarget);
189188

190189
Viewport viewport = GraphicsDevice.Viewport;
191190

NeonShooter/NeonShooter.Core/NeonShooterGame.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class NeonShooterGame: Microsoft.Xna.Framework.Game
2525
BloomComponent bloom;
2626

2727
bool paused = false;
28-
2928

3029
public NeonShooterGame()
3130
{

0 commit comments

Comments
 (0)