Fixed damageshader ignoring sprite colors. Closes #212
This commit is contained in:
@@ -148,14 +148,17 @@ namespace Barotrauma
|
||||
{
|
||||
float newCutoff = Math.Min((sections[i].damage / prefab.Health), 0.65f);
|
||||
|
||||
if (Math.Abs(newCutoff - Submarine.DamageEffectCutoff) > 0.01f)
|
||||
if (Math.Abs(newCutoff - Submarine.DamageEffectCutoff) > 0.01f || color != Submarine.DamageEffectColor)
|
||||
{
|
||||
damageEffect.Parameters["aCutoff"].SetValue(newCutoff);
|
||||
damageEffect.Parameters["cCutoff"].SetValue(newCutoff * 1.2f);
|
||||
damageEffect.Parameters["color"].SetValue(color.ToVector4());
|
||||
|
||||
|
||||
damageEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
Submarine.DamageEffectCutoff = newCutoff;
|
||||
Submarine.DamageEffectColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public static float DamageEffectCutoff;
|
||||
public static Color DamageEffectColor;
|
||||
|
||||
public static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing = false)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; }
|
||||
Texture xStencil;
|
||||
sampler StencilSampler = sampler_state { Texture = <xStencil>; };
|
||||
|
||||
float4 color;
|
||||
|
||||
float aCutoff;
|
||||
float aMultiplier;
|
||||
@@ -14,9 +15,9 @@ float cMultiplier;
|
||||
|
||||
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float4 c = tex2D(TextureSampler, texCoord);
|
||||
float4 c = xTexture.Sample(TextureSampler, texCoord) * color;
|
||||
|
||||
float4 stencilColor = tex2D(StencilSampler, texCoord);
|
||||
float4 stencilColor = xStencil.Sample(StencilSampler, texCoord);
|
||||
|
||||
float aDiff = stencilColor.a - aCutoff;
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user