diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 553b0d522d..dc0b5ec13b 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -115,6 +115,11 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"] = new MiscShaderData(new Ref(AdditiveFusableParticleEdgeShader), "ParticlePass"); GameShaders.Misc["CalamityMod:DoGPortal"] = new MiscShaderData(new Ref(DoGPortalShader), "ScreenPass"); + + //A little experimenting courtesy of looking at how slr does it. + var screenRef = new Ref(CalamityMod.Instance.Assets.Request("Effects/SpreadTelegraph", AssetRequestMode.ImmediateLoad).Value); + Filters.Scene["SpreadTelegraph"] = new Filter(new ScreenShaderData(screenRef, "TelegraphPass"), EffectPriority.High); + Filters.Scene["SpreadTelegraph"].Load(); } } } diff --git a/Effects/Compiler/EasyXnb.exe b/Effects/Compiler/EasyXnb.exe new file mode 100644 index 0000000000..3a5af70705 Binary files /dev/null and b/Effects/Compiler/EasyXnb.exe differ diff --git a/Effects/Compiler/EasyXnb.exe.config b/Effects/Compiler/EasyXnb.exe.config new file mode 100644 index 0000000000..9527be5fdc --- /dev/null +++ b/Effects/Compiler/EasyXnb.exe.config @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll new file mode 100644 index 0000000000..61f52fa6c5 Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll differ diff --git a/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll new file mode 100644 index 0000000000..bf8aeb3c6a Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll differ diff --git a/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll new file mode 100644 index 0000000000..396392c053 Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll differ diff --git a/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.dll b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.dll new file mode 100644 index 0000000000..a70e4120a2 Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.Content.Pipeline.dll differ diff --git a/Effects/Compiler/Microsoft.Xna.Framework.Game.dll b/Effects/Compiler/Microsoft.Xna.Framework.Game.dll new file mode 100644 index 0000000000..9ba4aa23b3 Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.Game.dll differ diff --git a/Effects/Compiler/Microsoft.Xna.Framework.Graphics.dll b/Effects/Compiler/Microsoft.Xna.Framework.Graphics.dll new file mode 100644 index 0000000000..2c00c4ccbe Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.Graphics.dll differ diff --git a/Effects/Compiler/Microsoft.Xna.Framework.dll b/Effects/Compiler/Microsoft.Xna.Framework.dll new file mode 100644 index 0000000000..a0caf6af26 Binary files /dev/null and b/Effects/Compiler/Microsoft.Xna.Framework.dll differ diff --git a/Effects/SpreadTelegraph.fx b/Effects/SpreadTelegraph.fx new file mode 100644 index 0000000000..eea200f02a --- /dev/null +++ b/Effects/SpreadTelegraph.fx @@ -0,0 +1,91 @@ +float3 edgeColor; +float3 centerColor; + +float edgeBlendLenght; +float edgeBlendStrength; + +float mainOpacity; +float centerOpacity; +float halfSpreadAngle; + +texture sampleTexture; +sampler2D Texture1Sampler = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; + + +//I can't believe it has gotten down to this. +float realCos(float value) +{ + return sin(value + 1.57079); +} + +//Gets the distance of a plot from a line with a specified origin and angle +float distanceFromLine(float2 origin, float angle, float2 plot) +{ + return abs(realCos(angle) * (origin.y - plot.y) - sin(angle) * (origin.x - plot.x)); +} + +//Gets the distance of a plot from a line with a specified origin and angle, but crops the line so it only expands towards the angle +float distanceFromLineCropped(float2 origin, float angle, float2 plot, float plotAngle) +{ + //If the angle between the line's angle and the plot's angle is less than 90° (aka , not BEHIND the half-line), return the distance from the line + if (abs(angle - plotAngle) < 1.5707) + return distanceFromLine(origin, angle, plot); + + //If we are behind the line, just give the distance between the start point and the plot + else + return length(origin - plot); + +} + + +float4 main(float2 uv : TEXCOORD) : COLOR +{ + //Set the uv's Y position to be only contained within the upper half of the texture, to mirror it around a horizontal axis + if (uv.y > 0.5) + uv.y = 1 - uv.y; + + float2 mappedUv = float2(uv.x - 0.5, abs(uv.y - 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(mappedUv) * 2; + + //Crop the sprite into a circle + if (distanceFromCenter > 1) + return float4(0, 0, 0, 0); + + //Grabs the angle (only as a positive angle, since it's a mirror image udnerneath. + float angle = atan2(mappedUv.y, mappedUv.x); + //Grabs the distance of the point from the edge line. + float distanceFromLine = distanceFromLineCropped(float2(0, 0), halfSpreadAngle, mappedUv, angle); + + //Grab the colors to blend the edge lines with. + float3 colour = float3(0, 0, 0); + float opacity = 0; + //If we are inside the spread's radius. + if (angle <= halfSpreadAngle) + { + colour = lerp(centerColor, edgeColor, pow(angle / halfSpreadAngle, 9)); + opacity = centerOpacity * pow(1 - distanceFromCenter, 2); + } + + //If we are further from the line than the edge's blending lenght, just don't even do the blending. + if (distanceFromLine > edgeBlendLenght) + return float4(colour * opacity * mainOpacity, opacity * mainOpacity); + + //The higher this value is, the more we blend with the edge's opacity & color. + float edgeBlendFactor = pow(1 - distanceFromLine / edgeBlendLenght, edgeBlendStrength); + + colour = lerp(colour, edgeColor, edgeBlendFactor); + opacity = lerp(opacity, 1 * pow(1 - distanceFromCenter, 3), edgeBlendFactor) * mainOpacity; + + colour = colour * opacity; + return float4(colour, opacity); +} + +technique Technique1 +{ + pass TelegraphPass + { + PixelShader = compile ps_3_0 main(); + } +} \ No newline at end of file diff --git a/Effects/SpreadTelegraph.xnb b/Effects/SpreadTelegraph.xnb new file mode 100644 index 0000000000..e752b000ce Binary files /dev/null and b/Effects/SpreadTelegraph.xnb differ diff --git a/Projectiles/Magic/CoralSpoutHoldout.cs b/Projectiles/Magic/CoralSpoutHoldout.cs index 30c538fd6a..f8d2a01ed2 100644 --- a/Projectiles/Magic/CoralSpoutHoldout.cs +++ b/Projectiles/Magic/CoralSpoutHoldout.cs @@ -7,6 +7,8 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Graphics.Effects; +using Terraria.Graphics.Shaders; namespace CalamityMod.Projectiles.Magic @@ -82,17 +84,23 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { + + var effect = Filters.Scene["SpreadTelegraph"].GetShader().Shader; + effect.Parameters["centerOpacity"].SetValue(0.7f); + effect.Parameters["mainOpacity"].SetValue((float)Math.Sqrt(ChargeProgress)); + effect.Parameters["halfSpreadAngle"].SetValue(Spread / 2f); + effect.Parameters["edgeColor"].SetValue(Color.DeepSkyBlue.ToVector3()); + effect.Parameters["centerColor"].SetValue(Color.DodgerBlue.ToVector3()); + effect.Parameters["edgeBlendLenght"].SetValue(0.07f); + effect.Parameters["edgeBlendStrength"].SetValue(8f); + Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; - Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Summon/DeathstareBeam").Value; - - for (int i = -1; i <= 1; i += 2) - { - float angle = (Owner.MountedCenter - Owner.Calamity().mouseWorld).ToRotation() + (Spread / 2f) * i - MathHelper.PiOver2; - Vector2 scale = new Vector2(0.2f, 1f) * 3f; - Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.DodgerBlue * 0.5f * (float)Math.Sqrt(ChargeProgress), angle, new Vector2(texture.Width / 2f, texture.Height), scale, 0, 0); - } + float angle = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation(); + Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.White, angle, new Vector2(texture.Width / 2f, texture.Height/2f), 700f, 0, 0); Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); @@ -111,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < ShotProjectiles; i++) { - float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / (float)ShotProjectiles); + float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / ((float)ShotProjectiles - 1)); Vector2 direction = (mainAngle + angleOffset).ToRotationVector2(); if (Owner.whoAmI == Main.myPlayer)