Added in light glows!!!!
This commit is contained in:
parent
50f84167aa
commit
808e44fff7
|
@ -42,8 +42,9 @@ namespace ShaderExample
|
||||||
effect = Helper.Content.Load<Effect>(Path.Combine("Content", "Shaders", "GreyScaleEffect.xnb"));
|
effect = Helper.Content.Load<Effect>(Path.Combine("Content", "Shaders", "GreyScaleEffect.xnb"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyCurrentShader(bool ignoreOutdoorLight=false)
|
public void applyCurrentShader(bool ignoreOutdoorLight = false,bool addLightGlow=false,int r=0, int g=0, int b=0,int a=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
|
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
|
||||||
Class1.effect.CurrentTechnique.Passes[0].Apply();
|
Class1.effect.CurrentTechnique.Passes[0].Apply();
|
||||||
if (Game1.player.currentLocation != null && Game1.activeClickableMenu==null)
|
if (Game1.player.currentLocation != null && Game1.activeClickableMenu==null)
|
||||||
|
@ -58,6 +59,14 @@ namespace ShaderExample
|
||||||
effect.Parameters["ambientRed"].SetValue(Game1.outdoorLight.R);
|
effect.Parameters["ambientRed"].SetValue(Game1.outdoorLight.R);
|
||||||
effect.Parameters["ambientGreen"].SetValue(Game1.outdoorLight.G);
|
effect.Parameters["ambientGreen"].SetValue(Game1.outdoorLight.G);
|
||||||
effect.Parameters["ambientBlue"].SetValue(Game1.outdoorLight.B);
|
effect.Parameters["ambientBlue"].SetValue(Game1.outdoorLight.B);
|
||||||
|
|
||||||
|
effect.Parameters["addLightGlow"].SetValue(addLightGlow);
|
||||||
|
|
||||||
|
effect.Parameters["addedRed"].SetValue(r);
|
||||||
|
effect.Parameters["addedGreen"].SetValue(g);
|
||||||
|
effect.Parameters["addedBlue"].SetValue(b);
|
||||||
|
effect.Parameters["addedAlpha"].SetValue(b);
|
||||||
|
|
||||||
effect.Parameters["timeOfDay"].SetValue(Game1.timeOfDay);
|
effect.Parameters["timeOfDay"].SetValue(Game1.timeOfDay);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -67,6 +76,13 @@ namespace ShaderExample
|
||||||
effect.Parameters["ambientGreen"].SetValue(255f);
|
effect.Parameters["ambientGreen"].SetValue(255f);
|
||||||
effect.Parameters["ambientBlue"].SetValue(255f);
|
effect.Parameters["ambientBlue"].SetValue(255f);
|
||||||
effect.Parameters["timeOfDay"].SetValue(600f);
|
effect.Parameters["timeOfDay"].SetValue(600f);
|
||||||
|
|
||||||
|
effect.Parameters["addLightGlow"].SetValue(addLightGlow);
|
||||||
|
|
||||||
|
effect.Parameters["addedRed"].SetValue(r);
|
||||||
|
effect.Parameters["addedGreen"].SetValue(g);
|
||||||
|
effect.Parameters["addedBlue"].SetValue(b);
|
||||||
|
effect.Parameters["addedAlpha"].SetValue(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -75,6 +91,13 @@ namespace ShaderExample
|
||||||
effect.Parameters["ambientGreen"].SetValue(255f);
|
effect.Parameters["ambientGreen"].SetValue(255f);
|
||||||
effect.Parameters["ambientBlue"].SetValue(255f);
|
effect.Parameters["ambientBlue"].SetValue(255f);
|
||||||
effect.Parameters["timeOfDay"].SetValue(600f);
|
effect.Parameters["timeOfDay"].SetValue(600f);
|
||||||
|
|
||||||
|
effect.Parameters["addLightGlow"].SetValue(addLightGlow);
|
||||||
|
|
||||||
|
effect.Parameters["addedRed"].SetValue(r);
|
||||||
|
effect.Parameters["addedGreen"].SetValue(g);
|
||||||
|
effect.Parameters["addedBlue"].SetValue(b);
|
||||||
|
effect.Parameters["addedAlpha"].SetValue(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,32 +131,6 @@ namespace ShaderExample
|
||||||
drawMapPart1();
|
drawMapPart1();
|
||||||
Game1.spriteBatch.End();
|
Game1.spriteBatch.End();
|
||||||
|
|
||||||
/*
|
|
||||||
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
|
||||||
Framework.Drawers.Characters.drawFarmer();
|
|
||||||
Framework.Drawers.Characters.drawCharacters();
|
|
||||||
|
|
||||||
foreach (var v in Game1.player.currentLocation.terrainFeatures)
|
|
||||||
{
|
|
||||||
var value = v.Values;
|
|
||||||
var keys = v.Keys;
|
|
||||||
int index = 0;
|
|
||||||
foreach(var terrain in value)
|
|
||||||
{
|
|
||||||
terrain.draw(Game1.spriteBatch, keys.ElementAt(index));
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Game1.spriteBatch.End();
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Game1.spriteBatch.End();
|
|
||||||
|
|
||||||
//Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
|
||||||
//drawFront();
|
|
||||||
|
|
||||||
//The perfect map draw order.
|
|
||||||
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||||
//drawMapPart2();
|
//drawMapPart2();
|
||||||
applyCurrentShader();
|
applyCurrentShader();
|
||||||
|
@ -141,9 +138,13 @@ namespace ShaderExample
|
||||||
Game1.spriteBatch.End();
|
Game1.spriteBatch.End();
|
||||||
|
|
||||||
|
|
||||||
|
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||||
|
applyCurrentShader(false);
|
||||||
|
Game1.player.currentLocation.drawAboveFrontLayer(Game1.spriteBatch);
|
||||||
|
Game1.spriteBatch.End();
|
||||||
|
|
||||||
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||||
applyCurrentShader();
|
applyCurrentShader();
|
||||||
Game1.player.currentLocation.drawAboveFrontLayer(Game1.spriteBatch);
|
|
||||||
if (Game1.currentLocation.Map.GetLayer("AlwaysFront") != null)
|
if (Game1.currentLocation.Map.GetLayer("AlwaysFront") != null)
|
||||||
{
|
{
|
||||||
Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch);
|
Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch);
|
||||||
|
@ -343,6 +344,20 @@ namespace ShaderExample
|
||||||
Game1.spriteBatch.End();
|
Game1.spriteBatch.End();
|
||||||
|
|
||||||
|
|
||||||
|
for (int index = 0; index < Game1.currentLightSources.Count; ++index)
|
||||||
|
{
|
||||||
|
if (Utility.isOnScreen((Vector2)(Game1.currentLightSources.ElementAt<LightSource>(index).position), (int)((double)(float)(Game1.currentLightSources.ElementAt<LightSource>(index).radius) * 64.0 * 4.0)))
|
||||||
|
{
|
||||||
|
//Game1.spriteBatch.Draw(Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture, Game1.GlobalToLocal(Game1.viewport, (Vector2)(Game1.currentLightSources.ElementAt<LightSource>(index).position)) / (float)(Game1.options.lightingQuality / 2), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture.Bounds), (Color)(Game1.currentLightSources.ElementAt<LightSource>(index).color), 0.0f, new Vector2((float)Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture.Bounds.Center.X, (float)Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture.Bounds.Center.Y), (float)(Game1.currentLightSources.ElementAt<LightSource>(index).radius) / (float)(Game1.options.lightingQuality / 2), SpriteEffects.None, 0.9f);
|
||||||
|
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||||
|
Color c = (Color)(Game1.currentLightSources.ElementAt<LightSource>(index).color);
|
||||||
|
applyCurrentShader(false,true,0,0,0);
|
||||||
|
Game1.spriteBatch.Draw(Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture, Game1.GlobalToLocal(Game1.viewport, (Vector2)(Game1.currentLightSources.ElementAt<LightSource>(index).position)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture.Bounds), (Color)(Game1.currentLightSources.ElementAt<LightSource>(index).color.Value), 0.0f, new Vector2((float)Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture.Bounds.Center.X, (float)Game1.currentLightSources.ElementAt<LightSource>(index).lightTexture.Bounds.Center.Y), (float)(Game1.currentLightSources.ElementAt<LightSource>(index).radius/2), SpriteEffects.None, 0.9f);
|
||||||
|
Game1.spriteBatch.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||||
applyCurrentShader(true);
|
applyCurrentShader(true);
|
||||||
drawMouse();
|
drawMouse();
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -17,7 +17,7 @@
|
||||||
<Processor>EffectProcessor</Processor>
|
<Processor>EffectProcessor</Processor>
|
||||||
<Options>None</Options>
|
<Options>None</Options>
|
||||||
<Output>C:\Users\iD Student\Desktop\Stardew\WindowsGame2\WindowsGame2\WindowsGame2\bin\x86\Debug\Content\GreyScaleEffect.xnb</Output>
|
<Output>C:\Users\iD Student\Desktop\Stardew\WindowsGame2\WindowsGame2\WindowsGame2\bin\x86\Debug\Content\GreyScaleEffect.xnb</Output>
|
||||||
<Time>2018-07-19T21:12:39.9018516-07:00</Time>
|
<Time>2018-07-20T00:29:12.9095899-07:00</Time>
|
||||||
</Item>
|
</Item>
|
||||||
<BuildSuccessful>true</BuildSuccessful>
|
<BuildSuccessful>true</BuildSuccessful>
|
||||||
<Settings>
|
<Settings>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -4,11 +4,16 @@ float ambientRed;
|
||||||
float ambientGreen;
|
float ambientGreen;
|
||||||
float ambientBlue;
|
float ambientBlue;
|
||||||
|
|
||||||
|
float addedRed;
|
||||||
|
float addedGreen;
|
||||||
|
float addedBlue;
|
||||||
|
float addedAlpha;
|
||||||
|
|
||||||
float timeOfDay;
|
float timeOfDay;
|
||||||
|
|
||||||
float4x4 MatrixTransform;
|
float4x4 MatrixTransform;
|
||||||
|
|
||||||
|
bool addLightGlow;
|
||||||
|
|
||||||
float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
|
float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
|
||||||
{
|
{
|
||||||
|
@ -22,7 +27,6 @@ float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
|
||||||
float Gray = (r * 0.3 + g * 0.59 + b * 0.11); //.3,.59,.11
|
float Gray = (r * 0.3 + g * 0.59 + b * 0.11); //.3,.59,.11
|
||||||
|
|
||||||
color.rgb = Gray;
|
color.rgb = Gray;
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float r = color.r*(ambientRed / 255);
|
float r = color.r*(ambientRed / 255);
|
||||||
|
@ -32,8 +36,23 @@ float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
|
||||||
float Gray = (r * 0.11 + g * 0.11 + b * 0.78); //.3,.59,.11
|
float Gray = (r * 0.11 + g * 0.11 + b * 0.78); //.3,.59,.11
|
||||||
|
|
||||||
color.rgb = Gray;
|
color.rgb = Gray;
|
||||||
return color;
|
//Used for night glow
|
||||||
|
[flatten]if (addLightGlow == true) {
|
||||||
|
color.r = color.r * 3;
|
||||||
|
color.g = color.g * 3;
|
||||||
|
color.b = color.b * 3;
|
||||||
|
color.a = color.a*0.25;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
color.r = color.r + addedRed;
|
||||||
|
color.g = color.g + addedGreen;
|
||||||
|
color.b = color.b + addedBlue;
|
||||||
|
color.a = color.a + addedAlpha;
|
||||||
|
return color;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue