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"));
|
||||
}
|
||||
|
||||
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");
|
||||
Class1.effect.CurrentTechnique.Passes[0].Apply();
|
||||
if (Game1.player.currentLocation != null && Game1.activeClickableMenu==null)
|
||||
|
@ -58,6 +59,14 @@ namespace ShaderExample
|
|||
effect.Parameters["ambientRed"].SetValue(Game1.outdoorLight.R);
|
||||
effect.Parameters["ambientGreen"].SetValue(Game1.outdoorLight.G);
|
||||
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);
|
||||
}
|
||||
else
|
||||
|
@ -67,6 +76,13 @@ namespace ShaderExample
|
|||
effect.Parameters["ambientGreen"].SetValue(255f);
|
||||
effect.Parameters["ambientBlue"].SetValue(255f);
|
||||
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
|
||||
|
@ -75,6 +91,13 @@ namespace ShaderExample
|
|||
effect.Parameters["ambientGreen"].SetValue(255f);
|
||||
effect.Parameters["ambientBlue"].SetValue(255f);
|
||||
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();
|
||||
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);
|
||||
//drawMapPart2();
|
||||
applyCurrentShader();
|
||||
|
@ -141,9 +138,13 @@ namespace ShaderExample
|
|||
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);
|
||||
applyCurrentShader();
|
||||
Game1.player.currentLocation.drawAboveFrontLayer(Game1.spriteBatch);
|
||||
if (Game1.currentLocation.Map.GetLayer("AlwaysFront") != null)
|
||||
{
|
||||
Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch);
|
||||
|
@ -333,15 +334,29 @@ namespace ShaderExample
|
|||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||
applyCurrentShader(true);
|
||||
if(Game1.activeClickableMenu==null&& Game1.eventUp==false)getInvokeMethod(Program.gamePtr, "drawHUD", new object[] { });
|
||||
|
||||
if (Game1.hudMessages.Count > 0 && (!Game1.eventUp || Game1.isFestival()))
|
||||
{
|
||||
for (int i = Game1.hudMessages.Count - 1; i >= 0; --i)
|
||||
Game1.hudMessages[i].draw(Game1.spriteBatch, i);
|
||||
}
|
||||
|
||||
if (Game1.hudMessages.Count > 0 && (!Game1.eventUp || Game1.isFestival()))
|
||||
{
|
||||
for (int i = Game1.hudMessages.Count - 1; i >= 0; --i)
|
||||
Game1.hudMessages[i].draw(Game1.spriteBatch, i);
|
||||
}
|
||||
|
||||
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);
|
||||
applyCurrentShader(true);
|
||||
|
|
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>
|
||||
<Options>None</Options>
|
||||
<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>
|
||||
<BuildSuccessful>true</BuildSuccessful>
|
||||
<Settings>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -4,11 +4,16 @@ float ambientRed;
|
|||
float ambientGreen;
|
||||
float ambientBlue;
|
||||
|
||||
float addedRed;
|
||||
float addedGreen;
|
||||
float addedBlue;
|
||||
float addedAlpha;
|
||||
|
||||
float timeOfDay;
|
||||
|
||||
float4x4 MatrixTransform;
|
||||
|
||||
|
||||
bool addLightGlow;
|
||||
|
||||
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
|
||||
|
||||
color.rgb = Gray;
|
||||
return color;
|
||||
}
|
||||
else {
|
||||
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
|
||||
|
||||
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