diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index e244ab9f98..6b1c44e2da 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Effects public static Effect BasicTintShader; public static Effect DoGDisintegrationShader; public static Effect ArtAttackTrailShader; + public static Effect CircularAoETelegraph; public static Effect BaseFusableParticleEdgeShader; public static Effect AdditiveFusableParticleEdgeShader; @@ -57,6 +58,7 @@ namespace CalamityMod.Effects BasicTintShader = CalamityMod.Instance.GetEffect("Effects/BasicTint"); DoGDisintegrationShader = CalamityMod.Instance.GetEffect("Effects/DoGDisintegration"); ArtAttackTrailShader = CalamityMod.Instance.GetEffect("Effects/ArtAttackTrail"); + CircularAoETelegraph = CalamityMod.Instance.GetEffect("Effects/CircularAoETelegraph"); BaseFusableParticleEdgeShader = CalamityMod.Instance.GetEffect("Effects/ParticleFusion/BaseFusableParticleEdgeShader"); AdditiveFusableParticleEdgeShader = CalamityMod.Instance.GetEffect("Effects/ParticleFusion/AdditiveFusableParticleEdgeShader"); @@ -85,6 +87,7 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:BasicTint"] = new MiscShaderData(new Ref(BasicTintShader), "TintPass"); GameShaders.Misc["CalamityMod:DoGDisintegration"] = new MiscShaderData(new Ref(DoGDisintegrationShader), "DisintegrationPass"); GameShaders.Misc["CalamityMod:ArtAttack"] = new MiscShaderData(new Ref(ArtAttackTrailShader), "TrailPass"); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"] = new MiscShaderData(new Ref(CircularAoETelegraph), "TelegraphPass"); GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"] = new MiscShaderData(new Ref(BaseFusableParticleEdgeShader), "ParticlePass"); GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"] = new MiscShaderData(new Ref(AdditiveFusableParticleEdgeShader), "ParticlePass"); diff --git a/Effects/CircularAoETelegraph.fx b/Effects/CircularAoETelegraph.fx new file mode 100644 index 0000000000..fe5cddcf51 --- /dev/null +++ b/Effects/CircularAoETelegraph.fx @@ -0,0 +1,57 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; //Color of the telegraph zone +float3 uSecondaryColor; //Color of the outline +float uOpacity; +float uSaturation; //Saturation is being used as completion here. 0 = Telegraph start, 1 = Telegraph about to end +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + + +float4 Recolor(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + float3 color = uColor; + //this is the center of the sprite, coords work from 0 - 1 + float2 center = float2(0.5, 0.5); + //get the length of the doubled distance, so that 0 = at the center of the sprite and 1 = at the very edge of the circle + float distanceFromCenter = length(coords - center) * 2; + + //Crop the sprite into a circle + if (distanceFromCenter > 1) + return float4(0, 0, 0, 0); + + //Make the brightness increase towards the edge + float opacity = 0.1 + (0.2 + 0.35 * pow(uSaturation, 2)) * distanceFromCenter; + + //Brighten the very edge + if (distanceFromCenter > 0.995) + { + //Make the color get closer to the outline color. At halfway completion the transition is complete (so proud of them) + color = lerp(color, uSecondaryColor, min(uSaturation * 2, 1)); + + //Do the same for the opacity + opacity = lerp(opacity, 1, pow(uSaturation, 2)) * lerp(uOpacity, 1, min(uSaturation * 1.25, min(uOpacity + 0.1, 1))); + } + + else + opacity = opacity * uOpacity; + + color = color * opacity; + + return float4(color, opacity); +} + + +technique Technique1 +{ + pass TelegraphPass + { + PixelShader = compile ps_2_0 Recolor(); + } +} \ No newline at end of file diff --git a/Effects/CircularAoETelegraph.xnb b/Effects/CircularAoETelegraph.xnb new file mode 100644 index 0000000000..8b1186f3ed Binary files /dev/null and b/Effects/CircularAoETelegraph.xnb differ diff --git a/Projectiles/Boss/AresGaussNukeProjectile.cs b/Projectiles/Boss/AresGaussNukeProjectile.cs index 114241ce62..9ac68c817d 100644 --- a/Projectiles/Boss/AresGaussNukeProjectile.cs +++ b/Projectiles/Boss/AresGaussNukeProjectile.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -142,6 +143,21 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { + spriteBatch.EnterShaderRegion(); + Texture2D telegraphBase = ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"); + + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseOpacity(0.4f * MathHelper.Clamp((1 - projectile.timeLeft / (float)timeLeft) * 8f, 0, 1)); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseColor(Color.Lerp(Color.Goldenrod, Color.Gold, 0.7f * (float)Math.Pow(0.5 + 0.5 * Math.Sin(Main.GlobalTime), 3))); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSecondaryColor(Color.Lerp(Color.Yellow, Color.White, 0.5f)); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSaturation(1 - projectile.timeLeft / (float)timeLeft); + + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].Apply(); + + Vector2 drawPosition = projectile.Center - Main.screenPosition; + spriteBatch.Draw(telegraphBase, drawPosition, null, lightColor, 0, telegraphBase.Size() / 2f, 1070f, 0, 0); + spriteBatch.ExitShaderRegion(); + + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; }