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

Solved FX issues #27

Open
wants to merge 2 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
4 changes: 2 additions & 2 deletions ZombustersInstaller/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@

<Fragment>
<ComponentGroup Id="Content_fx_files" Directory="Content_fx">
<Component Id="Content_fx_BloomCombine.xnb" Guid="5295c0d7-ace1-4b64-989c-3f094a9cd6c9">
<!-- <Component Id="Content_fx_BloomCombine.xnb" Guid="5295c0d7-ace1-4b64-989c-3f094a9cd6c9">
<File Id="Content_fx_BloomCombine.xnb" Name="BloomCombine.xnb" Source="$(var.ZombustersWindows_TargetDir)Content\fx\BloomCombine.xnb" />
</Component>
<Component Id="Content_fx_BloomExtract.xnb" Guid="c15196b6-215e-4cd0-89dd-1425dc6593fa">
<File Id="Content_fx_BloomExtract.xnb" Name="BloomExtract.xnb" Source="$(var.ZombustersWindows_TargetDir)Content\fx\BloomExtract.xnb" />
</Component>
<Component Id="Content_fx_GaussianBlur.xnb" Guid="f5eac172-2535-4f15-ba01-7eaf13890a46">
<File Id="Content_fx_GaussianBlur.xnb" Name="GaussianBlur.xnb" Source="$(var.ZombustersWindows_TargetDir)Content\fx\GaussianBlur.xnb" />
</Component>
</Component> -->
</ComponentGroup>
</Fragment>

Expand Down
3 changes: 2 additions & 1 deletion ZombustersWindows/BloomPostProcess/BloomComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
#endregion

namespace ZombustersWindows
Expand Down Expand Up @@ -71,8 +72,8 @@ protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);

bloomExtractEffect = Game.Content.Load<Effect>("fx/BloomExtract");
bloomCombineEffect = Game.Content.Load<Effect>("fx/BloomCombine");
bloomExtractEffect = Game.Content.Load<Effect>("fx/BloomExtract");
gaussianBlurEffect = Game.Content.Load<Effect>("fx/GaussianBlur");

// Look up the resolution and format of our main backbuffer.
Expand Down
18 changes: 18 additions & 0 deletions ZombustersWindows/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -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

51 changes: 51 additions & 0 deletions ZombustersWindows/Content/fx/BloomCombine.fx
Original file line number Diff line number Diff line change
@@ -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();
}
}
Binary file added ZombustersWindows/Content/fx/BloomCombine.mgfxo
Binary file not shown.
25 changes: 25 additions & 0 deletions ZombustersWindows/Content/fx/BloomExtract.fx
Original file line number Diff line number Diff line change
@@ -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();
}
}
Binary file added ZombustersWindows/Content/fx/BloomExtract.mgfxo
Binary file not shown.
33 changes: 33 additions & 0 deletions ZombustersWindows/Content/fx/GaussianBlur.fx
Original file line number Diff line number Diff line change
@@ -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();
}
}
Binary file added ZombustersWindows/Content/fx/GaussianBlur.mgfxo
Binary file not shown.
14 changes: 7 additions & 7 deletions ZombustersWindows/MyGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -73,13 +73,13 @@ public class MyGame : Game {
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();

Expand All @@ -101,7 +101,7 @@ public class MyGame : Game {
Components.Add(musicComponent);
musicComponent.Enabled = true;


}

protected override void Initialize() {
Expand All @@ -114,7 +114,7 @@ public class MyGame : Game {
if (i == 0) {
this.InitializeMain(PlayerIndex.One);
}
}
}
base.Initialize();
screenManager.AddScreen(new LogoScreen());
currentGameState = GameState.SignIn;
Expand Down
12 changes: 3 additions & 9 deletions ZombustersWindows/ZombustersWindows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,6 @@
<Content Include="Content\Flame2.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\fx\BloomCombine.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\fx\BloomExtract.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\fx\GaussianBlur.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\InGame\burningzombie.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -1208,6 +1199,9 @@
<Content Include="Content\Music\ThisCo_TakeItAway.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Content\fx\BloomCombine.fx" />
<None Include="Content\fx\BloomExtract.fx" />
<None Include="Content\fx\GaussianBlur.fx" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down