Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #15] Made FX work again #33

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions ZombustersWindows/Components/MusicComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ protected override void LoadContent()
retroTraxBkgTexture = contentManager.Load<Texture2D>(@"InGame/GUI/retrotrax_anim_bkg");
retroTraxLogoTexture = contentManager.Load<Texture2D>(@"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<SpriteFont>(@"menu\ArialMenuInfo");
fontItalic = contentManager.Load<SpriteFont>(@"menu\ArialMusic");
Expand Down Expand Up @@ -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<Song>(songPath));
//songsDictionary.Add(songName, contentManager.Load<Song>(songPath));
//songsDictionary.Add(songName, Song.FromUri(songName, new Uri(songPath, UriKind.RelativeOrAbsolute)));
}

/// <summary>
Expand All @@ -192,6 +193,7 @@ public void PlaySong(string song)
/// <param name="loop">True if song should loop, false otherwise</param>
public void PlaySong(string song, bool loop)
{
/*
string songName = song.Split('|')[0];

if (CurrentSong != songName)
Expand Down Expand Up @@ -226,6 +228,7 @@ public void PlaySong(string song, bool loop)
MediaPlayer.Pause();
}
}
*/
}

/// <summary>
Expand Down
21 changes: 20 additions & 1 deletion ZombustersWindows/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/outputDir:bin/Windows
/intermediateDir:obj/Windows
/platform:DesktopGL
/platform:Windows
/config:
/profile:Reach
/compress:False
Expand All @@ -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
Expand Down
49 changes: 49 additions & 0 deletions ZombustersWindows/Content/fx/BloomCombine.fx
Original file line number Diff line number Diff line change
@@ -0,0 +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 post-process.
#include "Macros.fxh"

DECLARE_TEXTURE(BloomTexture, 0);

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((float3)color, float3(0.3, 0.59, 0.11));

return lerp(grey, color, saturation);
}

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 = 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_NO_VS(BloomCombine, PixelShaderFunction);
Binary file modified ZombustersWindows/Content/fx/BloomCombine.xnb
Binary file not shown.
31 changes: 31 additions & 0 deletions ZombustersWindows/Content/fx/BloomExtract.fx
Original file line number Diff line number Diff line change
@@ -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
}
}
Binary file modified ZombustersWindows/Content/fx/BloomExtract.xnb
Binary file not shown.
39 changes: 39 additions & 0 deletions ZombustersWindows/Content/fx/GaussianBlur.fx
Original file line number Diff line number Diff line change
@@ -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
}
}
Binary file modified ZombustersWindows/Content/fx/GaussianBlur.xnb
Binary file not shown.
99 changes: 99 additions & 0 deletions ZombustersWindows/Content/fx/Macros.fxh
Original file line number Diff line number Diff line change
@@ -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<float4> 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
3 changes: 1 addition & 2 deletions ZombustersWindows/MainScreens/LogoScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool co

void FinishLogo() {
this.ScreenManager.AddScreen(new StartScreen());
//Removes the Bloom Effect from the Menu
//this.Game.bloom.Visible = !this.Game.bloom.Visible;
game.bloom.Visible = true;
ExitScreen();
}

Expand Down
2 changes: 0 additions & 2 deletions ZombustersWindows/MenuScreens/MenuScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public override void Initialize() {
fontItalic = game.Content.Load<SpriteFont>(@"menu\ArialMusic");
fontSmallItalic = game.Content.Load<SpriteFont>(@"menu\ArialMusicItalic");
menu = new MenuComponent(game, MenuListFont);
//bloom = new BloomComponent(game);
menu.Initialize();
menu.AddText("WPPlayNewGame", "WPPlayNewGameMMString");
menu.AddText("ExtrasMenuString", "ExtrasMMString");
Expand All @@ -58,7 +57,6 @@ public override void Initialize() {
menu.MenuConfigSelected += new EventHandler<MenuSelection>(OnMenuConfigSelected);
//menu.MenuShowMarketplace += new EventHandler<MenuSelection>(OnShowMarketplace);
menu.CenterInXLeftMenu(view);
//bloom.Visible = !bloom.Visible;
game.isInMenu = true;
base.Initialize();
this.isBackgroundOn = true;
Expand Down
20 changes: 9 additions & 11 deletions ZombustersWindows/MyGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ public class MyGame : Game {
public StorageDataSource storageDataSource;
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;
public int maxGamers = 4;
Expand Down Expand Up @@ -76,15 +74,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]
};
Components.Add(bloom);
bloom.Settings = BloomSettings.PresetSettings[6];
bloom.Visible = true;
*/

bugSnagClient = new Client("1cad9818fb8d84290d776245cd1f948d");
//bugSnagClient.StartAutoNotify();

Expand Down Expand Up @@ -117,7 +114,7 @@ protected override void Initialize() {
if (i == 0) {
this.InitializeMain(PlayerIndex.One);
}
}
}
base.Initialize();
screenManager.AddScreen(new LogoScreen());
currentGameState = GameState.SignIn;
Expand Down Expand Up @@ -318,6 +315,7 @@ public void FailToMenu() {

public void QuitGame() {
playScreen = null;
bloom.Visible = true;
Reset();
bPaused = EndPause();
}
Expand Down
Loading