diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx index 6742671c96..77470954e8 100644 --- a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx +++ b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx @@ -20,6 +20,7 @@ float2 renderTargetArea; float2 screenMoveOffset; float2 generalBackgroundOffset; bool invertedScreen; +float2 upscaleFactor; float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 { @@ -33,8 +34,8 @@ float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOO float4 color = tex2D(uImage0, coords); // Determine how much downscaling is required to reasonably zoom in on things. - float downscaleFactor = float2(5, 5) / max(renderTargetArea.x, renderTargetArea.y) / 2; - float2 backgroundCoords = frac((renderTargetArea * (originalCoords + generalBackgroundOffset) + uWorldPosition) * downscaleFactor); + float downscaleFactor = float2(5, 5) / upscaleFactor / max(renderTargetArea.x, renderTargetArea.y) / 2; + float2 backgroundCoords = frac((renderTargetArea * (originalCoords + generalBackgroundOffset * upscaleFactor) + uWorldPosition) * downscaleFactor); float4 backgroundColor = tex2D(uImage1, backgroundCoords); // Equivalent to edgeBorderSize pixels in both the X and Y direction. diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb index 6f38e1d526..ceff80f4eb 100644 Binary files a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb and b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb differ diff --git a/Particles/BaseFusableParticleSet.cs b/Particles/BaseFusableParticleSet.cs index f75d1c8a47..c68b0df0f8 100644 --- a/Particles/BaseFusableParticleSet.cs +++ b/Particles/BaseFusableParticleSet.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Particles Particles.RemoveAll(p => p.Size <= 5f); // Prepare the sprite batch for specialized drawing in prepration that the graphics device will to new render targets. - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); // Draw the surviving particles. DrawParticles(); diff --git a/Particles/GruesomeEminenceParticleSet.cs b/Particles/GruesomeEminenceParticleSet.cs index c9b6ef5754..1effede5e0 100644 --- a/Particles/GruesomeEminenceParticleSet.cs +++ b/Particles/GruesomeEminenceParticleSet.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Particles public override float BorderSize => 3f; public override bool BorderShouldBeSolid => false; public override Color BorderColor => Color.Lerp(Color.Fuchsia, Color.Black, 0.55f) * 0.85f; - public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverWater; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; // Cached for efficiency when loading textures and shaders. private static readonly List _backgroundShaders = new List() diff --git a/Projectiles/Magic/SmallSpirit.cs b/Projectiles/Magic/SmallSpirit.cs index 25f4dd6a2c..4a0b5b8997 100644 --- a/Projectiles/Magic/SmallSpirit.cs +++ b/Projectiles/Magic/SmallSpirit.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Magic // Die if close to the owner projectile, effectively being absorbed. projectile.Center = projectile.Center.MoveTowards(target.Center, 8.5f); - if (projectile.WithinRange(target.Center, 110f)) + if (projectile.WithinRange(target.Center, 80f)) projectile.Kill(); // Become translucent when returning to the projectile owner. diff --git a/Projectiles/Magic/SpiritCongregation.cs b/Projectiles/Magic/SpiritCongregation.cs index 7072bb5d81..d3c590f7ce 100644 --- a/Projectiles/Magic/SpiritCongregation.cs +++ b/Projectiles/Magic/SpiritCongregation.cs @@ -1,8 +1,10 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +18,7 @@ namespace CalamityMod.Projectiles.Magic public ref float DeathCounter => ref projectile.localAI[0]; public Player Owner => Main.player[projectile.owner]; public float CurrentPower => (float)Math.Pow(Utils.InverseLerp(15f, 840f, Time, true), 4D); - public float CongregationDiameter => MathHelper.SmoothStep(54f, 215f, CurrentPower); + public float CongregationDiameter => MathHelper.SmoothStep(54f, 145f, CurrentPower); public float MovementSpeed { get @@ -32,7 +34,6 @@ namespace CalamityMod.Projectiles.Magic return movementSpeed; } } - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { @@ -74,6 +75,7 @@ namespace CalamityMod.Projectiles.Magic DeathCounter++; if (DeathCounter >= 35f) projectile.Kill(); + projectile.scale = 1f - DeathCounter / 35f; projectile.velocity *= 0.98f; EmitGhostGas(); return; @@ -157,6 +159,7 @@ namespace CalamityMod.Projectiles.Magic // Approach the ideal velocity. projectile.velocity = projectile.velocity.MoveTowards(idealVelocity, MovementSpeed * 0.04f); projectile.velocity = (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; + projectile.rotation = projectile.velocity.ToRotation(); } public void ReleaseSmallSpirits() @@ -206,8 +209,51 @@ namespace CalamityMod.Projectiles.Magic } } - // Prevent obsence damage when hitting players. - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Vector2 backgroundOffset = Vector2.UnitX * Main.GlobalTime * 0.03f; + Texture2D texture = Main.projectileTexture[projectile.type]; + Texture2D backTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SpiritCongregationBack"); + Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1"); + Effect shader = GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader; + + Vector2 origin = backTexture.Size() * 0.5f; + float offsetFactor = projectile.scale * ((CongregationDiameter - 54f) / 90f + 1f); + Vector2 drawPosition = projectile.Center - Main.screenPosition + projectile.rotation.ToRotationVector2() * offsetFactor * 15f; + drawPosition += (projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * offsetFactor * 12f; + + // Draw the back with the specified shader. + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + shader.Parameters["edgeBorderSize"].SetValue(projectile.scale * 2f); + shader.Parameters["borderShouldBeSolid"].SetValue(FusableParticleManager.GetParticleSetByType().BorderShouldBeSolid); + shader.Parameters["edgeBorderColor"].SetValue(FusableParticleManager.GetParticleSetByType().BorderColor.ToVector3()); + shader.Parameters["screenArea"].SetValue(backTexture.Size() / Main.GameViewMatrix.Zoom); + shader.Parameters["screenMoveOffset"].SetValue(Vector2.Zero); + shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); + shader.Parameters["renderTargetArea"].SetValue(backTexture.Size()); + shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); + shader.Parameters["generalBackgroundOffset"].SetValue(backgroundOffset); + shader.Parameters["uWorldPosition"].SetValue(projectile.position); + shader.Parameters["uRotation"].SetValue(projectile.rotation); + shader.Parameters["upscaleFactor"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / backTexture.Size()); + + // Prepare the background texture for loading. + Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; + shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); + + shader.CurrentTechnique.Passes[0].Apply(); + + spriteBatch.Draw(backTexture, drawPosition, null, Color.White, projectile.rotation, origin, projectile.scale * 1.05f, SpriteEffects.None, 0f); + spriteBatch.ExitShaderRegion(); + + spriteBatch.Draw(texture, drawPosition, null, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } + + // Prevent obsence damage when hitting players. + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { damage = 92; } diff --git a/Projectiles/Magic/SpiritCongregation.png b/Projectiles/Magic/SpiritCongregation.png new file mode 100644 index 0000000000..831d85650d Binary files /dev/null and b/Projectiles/Magic/SpiritCongregation.png differ diff --git a/Projectiles/Magic/SpiritCongregationBack.png b/Projectiles/Magic/SpiritCongregationBack.png new file mode 100644 index 0000000000..2d66e95b81 Binary files /dev/null and b/Projectiles/Magic/SpiritCongregationBack.png differ