From fade085269a19048f5eb8a230ef17a844e5ee7ae Mon Sep 17 00:00:00 2001 From: Ferran Pons Date: Sun, 8 Dec 2019 17:41:29 +0100 Subject: [PATCH 1/3] [Issue #20] Added again the DebugComponent --- .../Components/DebugComponent.cs | 157 ++++++++++++++++++ .../Components/FrameRateCounter.cs | 65 ++++++++ ZombustersWindows/MyGame.cs | 8 +- ZombustersWindows/ZombustersWindows.csproj | 2 + 4 files changed, 228 insertions(+), 4 deletions(-) create mode 100644 ZombustersWindows/Components/DebugComponent.cs create mode 100644 ZombustersWindows/Components/FrameRateCounter.cs diff --git a/ZombustersWindows/Components/DebugComponent.cs b/ZombustersWindows/Components/DebugComponent.cs new file mode 100644 index 0000000..f8c73ea --- /dev/null +++ b/ZombustersWindows/Components/DebugComponent.cs @@ -0,0 +1,157 @@ +#region Using Statements +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using GameStateManagement; +using ZombustersWindows.Subsystem_Managers; +#endregion + +namespace ZombustersWindows +{ + /// + /// A message box screen, used to display "debug" messages. + /// + public class DebugInfoComponent : DrawableGameComponent + { + readonly MyGame game; + SpriteBatch spriteBatch; + SpriteFont spriteFont, smallspriteFont; + bool stopUpdatingText = false; + readonly InputState input = new InputState(); + + ScrollingTextManager mText; + String previousNetDebugText = ""; + public String NetDebugText = ""; + + public DebugInfoComponent(MyGame game) + : base(game) + { + this.game = game; + } + + protected override void LoadContent() + { + spriteBatch = new SpriteBatch(GraphicsDevice); + spriteFont = game.Content.Load(@"menu\ArialMenuInfo"); //content.Load(@"menu/ArialMenuInfo"); + smallspriteFont = game.Content.Load(@"menu\ArialMusicItalic"); + + //Create a Textblock object. This object will calculate the line wraps needs for the + //block of text and position the lines of text for scrolling through the display area + mText = new ScrollingTextManager(new Rectangle(0, 280, 500, 400), smallspriteFont, NetDebugText); + } + + public virtual void HandleInput(InputState input) { } + + public void HandleDebugInput(InputState input) + { + if (input.IsNewButtonPress(Buttons.X)) + { + if (stopUpdatingText == false) + stopUpdatingText = true; + else + stopUpdatingText = false; + + + return; + } + + this.HandleInput(input); + } + + + public override void Update(GameTime gameTime) + { + input.Update(); + this.HandleDebugInput(input); + + //Update the TextBlock. This will allow the lines of text to scroll. + if (NetDebugText != previousNetDebugText) + { + mText = new ScrollingTextManager(new Rectangle(781, 322, 500, 400), smallspriteFont, NetDebugText); + previousNetDebugText = NetDebugText; + } + + if (stopUpdatingText == false) + mText.Update(gameTime); + } + + + public override void Draw(GameTime gameTime) + { + int count = 0; + + Vector2 position = new Vector2(32, 64); + + spriteBatch.Begin(); + + //spriteBatch.DrawString(spriteFont, "Signed In Gamers: " + Gamer.SignedInGamers.Count.ToString(), position, Color.White); + + +#if XBOX + if (mygame.gamerManager.getOnlinePlayerGamertag() != null) + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Online Gamertags: " + mygame.gamerManager.getOnlinePlayerGamertag().Count.ToString(), position, Color.White); + } + + if (mygame.gamerManager.getOnlinePlayerIcons() != null) + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Online Icons: " + mygame.gamerManager.getOnlinePlayerIcons().Count.ToString(), position, Color.White); + } +#endif + +#if !WINDOWS_PHONE && !WINDOWS + if (mygame.networkSessionManager.networkSession != null) + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "BPS Received: " + mygame.networkSessionManager.networkSession.BytesPerSecondReceived.ToString(), position, Color.White); + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "BPS Sent: " + mygame.networkSessionManager.networkSession.BytesPerSecondSent.ToString(), position, Color.White); + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Private Slots: " + mygame.networkSessionManager.networkSession.PrivateGamerSlots.ToString(), position, Color.White); + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Max session Gamers: " + mygame.networkSessionManager.networkSession.MaxGamers.ToString(), position, Color.White); + } +#endif + + /*if (Guide.IsTrialMode == true) + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Trial Mode On", position, Color.White); + } + else*/ + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Trial Mode Off", position, Color.White); + } + + count = 0; + foreach (Avatar avatar in game.currentPlayers) + { + if (avatar.Player != null) + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Name: " + avatar.Player.Name, position, Color.White); + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "ULevels" + count.ToString() + ": " + avatar.Player.levelsUnlocked.ToString(), position, Color.White); + +#if !WINDOWS_PHONE && !WINDOWS + if (avatar.Player.Container != null) + { + position = new Vector2(position.X, position.Y + 32); + spriteBatch.DrawString(spriteFont, "Contner Dispsd: " + avatar.Player.Container.IsDisposed.ToString(), position, Color.White); + } +#endif + } + count++; + } + + //Now draw the text to be drawn on the screen + mText.Draw(spriteBatch); + + spriteBatch.End(); + } + } +} diff --git a/ZombustersWindows/Components/FrameRateCounter.cs b/ZombustersWindows/Components/FrameRateCounter.cs new file mode 100644 index 0000000..127a660 --- /dev/null +++ b/ZombustersWindows/Components/FrameRateCounter.cs @@ -0,0 +1,65 @@ +#region Using Statements +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace ZombustersWindows +{ + /// + /// A message box screen, used to display framerate. + /// + public class FrameRateCounter : DrawableGameComponent + { + ContentManager content; + SpriteBatch spriteBatch; + SpriteFont spriteFont; + + int frameRate = 0; + int frameCounter = 0; + TimeSpan elapsedTime = TimeSpan.Zero; + + + public FrameRateCounter(Game game) + : base(game) + { + content = game.Content; + } + + + protected override void LoadContent() + { + spriteBatch = new SpriteBatch(GraphicsDevice); + spriteFont = content.Load(@"menu\ArialMenuInfo"); //content.Load(@"menu/ArialMenuInfo"); + } + + + public override void Update(GameTime gameTime) + { + elapsedTime += gameTime.ElapsedGameTime; + + if (elapsedTime > TimeSpan.FromSeconds(1)) + { + elapsedTime -= TimeSpan.FromSeconds(1); + frameRate = frameCounter; + frameCounter = 0; + } + } + + + public override void Draw(GameTime gameTime) + { + frameCounter++; + + string fps = string.Format("fps: {0}", frameRate); + + spriteBatch.Begin(); + + spriteBatch.DrawString(spriteFont, fps, new Vector2(33, 33), Color.Black); + spriteBatch.DrawString(spriteFont, fps, new Vector2(32, 32), Color.White); + + spriteBatch.End(); + } + } +} diff --git a/ZombustersWindows/MyGame.cs b/ZombustersWindows/MyGame.cs index 6af1038..a37f9d2 100644 --- a/ZombustersWindows/MyGame.cs +++ b/ZombustersWindows/MyGame.cs @@ -35,8 +35,8 @@ public class MyGame : Game { //public StorageDeviceManager storageDeviceManager; #if DEBUG - //public FrameRateCounter FrameRateComponent; - //public DebugInfoComponent DebugComponent; + public FrameRateCounter FrameRateComponent; + public DebugInfoComponent DebugComponent; #endif //int bloomSettingsIndex = 0; @@ -81,10 +81,10 @@ public MyGame() { player4 = new Player(options, audio, this); currentNetworkSetting = 0; #if DEBUG - /*FrameRateComponent = new FrameRateCounter(this); + FrameRateComponent = new FrameRateCounter(this); Components.Add(FrameRateComponent); DebugComponent = new DebugInfoComponent(this); - Components.Add(DebugComponent);*/ + Components.Add(DebugComponent); //Guide.SimulateTrialMode = true; #endif musicComponent = new MusicComponent(this); diff --git a/ZombustersWindows/ZombustersWindows.csproj b/ZombustersWindows/ZombustersWindows.csproj index 58e3e04..42930c9 100644 --- a/ZombustersWindows/ZombustersWindows.csproj +++ b/ZombustersWindows/ZombustersWindows.csproj @@ -62,6 +62,8 @@ Game.ico + + From 1a05f176e6203e8911b1bc7024c61b716075611c Mon Sep 17 00:00:00 2001 From: Ferran Pons Date: Thu, 12 Dec 2019 15:05:30 +0100 Subject: [PATCH 2/3] [Issue #15] Made FX work again --- .../Components/MusicComponent.cs | 29 +++++---- ZombustersWindows/Content/Content.mgcb | 21 ++++++- ZombustersWindows/Content/fx/BloomCombine.fx | 57 ++++++++++++++++++ ZombustersWindows/Content/fx/BloomCombine.xnb | Bin 674 -> 1435 bytes ZombustersWindows/Content/fx/BloomExtract.fx | 31 ++++++++++ ZombustersWindows/Content/fx/BloomExtract.xnb | Bin 598 -> 857 bytes ZombustersWindows/Content/fx/GaussianBlur.fx | 39 ++++++++++++ ZombustersWindows/Content/fx/GaussianBlur.xnb | Bin 672 -> 2123 bytes ZombustersWindows/MainScreens/LogoScreen.cs | 3 +- ZombustersWindows/MenuScreens/MenuScreen.cs | 2 - ZombustersWindows/MyGame.cs | 21 +++---- ZombustersWindows/ZombustersWindows.csproj | 28 +++++---- 12 files changed, 189 insertions(+), 42 deletions(-) create mode 100644 ZombustersWindows/Content/fx/BloomCombine.fx create mode 100644 ZombustersWindows/Content/fx/BloomExtract.fx create mode 100644 ZombustersWindows/Content/fx/GaussianBlur.fx diff --git a/ZombustersWindows/Components/MusicComponent.cs b/ZombustersWindows/Components/MusicComponent.cs index 4fd733a..7525b80 100644 --- a/ZombustersWindows/Components/MusicComponent.cs +++ b/ZombustersWindows/Components/MusicComponent.cs @@ -109,18 +109,18 @@ protected override void LoadContent() retroTraxBkgTexture = contentManager.Load(@"InGame/GUI/retrotrax_anim_bkg"); retroTraxLogoTexture = contentManager.Load(@"InGame/GUI/retrotrax_anim"); - LoadSong("Dancing on a Dime", @"Music/BareWires_DancingOnADime"); - LoadSong("High Dive", @"Music/BlackMath_HighDive"); - LoadSong("Suck City", @"Music/BlackMath_SuckCity"); - LoadSong("Bad Attraction", @"Music/BradSucks_BadAttraction"); - LoadSong("Understood by your Dad", @"Music/BradSucks_UnderstoodByYourDad"); - LoadSong("Wolfram", @"Music/Kraus_Wolfram"); - LoadSong("High Ground", @"Music/LondonToTokyo_HighGround"); - LoadSong("Opening The Portal", @"Music/NuitNoire_OpeningThePortal"); - LoadSong("I Don't Like You", @"Music/TheBlackBug_IDontLikeYou"); - LoadSong("In The Hall Of The Mountain King", @"Music/TheItchyCreeps_ITHOTM"); - LoadSong("As You Know", @"Music/ThisCo_AsYouKnow"); - LoadSong("Take It Away", @"Music/ThisCo_TakeItAway"); + LoadSong("Dancing on a Dime", @"Music\BareWires_DancingOnADime"); + LoadSong("High Dive", @"Music\BlackMath_HighDive"); + LoadSong("Suck City", @"Music\BlackMath_SuckCity"); + LoadSong("Bad Attraction", @"Music\BradSucks_BadAttraction"); + LoadSong("Understood by your Dad", @"Music\BradSucks_UnderstoodByYourDad"); + LoadSong("Wolfram", @"Music\Kraus_Wolfram"); + LoadSong("High Ground", @"Music\LondonToTokyo_HighGround"); + LoadSong("Opening The Portal", @"Music\NuitNoire_OpeningThePortal"); + LoadSong("I Don't Like You", @"Music\TheBlackBug_IDontLikeYou"); + LoadSong("In The Hall Of The Mountain King", @"Music\TheItchyCreeps_ITHOTM"); + LoadSong("As You Know", @"Music\ThisCo_AsYouKnow"); + LoadSong("Take It Away", @"Music\ThisCo_TakeItAway"); font = contentManager.Load(@"menu\ArialMenuInfo"); fontItalic = contentManager.Load(@"menu\ArialMusic"); @@ -166,7 +166,8 @@ public void LoadSong(string songName, string songPath) throw new InvalidOperationException(string.Format("Song '{0}' has already been loaded", songName)); } - songsDictionary.Add(songName, contentManager.Load(songPath)); + //songsDictionary.Add(songName, contentManager.Load(songPath)); + //songsDictionary.Add(songName, Song.FromUri(songName, new Uri(songPath, UriKind.RelativeOrAbsolute))); } /// @@ -192,6 +193,7 @@ public void PlaySong(string song) /// True if song should loop, false otherwise public void PlaySong(string song, bool loop) { + /* string songName = song.Split('|')[0]; if (CurrentSong != songName) @@ -226,6 +228,7 @@ public void PlaySong(string song, bool loop) MediaPlayer.Pause(); } } + */ } /// diff --git a/ZombustersWindows/Content/Content.mgcb b/ZombustersWindows/Content/Content.mgcb index 312657d..67299a1 100644 --- a/ZombustersWindows/Content/Content.mgcb +++ b/ZombustersWindows/Content/Content.mgcb @@ -3,7 +3,7 @@ /outputDir:bin/Windows /intermediateDir:obj/Windows -/platform:DesktopGL +/platform:Windows /config: /profile:Reach /compress:False @@ -13,6 +13,25 @@ #---------------------------------- Content ---------------------------------# +#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 +/processorParam:Defines= +/build:fx/BloomExtract.fx + +#begin fx/GaussianBlur.fx +/importer:EffectImporter +/processor:EffectProcessor +/processorParam:DebugMode=Auto +/build:fx/GaussianBlur.fx + #begin Music/BareWires_DancingOnADime.ogg /importer:OggImporter /processor:SongProcessor diff --git a/ZombustersWindows/Content/fx/BloomCombine.fx b/ZombustersWindows/Content/fx/BloomCombine.fx new file mode 100644 index 0000000..f5b49b6 --- /dev/null +++ b/ZombustersWindows/Content/fx/BloomCombine.fx @@ -0,0 +1,57 @@ +// 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 + { +#if SM4 + PixelShader = compile ps_4_0_level_9_1 PixelShaderF(); +#elif SM3 + PixelShader = compile ps_3_0 PixelShaderF(); +#else + PixelShader = compile ps_2_0 PixelShaderF(); +#endif + } +} diff --git a/ZombustersWindows/Content/fx/BloomCombine.xnb b/ZombustersWindows/Content/fx/BloomCombine.xnb index f950d7f7335e13393ce827839f2bdadd41687d0f..557200d98a46a89ddf6216d904cee4bd33e78d5f 100644 GIT binary patch literal 1435 zcma)6&rj1}7=FK&LHQwDxaf@@Ja||Zz_`F+FgEBUh95E@(~Fi_bYW{r*9Fmp)Pphc zpj^?*5)%_$VmOPH%6~xMB>q6 zrR+L&XUj{KY%^uJX3g4l-0f7}u|3Q7QuA9|R@qy%%zKub)E6DwDFAW`OzIn!Tdz2F z=4vXP8cU6*C$1&+e52|$Tq|Q+4bL^JNqwcUS*?_BSbJ;Ewq@YfTgK=mV?wNF4|$T;$OhNVl?Lpwo!ef>1%8poRnQYR8Y-9nFJ zJ@6l3e>^nJ6ZIeCD6knJ&e%^7^LanMqdG8xEBl5LV3jP<+4qGak#^E+IKcH%!ksp6U_&M6=Y>rC9=?nJvsRkHuqEPFu*-y_Y; zjWl!q?Qu#UCH8t^WVLoqd$6g z(Y*NH-ESIWUMLop_{(D*IQyhyMaJ)&O@*^IU&=2pug+1c)mr`!P8_`A#+^0Oy>EFS z@xJ^=;LjN!FJ`6==ctn*50 m-%v=a?Nlu{+@xQd^b%7hNvX{L%w}_o)TVP&8DIoR| zoi54=Vime?)DcW&)%(L2`P$P%-EJN}8t=Shy|th8KAHzH3CF>cK|YK>RExp+`-v-P z!zu)9=AYLqbUDDqGO3u4U@erw&>bk+^Siw?NY+Ok61)D208^Iyz^l1JcBuQ~e}OJ6tSy98^b))spEBZEOjKjaH2W`0yO5 z^PxJ@R)eDy`&;YAoTFMF9iylhk*=B_k3jyV2~EHqRvOuBjjSI^c1kR4N>+X09^9b4 z1Np|~&?kGw{F@U?mJ+jcgULgPBqpD&$_?1d35iW}(9rx~@NM2Z%$nV!vh42uv!)!) z!3NWqXLZ-7t}YE)*cvLTS-mY)HCweQ|9@8a&w!a-(|fxXU04M(i`VNFw!zNqRYQjZ zXJ=)tK|RM$=%|yj>CbcMpVLa_{?>utdrA?o{Ie>zEyHB3(bjGQsR0)mS)Wk;sEdx! zh7*syVBirYIe!H2?D@#XeFI2GVi+I-z-`(;TI7TnmSl@MhP?%h`U3;T#}HFM{&Rqb I000000D6c$O8@`> diff --git a/ZombustersWindows/Content/fx/BloomExtract.fx b/ZombustersWindows/Content/fx/BloomExtract.fx new file mode 100644 index 0000000..e0fbef9 --- /dev/null +++ b/ZombustersWindows/Content/fx/BloomExtract.fx @@ -0,0 +1,31 @@ +// 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 + { +#if SM4 + PixelShader = compile ps_4_0_level_9_1 PixelShaderF(); +#elif SM3 + PixelShader = compile ps_3_0 PixelShaderF(); +#else + PixelShader = compile ps_2_0 PixelShaderF(); +#endif + } +} diff --git a/ZombustersWindows/Content/fx/BloomExtract.xnb b/ZombustersWindows/Content/fx/BloomExtract.xnb index b96767ac1dc0e7919dc48742841e197038a33dd7..24fc4fe12b0f29d095e5b347fed3433829b35597 100644 GIT binary patch literal 857 zcma)4%Wl(95S<&7)LVj5MAzXU@#^eb_st(P!f@E&{zC!G?r*$0F?oYCDF z<$;%Di~y7KltKTLD9I>2CJMJ=R)s940fa=_MU2l$PmfC=h|=Jv7o<p$*6Mlg0Tkj2^=>MO| z{uddQ+qZBuClTJ;BRb5Gww8%<4&9{@;U3nIo2n8mUE#a~K}e96D!D=o+C85Sd%``6cv;sLQ*C}GpK;3> doVeVVB+55bL-h;~yAu#g?mENaD&d-l{s4CajRODx literal 598 zcmV-c0;&C2PC|DDfmQ+l0Hy>00RIH00zLpBX-bt%08#(|GXelKKmged)yisO0zMZ4 z2zZ#F%d)^y#vs+^kb~Hz;!9>pO}(XAZR*shAP^4-qL7OCeFXsshdq7t$j8N=Cinml z002fK0B~>xD!(OHEx`?&u-O}K!YiB5I+&Z{L*{I#)@4auw*`UMR+PXCztI2x0KotN z001-tQ&9H`$4j3;`la8c-`@k@4yJTe5|xa?u(?F!0yZwO&BM16oJI>N8i)96g3<7j z5`$GJ8R6!o^KmH&rTTA~pDm9TT30nYI?hg)qLh{Lqz%e|o?YQ7DuYJlI+cVgZ3&k(TSssWH#RmIisaux4kNz73Foym*%w4GB!?%l|h@97D54HTW0+lAM z+0)cPlub|35R}obuTD%BMM}l>%KYtx)U=jGA+a}xGkSmdsfX_`ntZ+5SQC72kpoPh zb#&*1m*&1x;+Tx*2UgpIyCzKf9R_lcS3IKM!@8=@_>{UEgpD+TTz+tz{_4*G91Uh%{KQ5nmIBNeo@-nvd2CTM)tfFPteX)4UAJU6#Fk)}A zoDwX)h~Uo<`#bF>sQx3I-fwH2nlROFS&^^cpCeC$mGPUDScYZxK8`P!I6w5hBHb4o k_c5ILqAvRW{*q6>oxIxEocMlsGEJ6Wk10000008{lP5dZ)H diff --git a/ZombustersWindows/Content/fx/GaussianBlur.fx b/ZombustersWindows/Content/fx/GaussianBlur.fx new file mode 100644 index 0000000..0e73d07 --- /dev/null +++ b/ZombustersWindows/Content/fx/GaussianBlur.fx @@ -0,0 +1,39 @@ +// 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 + { +#if SM4 + PixelShader = compile ps_4_0_level_9_1 PixelShaderF(); +#elif SM3 + PixelShader = compile ps_3_0 PixelShaderF(); +#else + PixelShader = compile ps_2_0 PixelShaderF(); +#endif + } +} diff --git a/ZombustersWindows/Content/fx/GaussianBlur.xnb b/ZombustersWindows/Content/fx/GaussianBlur.xnb index 8f4dd6cb0175a1d6acf690ba838850ea6815a183..a5758f1c5980bfb1a605fe257ac0daba3555a236 100644 GIT binary patch literal 2123 zcmd^=%}*0S7{=e(?Z;A~1^hz%T8#$}O#_G|9x%0qRzvs*En2cP~+ z69?l7uiWu~XAgSt=zrkF1MzJ52k?12v#Z&Yi6`TP?Y_TfW_O->-`SxySJ;lzj6o!x z&o)*(x8>ITT+Oj^CC}Qlw_R@|S9BfUcKqCQy>74gi?+3Dds%bVb=)$B{2G`w@7rFh z;X0Eyaud0c+~~yE&8%5$H~qF}Pdawn_pD~tTxc&h8!I#Rv#PscJCjbk*(7e_Ly~B= zT&fu&{c-2Bpl?EB`3DK|<3v-nLNVrifBR|k)z>fYcILF**n5Ei+!w=r1lOKU)C#{c6>aJ`#3^D*YV5IIO1z6#trR~ymiN4#xJl#q#vmG4H=m|htJ{dIR=K;kmF!@4LJdZ*N~H7cn#SA!)wSrV0aBV1%}ryqjbox^xKb; zqPF;xeluWRN1(Cifr!Sw2O}DLKN->3|EY+^Yd9UzcpYaV8n5MSMC0`gMKoU1Ii>Nw z3HHeeRi|K|^ePVaNuT0ipQKeC|E6w1&baQw5ucpL^AU~ncp;*39xo~l-=2o=p~Lk! zJ|?Q%omyOlm?xr#d>Irgy*3fa@9GiP^$9A9RvSW1w`9DuM6}#b`dGhY8{>{l8Lwjw z{(L8hj3bhomWL2&=#LMgpU(r4mz^UBuMj1#Dn0dEKlTyK#PngM0ehBJoEVVvBwm_G z8By@uG{&$8)RA`Ma<0+~IW}0=7>=L7XDKbmCOT$<-@|hT@8UjgIB$}H@1T$U^E$BS z1g|T|MexjR==Un+xh%%;IGo*N;tCq)i<^$1I$bNy&o55V{{H^_A3VbzEB7B)EpN^C z@escsCBRJ=dSAub+-lnM^?J+pTbNwS2%fBaOm_z&{;ve2MJ45d-B?@iCPifU_#z=w r$J^|mgk-vEKjnYivgn?yujnmX?N+N{IfZ81BN1P)TCGvS*H82l6wftH literal 672 zcmV;R0$=@DPC|DDfuI5a0M-Wp0RIQp0*C-0XMJ%L073u&GXelLKmhGsx3wjIR{c>c zLfm44+R6czZ2&-4Flq~yLI6h^wAr?qY?}f$!~;S+1Bgz<3L!ZIh=)gcd5oBcc|b%7 z000O8Sk(al9a!$Obp6|LHN6JK;I-jxhFDyRg`7E|7kDoe6$4Si@m-3bZwwF)uOQ29y>yd|$W5E|X&(fpIy$OoeftsQ!F z+G%91!L{b}O&lVpZ+?5yFFFxvb#~a+AzU^Ce zM*93LA|h_yKBAywIuDXoZxV|=DA%_3HL;Vx(@L~vE8pDi&g+e6LLA_9)Ozh6{>Vd< zAoyU6`3onHMHbnL6DqzFe1VVri2mA5?cKSJ9*wavY2=2Pm&IgPnWG)sas#w=9w;0J zBp5Vpxg!`q^2D-SdkmR}la)HofVfl2A^=DP5s4^5h($WFp%W83Jh8zOBN&MmL-ohr z#%O38whJrK(YCfrYthrT+ojrRwC#5BFxse2?Y|i&yMH@oG2bcaC$7j+HRFy(@"menu\ArialMusic"); fontSmallItalic = game.Content.Load(@"menu\ArialMusicItalic"); menu = new MenuComponent(game, MenuListFont); - //bloom = new BloomComponent(game); menu.Initialize(); menu.AddText(Strings.WPPlayNewGame.ToUpper(), Strings.WPPlayNewGameMMString); menu.AddText(Strings.ExtrasMenuString, Strings.ExtrasMMString); @@ -57,7 +56,6 @@ public override void Initialize() { menu.MenuConfigSelected += new EventHandler(OnMenuConfigSelected); //menu.MenuShowMarketplace += new EventHandler(OnShowMarketplace); menu.CenterInXLeftMenu(view); - //bloom.Visible = !bloom.Visible; game.isInMenu = true; base.Initialize(); this.isBackgroundOn = true; diff --git a/ZombustersWindows/MyGame.cs b/ZombustersWindows/MyGame.cs index a37f9d2..e5f0f27 100644 --- a/ZombustersWindows/MyGame.cs +++ b/ZombustersWindows/MyGame.cs @@ -31,15 +31,13 @@ public class MyGame : Game { public BaseClient bugSnagClient; public float totalGameSeconds; - //public BloomComponent bloom; + public BloomComponent bloom; //public StorageDeviceManager storageDeviceManager; #if DEBUG public FrameRateCounter FrameRateComponent; public DebugInfoComponent DebugComponent; #endif - - //int bloomSettingsIndex = 0; public String[] networkSettings = { "XBOX LIVE", "SYSTEM LINK" }; public int currentNetworkSetting; @@ -66,15 +64,14 @@ public MyGame() { audio.SetOptions(0.7f, 0.5f); input = new InputManager(this); Components.Add(input); - //Bloom Component - //REVISAR!!! - //graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0; - /* - bloom = new BloomComponent(this); + + bloom = new BloomComponent(this) + { + Settings = BloomSettings.PresetSettings[6] + }; + bloom.Visible = false; Components.Add(bloom); - bloom.Settings = BloomSettings.PresetSettings[6]; - bloom.Visible = true; - */ + player1 = new Player(options, audio, this); player2 = new Player(options, audio, this); player3 = new Player(options, audio, this); @@ -299,7 +296,7 @@ public void FailToMenu() { public void QuitGame() { playScreen = null; - //bloom.Visible = true; + bloom.Visible = true; Reset(); bPaused = EndPause(); //GamePlayStatus = GameplayState.StartLevel; diff --git a/ZombustersWindows/ZombustersWindows.csproj b/ZombustersWindows/ZombustersWindows.csproj index 42930c9..e65816f 100644 --- a/ZombustersWindows/ZombustersWindows.csproj +++ b/ZombustersWindows/ZombustersWindows.csproj @@ -187,6 +187,10 @@ ..\packages\Bugsnag.1.4.0.0\lib\Net45\Bugsnag.dll + + False + ..\..\..\..\..\..\..\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll + ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll @@ -212,9 +216,6 @@ ..\packages\MonoGame.Framework.MacOS.3.6.0.1625\lib\net45\Tao.Sdl.dll - - ..\packages\MonoGame.Framework.DesktopGL.3.5.1.1679\lib\net40\MonoGame.Framework.dll - ..\packages\MonoGame.Framework.DesktopGL.3.5.1.1679\lib\net40\NVorbis.dll False @@ -389,15 +390,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -1194,6 +1186,18 @@ PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + + PreserveNewest + From 1853aa789fa5d944e04e09db785f3b8241941898 Mon Sep 17 00:00:00 2001 From: Ferran Pons Date: Wed, 25 Mar 2020 19:52:33 +0100 Subject: [PATCH 3/3] Working but with black screen --- ZombustersWindows/Content/fx/BloomCombine.fx | 52 ++++----- ZombustersWindows/Content/fx/BloomCombine.xnb | Bin 1435 -> 1494 bytes ZombustersWindows/Content/fx/Macros.fxh | 99 ++++++++++++++++++ ZombustersWindows/MainScreens/LogoScreen.cs | 2 +- ZombustersWindows/MyGame.cs | 2 - ZombustersWindows/ZombustersWindows.csproj | 1 + 6 files changed, 123 insertions(+), 33 deletions(-) create mode 100644 ZombustersWindows/Content/fx/Macros.fxh diff --git a/ZombustersWindows/Content/fx/BloomCombine.fx b/ZombustersWindows/Content/fx/BloomCombine.fx index f5b49b6..6617b85 100644 --- a/ZombustersWindows/Content/fx/BloomCombine.fx +++ b/ZombustersWindows/Content/fx/BloomCombine.fx @@ -1,57 +1,49 @@ // 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. +// This is the final step in applying a bloom post-process. +#include "Macros.fxh" -sampler BloomSampler : register(s0); -sampler BaseSampler : register(s1); +DECLARE_TEXTURE(BloomTexture, 0); -float BloomIntensity; -float BaseIntensity; - -float BloomSaturation; -float BaseSaturation; +BEGIN_DECLARE_TEXTURE(BaseTexture, 1) +Filter = LINEAR; +AddressU = CLAMP; +AddressV = CLAMP; +END_DECLARE_TEXTURE; +BEGIN_CONSTANTS +float BloomIntensity; +float BaseIntensity; +float BloomSaturation; +float BaseSaturation; +END_CONSTANTS // 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)); + float grey = dot((float3)color, float3(0.3, 0.59, 0.11)); return lerp(grey, color, saturation); } - -float4 PixelShaderF(float2 texCoord : TEXCOORD0) : COLOR0 +float4 PixelShaderFunction(float4 position : SV_POSITION, float4 Color : COLOR0, float2 texCoord : TEXCOORD0) : SV_TARGET0 { // Look up the bloom and original base image colors. - float4 bloom = tex2D(BloomSampler, texCoord); - float4 base = tex2D(BaseSampler, texCoord); - + float4 bloom = SAMPLE_TEXTURE(BloomTexture, texCoord); + float4 base = SAMPLE_TEXTURE(BaseTexture, 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 - { -#if SM4 - PixelShader = compile ps_4_0_level_9_1 PixelShaderF(); -#elif SM3 - PixelShader = compile ps_3_0 PixelShaderF(); -#else - PixelShader = compile ps_2_0 PixelShaderF(); -#endif - } -} +TECHNIQUE_NO_VS(BloomCombine, PixelShaderFunction); diff --git a/ZombustersWindows/Content/fx/BloomCombine.xnb b/ZombustersWindows/Content/fx/BloomCombine.xnb index 557200d98a46a89ddf6216d904cee4bd33e78d5f..9a7c729a6fbeb9f9221470737eba6a946c6859c2 100644 GIT binary patch delta 349 zcmbQueT|zv!q2IkmEqb%_SRrGRt5%Ncee-*MkS43!i)?83@i)`42&!cOdJf%JPeEs z89=^Egp>0D+4!Ih$v*{pvUDROgW6(`H7d&1ua1jP*G{6M&i-IDj|+ zh(Q2k14s-6_<=YE%z_XgagaPnJP9HMCPCs%K+Fte1c${3_y>E2c>4P>IQ#qf2Qh@W zMmYQX2e~k;_78UV(*ddjnE|wO@)j0ZR>vTB*O1BASUN01QY%VIi&BAdK)}q-?UY!Y aiXz6yh;tcgYGsU?%eSUYTk6LSl4Qj35#0Rb~Rw^L$qDvB5*k5f*5ey($V VZc=7mDgz^HKw@#RA;W)=dI08wJBk1R diff --git a/ZombustersWindows/Content/fx/Macros.fxh b/ZombustersWindows/Content/fx/Macros.fxh new file mode 100644 index 0000000..9173f37 --- /dev/null +++ b/ZombustersWindows/Content/fx/Macros.fxh @@ -0,0 +1,99 @@ +//----------------------------------------------------------------------------- +// Macros.fxh +// +// Microsoft XNA Community Game Platform +// Copyright (C) Microsoft Corporation. All rights reserved. +//----------------------------------------------------------------------------- + +#ifdef SM5 + +// Macros for targeting shader 5.0(DX11) + +#define TECHNIQUE(name, vsname, psname ) \ + technique name { pass { VertexShader = compile vs_5_0 vsname (); PixelShader = compile ps_5_0 psname(); } } + +#define TECHNIQUE_NO_VS(name, psname ) \ + technique name { pass { PixelShader = compile ps_5_0 psname(); } } + +#elif SM4 + +// Macros for targeting shader model 4.0(DX11) + +#define TECHNIQUE(name, vsname, psname ) \ + technique name { pass { VertexShader = compile vs_4_0_level_9_1 vsname (); PixelShader = compile ps_4_0_level_9_1 psname(); } } + +#define TECHNIQUE_NO_VS(name, psname ) \ + technique name { pass { PixelShader = compile ps_4_0_level_9_1 psname(); } } + + +#elif OPENGL + +// Macros for targeting shader model 3.0 (OPENGL) + +#define TECHNIQUE(name, vsname, psname ) \ + technique name { pass { VertexShader = compile vs_3_0 vsname (); PixelShader = compile ps_3_0 psname(); } } + +#define TECHNIQUE_NO_VS(name, psname ) \ + technique name { pass { PixelShader = compile ps_3_0 psname(); } } + +#else + +// Macros for targeting shader model 2.0 (DX9) + +#define TECHNIQUE(name, vsname, psname ) \ + technique name { pass { VertexShader = compile vs_2_0 vsname (); PixelShader = compile ps_2_0 psname(); } } + +#define TECHNIQUE_NO_VS(name, psname ) \ + technique name { pass { PixelShader = compile ps_2_0 psname(); } } + +#endif + +#if defined(SM5) || defined(SM4) + +// Macros for targeting shader model 4.0 and 5.0(DX11) + +#define BEGIN_CONSTANTS cbuffer Parameters : register(b0) { +#define END_CONSTANTS }; + +#define DECLARE_TEXTURE(Name, index) \ + Texture2D Name : register(t##index); \ + sampler Name##Sampler : register(s##index) + +#define BEGIN_DECLARE_TEXTURE(Name, index) \ + DECLARE_TEXTURE(Name, index) \ + { + +#define END_DECLARE_TEXTURE \ + } + +#define SAMPLE_TEXTURE(Name, texCoord) Name.Sample(Name##Sampler, texCoord) + +#else + +// Macros for targeting shader model 2.0, 3.0 (DX9/OPENGL) + +#define SV_POSITION POSITION +#define SV_POSITION0 POSITION0 +#define SV_TARGET COLOR +#define SV_TARGET0 COLOR0 + +#define BEGIN_CONSTANTS +#define END_CONSTANTS + +#define DECLARE_TEXTURE(Name, index) \ + sampler Name##Sampler : register(s##index) \ + { \ + Texture = (Name); \ + } + +#define BEGIN_DECLARE_TEXTURE(Name, index) \ + sampler Name##Sampler : register(s##index) \ + { \ + Texture = (Name); + +#define END_DECLARE_TEXTURE \ + } + +#define SAMPLE_TEXTURE(Name, texCoord) tex2D(Name##Sampler, texCoord) + +#endif diff --git a/ZombustersWindows/MainScreens/LogoScreen.cs b/ZombustersWindows/MainScreens/LogoScreen.cs index 972bc16..9bac22d 100644 --- a/ZombustersWindows/MainScreens/LogoScreen.cs +++ b/ZombustersWindows/MainScreens/LogoScreen.cs @@ -65,7 +65,7 @@ public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool co void FinishLogo() { this.ScreenManager.AddScreen(new StartScreen()); - game.bloom.Visible = false; + game.bloom.Visible = true; ExitScreen(); } diff --git a/ZombustersWindows/MyGame.cs b/ZombustersWindows/MyGame.cs index 54bb98a..bec3662 100644 --- a/ZombustersWindows/MyGame.cs +++ b/ZombustersWindows/MyGame.cs @@ -74,9 +74,7 @@ public MyGame() { { Settings = BloomSettings.PresetSettings[6] }; - bloom.Visible = false; Components.Add(bloom); - bloom.Settings = BloomSettings.PresetSettings[6]; bloom.Visible = true; bugSnagClient = new Client("1cad9818fb8d84290d776245cd1f948d"); diff --git a/ZombustersWindows/ZombustersWindows.csproj b/ZombustersWindows/ZombustersWindows.csproj index 4fa9889..a54513f 100644 --- a/ZombustersWindows/ZombustersWindows.csproj +++ b/ZombustersWindows/ZombustersWindows.csproj @@ -1212,6 +1212,7 @@ PreserveNewest +