diff --git a/ZombustersInstaller/Product.wxs b/ZombustersInstaller/Product.wxs index dddd372..a27e381 100644 --- a/ZombustersInstaller/Product.wxs +++ b/ZombustersInstaller/Product.wxs @@ -464,7 +464,7 @@ - + diff --git a/ZombustersWindows/BloomPostProcess/BloomComponent.cs b/ZombustersWindows/BloomPostProcess/BloomComponent.cs index 35cc0f3..265ea02 100644 --- a/ZombustersWindows/BloomPostProcess/BloomComponent.cs +++ b/ZombustersWindows/BloomPostProcess/BloomComponent.cs @@ -2,6 +2,7 @@ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.IO; #endregion namespace ZombustersWindows @@ -71,8 +72,8 @@ protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); - bloomExtractEffect = Game.Content.Load("fx/BloomExtract"); bloomCombineEffect = Game.Content.Load("fx/BloomCombine"); + bloomExtractEffect = Game.Content.Load("fx/BloomExtract"); gaussianBlurEffect = Game.Content.Load("fx/GaussianBlur"); // Look up the resolution and format of our main backbuffer. diff --git a/ZombustersWindows/Content/Content.mgcb b/ZombustersWindows/Content/Content.mgcb index 312657d..a708b33 100644 --- a/ZombustersWindows/Content/Content.mgcb +++ b/ZombustersWindows/Content/Content.mgcb @@ -85,3 +85,21 @@ /processorParam:Quality=Best /build:Music/ThisCo_TakeItAway.ogg +#begin fx/BloomCombine.fx +/importer:EffectImporter +/processor:EffectProcessor +/processorParam:DebugMode=Auto +/build:fx/BloomCombine.fx + +#begin fx/BloomExtract.fx +/importer:EffectImporter +/processor:EffectProcessor +/processorParam:DebugMode=Auto +/build:fx/BloomExtract.fx + +#begin fx/GaussianBlur.fx +/importer:EffectImporter +/processor:EffectProcessor +/processorParam:DebugMode=Auto +/build:fx/GaussianBlur.fx + diff --git a/ZombustersWindows/Content/fx/BloomCombine.fx b/ZombustersWindows/Content/fx/BloomCombine.fx new file mode 100644 index 0000000..b8f25c8 --- /dev/null +++ b/ZombustersWindows/Content/fx/BloomCombine.fx @@ -0,0 +1,51 @@ +// Pixel shader combines the bloom image with the original +// scene, using tweakable intensity levels and saturation. +// This is the final step in applying a bloom postprocess. + +sampler BloomSampler : register(s0); +sampler BaseSampler : register(s1); + +float BloomIntensity; +float BaseIntensity; + +float BloomSaturation; +float BaseSaturation; + + +// Helper for modifying the saturation of a color. +float4 AdjustSaturation(float4 color, float saturation) +{ + // The constants 0.3, 0.59, and 0.11 are chosen because the + // human eye is more sensitive to green light, and less to blue. + float grey = dot(color, float3(0.3, 0.59, 0.11)); + + return lerp(grey, color, saturation); +} + + +float4 PixelShaderF(float2 texCoord : TEXCOORD0) : COLOR0 +{ + // Look up the bloom and original base image colors. + float4 bloom = tex2D(BloomSampler, texCoord); + float4 base = tex2D(BaseSampler, texCoord); + + // Adjust color saturation and intensity. + bloom = AdjustSaturation(bloom, BloomSaturation) * BloomIntensity; + base = AdjustSaturation(base, BaseSaturation) * BaseIntensity; + + // Darken down the base image in areas where there is a lot of bloom, + // to prevent things looking excessively burned-out. + base *= (1 - saturate(bloom)); + + // Combine the two images. + return base + bloom; +} + + +technique BloomCombine +{ + pass Pass1 + { + PixelShader = compile ps_3_0 PixelShaderF(); + } +} \ No newline at end of file diff --git a/ZombustersWindows/Content/fx/BloomCombine.mgfxo b/ZombustersWindows/Content/fx/BloomCombine.mgfxo new file mode 100644 index 0000000..6c56e23 Binary files /dev/null and b/ZombustersWindows/Content/fx/BloomCombine.mgfxo differ diff --git a/ZombustersWindows/Content/fx/BloomExtract.fx b/ZombustersWindows/Content/fx/BloomExtract.fx new file mode 100644 index 0000000..29b57b6 --- /dev/null +++ b/ZombustersWindows/Content/fx/BloomExtract.fx @@ -0,0 +1,25 @@ +// Pixel shader extracts the brighter areas of an image. +// This is the first step in applying a bloom postprocess. + +sampler TextureSampler : register(s0); + +float BloomThreshold; + + +float4 PixelShaderF(float2 texCoord : TEXCOORD0) : COLOR0 +{ + // Look up the original image color. + float4 c = tex2D(TextureSampler, texCoord); + + // Adjust it to keep only values brighter than the specified threshold. + return saturate((c - BloomThreshold) / (1 - BloomThreshold)); +} + + +technique BloomExtract +{ + pass Pass1 + { + PixelShader = compile ps_3_0 PixelShaderF(); + } +} \ No newline at end of file diff --git a/ZombustersWindows/Content/fx/BloomExtract.mgfxo b/ZombustersWindows/Content/fx/BloomExtract.mgfxo new file mode 100644 index 0000000..6faf25f Binary files /dev/null and b/ZombustersWindows/Content/fx/BloomExtract.mgfxo differ diff --git a/ZombustersWindows/Content/fx/GaussianBlur.fx b/ZombustersWindows/Content/fx/GaussianBlur.fx new file mode 100644 index 0000000..6d93524 --- /dev/null +++ b/ZombustersWindows/Content/fx/GaussianBlur.fx @@ -0,0 +1,33 @@ +// Pixel shader applies a one dimensional gaussian blur filter. +// This is used twice by the bloom postprocess, first to +// blur horizontally, and then again to blur vertically. + +sampler TextureSampler : register(s0); + +#define SAMPLE_COUNT 15 + +float2 SampleOffsets[SAMPLE_COUNT]; +float SampleWeights[SAMPLE_COUNT]; + + +float4 PixelShaderF(float2 texCoord : TEXCOORD0) : COLOR0 +{ + float4 c = 0; + + // Combine a number of weighted image filter taps. + for (int i = 0; i < SAMPLE_COUNT; i++) + { + c += tex2D(TextureSampler, texCoord + SampleOffsets[i]) * SampleWeights[i]; + } + + return c; +} + + +technique GaussianBlur +{ + pass Pass1 + { + PixelShader = compile ps_3_0 PixelShaderF(); + } +} \ No newline at end of file diff --git a/ZombustersWindows/Content/fx/GaussianBlur.mgfxo b/ZombustersWindows/Content/fx/GaussianBlur.mgfxo new file mode 100644 index 0000000..9095e80 Binary files /dev/null and b/ZombustersWindows/Content/fx/GaussianBlur.mgfxo differ diff --git a/ZombustersWindows/MyGame.cs b/ZombustersWindows/MyGame.cs index 7d9e3dd..e44a6e9 100644 --- a/ZombustersWindows/MyGame.cs +++ b/ZombustersWindows/MyGame.cs @@ -36,7 +36,7 @@ public class MyGame : Game { public StorageDataSource storageDataSource; public float totalGameSeconds; - //public BloomComponent bloom; + public BloomComponent bloom; //public StorageDeviceManager storageDeviceManager; #if DEBUG @@ -45,7 +45,7 @@ public class MyGame : Game { #endif //int bloomSettingsIndex = 0; - + public String[] networkSettings = { "XBOX LIVE", "SYSTEM LINK" }; public int currentNetworkSetting; public int maxGamers = 4; @@ -73,13 +73,13 @@ public MyGame() { Components.Add(input); //Bloom Component //REVISAR!!! - //graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0; - /* + //graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0; + bloom = new BloomComponent(this); Components.Add(bloom); bloom.Settings = BloomSettings.PresetSettings[6]; bloom.Visible = true; - */ + bugSnagClient = new Client("1cad9818fb8d84290d776245cd1f948d"); //bugSnagClient.StartAutoNotify(); @@ -101,7 +101,7 @@ public MyGame() { Components.Add(musicComponent); musicComponent.Enabled = true; - + } protected override void Initialize() { @@ -114,7 +114,7 @@ protected override void Initialize() { if (i == 0) { this.InitializeMain(PlayerIndex.One); } - } + } base.Initialize(); screenManager.AddScreen(new LogoScreen()); currentGameState = GameState.SignIn; diff --git a/ZombustersWindows/ZombustersWindows.csproj b/ZombustersWindows/ZombustersWindows.csproj index 5e8ddab..1de4e03 100644 --- a/ZombustersWindows/ZombustersWindows.csproj +++ b/ZombustersWindows/ZombustersWindows.csproj @@ -403,15 +403,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -1208,6 +1199,9 @@ PreserveNewest + + +