Improved LOS effect

It's pretty inefficient (I need to figure out how to set up new shaders), and it might let the player see too much, but it looks way better than pure black.
This commit is contained in:
juanjp600
2016-10-12 16:54:41 -03:00
parent 1cdb218fe0
commit 7e6ef65eb3
4 changed files with 68 additions and 12 deletions

View File

@@ -366,15 +366,15 @@ namespace Barotrauma.Lights
spriteBatch.End();
}
public void DrawLOS(SpriteBatch spriteBatch, Effect effect)
public void DrawLOS(SpriteBatch spriteBatch, Effect effect,bool renderingBackground)
{
if (!LosEnabled || ViewTarget == null) return;
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative, null, null, null, effect);
spriteBatch.Begin(SpriteSortMode.Deferred, renderingBackground ? CustomBlendStates.LOS : CustomBlendStates.Multiplicative, null, null, null, effect);
spriteBatch.Draw(losTexture, Vector2.Zero, Color.White);
spriteBatch.End();
ObstructVision = false;
if (!renderingBackground) ObstructVision = false;
}
public void ClearLights()
@@ -399,10 +399,16 @@ namespace Barotrauma.Lights
MultiplyWithAlpha = new BlendState();
MultiplyWithAlpha.ColorDestinationBlend = MultiplyWithAlpha.AlphaDestinationBlend = Blend.One;
MultiplyWithAlpha.ColorSourceBlend = MultiplyWithAlpha.AlphaSourceBlend = Blend.DestinationAlpha;
LOS = new BlendState();
LOS.ColorSourceBlend = LOS.AlphaSourceBlend = Blend.Zero;
LOS.ColorDestinationBlend = LOS.AlphaDestinationBlend = Blend.InverseSourceColor;
LOS.ColorBlendFunction = LOS.AlphaBlendFunction = BlendFunction.Add;
}
public static BlendState Multiplicative { get; private set; }
public static BlendState WriteToAlpha { get; private set; }
public static BlendState MultiplyWithAlpha { get; private set; }
public static BlendState LOS { get; private set; }
}
}

View File

@@ -307,15 +307,23 @@ namespace Barotrauma
if (MapEntity.mapEntityList[i].DrawDamageEffect)
MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect);
}
damageEffect.Parameters["aCutoff"].SetValue(0.0f);
damageEffect.Parameters["cCutoff"].SetValue(0.0f);
if (damageEffect != null)
{
damageEffect.Parameters["aCutoff"].SetValue(0.0f);
damageEffect.Parameters["cCutoff"].SetValue(0.0f);
}
}
public static void DrawBack(SpriteBatch spriteBatch, bool editing = false)
public static void DrawBack(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (predicate != null)
{
if (!predicate(MapEntity.mapEntityList[i])) continue;
}
if (MapEntity.mapEntityList[i].DrawBelowWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
}