DoGTeleportRift visual redo

- Redid the visuals of DoGTeleportRift entirely
- Moved all visual management for DoG's fight from DoGWorldVisualChangesManager to DoGVisualsManager. Additionally, also made the class its own file rather than being attached to DoGSky's file.
- Created a new foreground Distortion target for DoGDistortionMetaball and DoGRiftCrack
- Adjusted CircularOpacityShader
- Changed the display name of DoGTeleportRift from "Rift" to "DoG Distortion Rift"
This commit is contained in:
fryzahh committed 2025-07-06 12:02:05 -04:00
1 parent 6efe81e154
commit eb2811ea9e
9 files changed
+914 -275

No files matched your search

+5 -3
View File
@@ -2,6 +2,7 @@
float opacityCutoffValue;
float fadeoutPower;
float overallOpacity;
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0
{
@@ -14,9 +15,10 @@ float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD
float4 color = tex2D(baseTexture, coords);
// Fade out from the edges of the texture to the middle depending on the cutoff value.
color.rgba *= pow(-polarCoords.y + opacityCutoffValue, fadeoutPower);
return color * sampleColor;
if (-polarCoords.y < opacityCutoffValue)
color.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower);
return color * sampleColor * overallOpacity;
}
technique Technique1
Binary file not shown.
+106
View File
@@ -0,0 +1,106 @@
using System.Collections.Generic;
using CalamityMod.Effects;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Systems.Graphic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Graphics.Metaballs
{
public class DoGDistortionMetaball : Metaball
{
public class DistortionParticle(Vector2 center, Vector2 velocity, float size, bool square = false, float rotation = 0f)
{
public Vector2 Center = center;
public Vector2 Velocity = velocity;
public float Size = size;
public bool Square = square;
public float Rotation = rotation;
public void Update()
{
Center += Velocity;
Velocity *= 0.96f;
Size *= 0.91f;
}
}
public static List<DistortionParticle> Particles { get; private set; } = [];
public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles;
public override bool AnythingToDraw => Particles.Count > 0 || CalamityUtils.AnyProjectiles(ModContent.ProjectileType<DoGRiftCrack>());
public override Color EdgeColor => new(136, 26, 186);
public override IEnumerable<Texture2D> Layers
{
get
{
yield return ModContent.Request<Texture2D>("CalamityMod/Projectiles/InvisibleProj").Value;
}
}
public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, bool square = false, float rotation = 0f) =>
Particles.Add(new(position, velocity, size, square, rotation));
public override void Update()
{
for (int i = 0; i < Particles.Count; i++)
Particles[i].Update();
Particles.RemoveAll(p => p.Size <= 2f);
}
public override void PrepareShaderForTarget(int layerIndex)
{
var metaballShader = CalamityShaders.MetaballEdgeShader;
var gd = Main.instance.GraphicsDevice;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
Vector2 layerScrollOffset = Main.screenPosition / screenSize + CalculateManualOffsetForLayer(layerIndex);
if (FixedToScreen)
layerScrollOffset = Vector2.Zero;
metaballShader.Parameters["layerSize"]?.SetValue(DoGVisualsManager.DistortionForegroundContentsTarget.Target.Size());
metaballShader.Parameters["screenSize"]?.SetValue(screenSize);
metaballShader.Parameters["layerOffset"]?.SetValue(layerScrollOffset);
metaballShader.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4());
metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize);
gd.Textures[1] = DoGVisualsManager.DistortionForegroundContentsTarget;
gd.SamplerStates[1] = SamplerState.LinearWrap;
metaballShader.CurrentTechnique.Passes[0].Apply();
}
public override void DrawInstances()
{
Texture2D metaballTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BasicCircle").Value;
Texture2D squareTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/Square").Value;
foreach (DistortionParticle particle in Particles)
{
Texture2D textureToUse = particle.Square ? squareTexture : metaballTexture;
Vector2 drawPosition = particle.Center - Main.screenPosition;
Vector2 origin = textureToUse.Size() * 0.5f;
Vector2 scale = Vector2.One * particle.Size / textureToUse.Size();
Main.spriteBatch.Draw(textureToUse, drawPosition, null, Color.White, particle.Rotation, origin, scale, SpriteEffects.None, 0f);
}
foreach (Projectile proj in Main.ActiveProjectiles)
{
if (proj.type == ModContent.ProjectileType<DoGRiftCrack>())
{
Color lightColor = Color.White;
proj.ModProjectile.PreDraw(ref lightColor);
}
}
}
}
}
@@ -55,7 +55,8 @@ DoGFire.DisplayName: Death Fire
DoGLaserWalls.DisplayName: God's Bane Doombeam Array
DoGLaserWallsBigBeam.DisplayName: Hyperdeath Rift Ripper
DoGP1EndPortal.DisplayName: Portal
DoGTeleportRift.DisplayName: Rift
DoGRiftCrack.DisplayName: DoG Distortion Crack
DoGTeleportRift.DisplayName: DoG Distortion Rift
DoGWingdings.DisplayName: Ramblings of Wing DoGster
DraedonSummonLaser.DisplayName: Giant Fuck-off Deathray of Doom
DyingSun.DisplayName: Dying Sun
+19 -39
View File
@@ -485,11 +485,7 @@ namespace CalamityMod.NPCs.DevourerofGods
float timeWhenDoGShouldTeleportDuringPhase2Countdown = 61f;
if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + (death ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal))
SpawnTeleportLocation(player, true);
if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 30)
{
Particle pulse = new DirectionalPulseRing(GetRiftLocationSafe(), Vector2.Zero, Color.Orchid, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 6f, 0f, 30);
GeneralParticleHandler.SpawnParticle(pulse);
}
if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown)
Teleport(player, bossRush, death, revenge, expertMode, phase5);
@@ -640,13 +636,6 @@ namespace CalamityMod.NPCs.DevourerofGods
if (teleportTimer > 0)
{
teleportTimer--;
if (teleportTimer == 30)
{
Particle pulse = new DirectionalPulseRing(GetRiftLocationSafe(), Vector2.Zero, Color.Orchid, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 6f, 0f, 30);
GeneralParticleHandler.SpawnParticle(pulse);
}
// Teleport
if (teleportTimer == 0)
Teleport(player, bossRush, death, revenge, expertMode, phase5);
}
@@ -693,7 +682,7 @@ namespace CalamityMod.NPCs.DevourerofGods
// Disable teleports
if (teleportTimer > 0)
{
GetRiftLocation(false);
GetRiftLocation();
teleportTimer = 0;
}
}
@@ -2135,16 +2124,26 @@ namespace CalamityMod.NPCs.DevourerofGods
int randomRange = Main.zenithWorld ? 960 : 48;
float distance = 500f;
Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1));
Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType<DoGTeleportRift>(), 0, 0f, Main.myPlayer, NPC.whoAmI);
int rift = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType<DoGTeleportRift>(), 0, 0f, Main.myPlayer, NPC.whoAmI);
if (Main.projectile.IndexInRange(rift))
{
int timeForPhaseTransition = ((CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal);
Main.projectile[rift].ModProjectile<DoGTeleportRift>().RiftLifetime = phase2Transition ? timeForPhaseTransition : teleportTimer;
}
// GFB, spawn a ton of fake rifts alongside the real one.
if (Main.zenithWorld)
{
// Fake portals galore
randomRange = 2000;
for (int k = 0; k < 35; k++)
{
targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1));
Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType<DoGTeleportRift>(), 0, 0f, Main.myPlayer, NPC.whoAmI, ai2: 1f);
int faker = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType<DoGTeleportRift>(), 0, 0f, Main.myPlayer, NPC.whoAmI);
if (Main.projectile.IndexInRange(faker))
{
Main.projectile[faker].ModProjectile<DoGTeleportRift>().FakeRift = true;
Main.projectile[faker].ModProjectile<DoGTeleportRift>().RiftLifetime = teleportTimer;
}
}
}
}
@@ -2152,7 +2151,7 @@ namespace CalamityMod.NPCs.DevourerofGods
private void Teleport(Player player, bool bossRush, bool death, bool revenge, bool expertMode, bool phase5)
{
Vector2 newPosition = GetRiftLocation(true);
Vector2 newPosition = GetRiftLocation();
if ((!AwaitingPhase2Teleport && (player.dead || !player.active)) || newPosition == default)
return;
@@ -2326,28 +2325,7 @@ namespace CalamityMod.NPCs.DevourerofGods
DeathAnimationTimer++;
}
private Vector2 GetRiftLocation(bool spawnDust)
{
Vector2 realSpot = default;
foreach (Projectile proj in Main.ActiveProjectiles)
{
if (proj.type == ModContent.ProjectileType<DoGTeleportRift>())
{
if (!spawnDust)
proj.ai[0] = -1f;
proj.Kill();
if (proj.ai[2] == 1f)
continue;
realSpot = proj.Center;
}
}
return realSpot;
}
private Vector2 GetRiftLocationSafe()
private Vector2 GetRiftLocation()
{
Vector2 realSpot = default;
foreach (Projectile proj in Main.ActiveProjectiles)
@@ -2355,6 +2333,8 @@ namespace CalamityMod.NPCs.DevourerofGods
if (proj.type == ModContent.ProjectileType<DoGTeleportRift>())
{
realSpot = proj.Center;
// Safeguard for if the rift doesn't activate at its designated time.
proj.ModProjectile<DoGTeleportRift>().SwitchAIStates();
}
}
return realSpot;
+84
View File
@@ -0,0 +1,84 @@
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class DoGRiftCrack : ModProjectile
{
public Vector2[] CrackPoints;
public ref float Timer => ref Projectile.ai[0];
public ref float MaxWidth => ref Projectile.ai[1];
public new string LocalizationCategory => "Projectiles.Boss";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = Projectile.height = 30;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 30;
}
public override void AI()
{
float minDistanceBetweenPoints = 25f;
float maxDistanceBetweenPoints = 50f;
if (CrackPoints is null)
{
CrackPoints = new Vector2[25];
Vector2 startingPosition = Projectile.Center;
for (int i = 0; i < CrackPoints.Length; i++)
{
// First point should always be the starting position.
if (i == 0)
{
CrackPoints[i] = startingPosition;
}
// Next point pivots away from the starting position in the direction of the velocity.
else if (i == 1)
{
Vector2 nextPointPosition = startingPosition + Projectile.velocity * Main.rand.NextFloat(0.8f, 1.2f) + Main.rand.NextVector2Circular(30f, 30f);
CrackPoints[i] = nextPointPosition;
}
// All other points follow after the last one with the same slight offset to resemble cracks.
else
{
Vector2 previousPoint = CrackPoints[i - 2];
float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints);
if (i == CrackPoints.Length - 1)
distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints) * 0.5f;
Vector2 newPoint = CrackPoints[i - 1] + (previousPoint.DirectionTo(CrackPoints[i - 1]) * distanceFromLastPoint).RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-5f, 5f) * i * 0.25f));
CrackPoints[i] = newPoint;
}
if (Main.rand.NextBool(9))
CrackPoints[i] += Main.rand.NextVector2Circular(10f, 10f);
}
}
Projectile.scale = MathHelper.Lerp(1f, 0f, Timer / 30f);
Timer++;
}
public float CrackWidthFunction(float completion) => Projectile.scale * MathHelper.Lerp(MaxWidth, 0f, completion);
public Color CrackColorFunction(float completion) => Projectile.GetAlpha(Color.White);
public override bool PreDraw(ref Color lightColor)
{
PrimitiveRenderer.RenderTrail(CrackPoints, new(CrackWidthFunction, CrackColorFunction, null, false));
return false;
}
}
}
+227 -92
View File
@@ -1,8 +1,13 @@
using System;
using System.IO;
using CalamityMod.Dusts;
using CalamityMod.Effects;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
@@ -10,124 +15,254 @@ namespace CalamityMod.Projectiles.Boss
{
public class DoGTeleportRift : ModProjectile, ILocalizedModType
{
public static readonly SoundStyle CrackSound = new("CalamityMod/Sounds/NPCHit/CryogenHit", 3);
public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/NPCHit/CryogenPhaseTransitionCrack");
public bool FakeRift;
public int RiftLifetime;
public NPC DoGHead => Main.npc[(int)Projectile.ai[0]];
public ref float Timer => ref Projectile.ai[1];
public ref float CrackScale => ref Projectile.ai[2];
public ref float AIState => ref Projectile.localAI[0];
public ref float CrackExposure => ref Projectile.localAI[1];
public ref float MaxExposure => ref Projectile.localAI[2];
public new string LocalizationCategory => "Projectiles.Boss";
public override string Texture => "CalamityMod/Projectiles/StarProj";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = Projectile.height = 30;
Projectile.scale = 2.5f;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.Opacity = 0f;
Projectile.scale = 0f;
Projectile.penetrate = -1;
Projectile.timeLeft = 200;
Projectile.timeLeft = RiftLifetime;
}
public override bool? CanDamage() => false;
public override bool ShouldUpdatePosition() => false;
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(FakeRift);
writer.Write(RiftLifetime);
for (int i = 0; i < Projectile.localAI.Length; i++)
writer.Write(Projectile.localAI[i]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
FakeRift = reader.ReadBoolean();
RiftLifetime = reader.ReadInt32();
for (int i = 0; i < Projectile.localAI.Length; i++)
Projectile.localAI[i] = reader.ReadSingle();
}
public override void AI()
{
if (Projectile.ai[0] == -1f)
return;
if (Projectile.timeLeft < 160)
Projectile.timeLeft = 160;
if (!Main.npc[(int)Projectile.ai[0]].active)
Projectile.Kill();
Projectile.ai[1] += MathHelper.Pi / 30f;
Projectile.Opacity = MathHelper.Clamp(Projectile.ai[1], 0f, 1f);
if (Projectile.Opacity == 1f && Main.rand.NextBool(15))
if (DoGHead is null || !DoGHead.active)
{
Dust dust = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, DustID.RainbowMk2, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f)];
dust.velocity.X = 0f;
dust.noGravity = true;
dust.fadeIn = 1f;
dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f);
dust.scale = 0.5f;
Projectile.Kill();
return;
}
// Pre-explosion, charge-up.
if (AIState == 0f)
{
int riftCrackInterval = (int)(RiftLifetime / 3f);
if (Timer % riftCrackInterval == 0f)
{
// Increase the intensity of certain effects as the crack gets bigger.
float effectsLifetimeInterpolant = MathHelper.Lerp(1f, 2f, Timer / RiftLifetime);
// Only let the real rift on GFB perform these additional effects.
if (!FakeRift)
{
float crackPitch = MathHelper.Lerp(-0.75f, 0f, Timer / RiftLifetime);
SoundEngine.PlaySound(CrackSound with { Pitch = crackPitch }, Projectile.Center);
for (int i = 0; i < 12; i++)
{
Vector2 sparkVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(8f, 12f) * effectsLifetimeInterpolant * 0.7f;
float sparkScale = Main.rand.NextFloat(1.2f, 1.6f) * effectsLifetimeInterpolant * 0.62f;
Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, new Color(0, 221, 250), new(117, 21, 161)), Color.White, 0.65f);
SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor);
GeneralParticleHandler.SpawnParticle(crackSpark);
}
for (int i = 0; i < 8; i++)
{
Vector2 lightVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 14f) * effectsLifetimeInterpolant * 0.5f;
float lightScale = Main.rand.NextFloat(1.2f, 1.6f) * effectsLifetimeInterpolant * 0.62f;
Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, new Color(0, 221, 250), new(117, 21, 161)), Color.White, 0.65f);
SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45));
GeneralParticleHandler.SpawnParticle(crackLight);
}
CalamityUtils.AddScreenshakeAt(Projectile.Center, 6f * effectsLifetimeInterpolant * 0.8f);
}
CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/ShineExplosion2", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f * effectsLifetimeInterpolant, 45);
GeneralParticleHandler.SpawnParticle(shineExplosion2);
// Increase the scale and exposure of the actual crack at each interval.
CrackScale += 0.45f * effectsLifetimeInterpolant * 0.75f;
MaxExposure = MathHelper.Clamp(MaxExposure + 0.25f * effectsLifetimeInterpolant, 0f, 0.95f);
}
// Perform the explosion right at the point where DoG emerges.
if (Timer >= RiftLifetime)
SwitchAIStates();
if (Projectile.timeLeft < 30)
Projectile.timeLeft = 30;
CrackExposure = MathHelper.Lerp(CrackExposure, MaxExposure, 0.075f);
Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.05f, 0f, 1f);
Projectile.scale = MathHelper.Clamp(Projectile.scale + 0.02f, 0f, 1f);
}
// Post-explosion, slowly fade out.
if (AIState == 1f)
{
Projectile.Opacity = MathHelper.Lerp(1f, 0f, Timer / RiftLifetime);
Projectile.scale = MathHelper.Lerp(1f, 0f, Timer / RiftLifetime);
}
Timer++;
}
public void SwitchAIStates()
{
AIState = 1f;
Timer = 0f;
Projectile.timeLeft = 30;
SpawnExplosionVisuals();
Projectile.netUpdate = true;
}
public void SpawnExplosionVisuals()
{
float brightnessMultiplier = CalamityClientConfig.Instance.Photosensitivity ? 0.6f : 1f;
if (!FakeRift)
{
// Spawn the rift cracks.
for (int i = 0; i < 25; i++)
{
Vector2 crackOffset = Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / 25) * Main.rand.NextFloat(20f, 80f);
Vector2 crackDestination = Projectile.Center + crackOffset;
Vector2 crackLength = crackDestination - Projectile.Center;
float riftWidth = Main.rand.NextFloat(20f, 30f);
Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, crackLength, ModContent.ProjectileType<DoGRiftCrack>(), 0, 0f, ai1: riftWidth);
}
// Spawn a bunch of square-shaped metaballs at the impact zone as well.
for (int i = 0; i < 35; i++)
DoGDistortionMetaball.SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(25f, 25f), Vector2.Zero, 500f, true, Main.rand.NextFloat(MathHelper.TwoPi));
// More metaballs flying away from the impact zone for extra flavor.
int metaballAmount = Main.rand.Next(15, 21);
for (int i = 0; i < metaballAmount; i++)
DoGDistortionMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2Unit() * Main.rand.NextFloat(25f, 35f), Main.rand.NextFloat(30f, 50f));
// Addtional particles and effects.
for (int i = 0; i < 25; i++)
{
Vector2 sparkVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 16f);
float sparkScale = Main.rand.NextFloat(1.8f, 2f);
Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, new Color(0, 221, 250), new(117, 21, 161)), Color.White, 0.65f);
SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor);
GeneralParticleHandler.SpawnParticle(crackSpark);
}
for (int i = 0; i < 20; i++)
{
Vector2 lightVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(16f, 20f);
float lightScale = Main.rand.NextFloat(1.8f, 2f);
Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, new Color(0, 221, 250), new(117, 21, 161)), Color.White, 0.65f);
SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45));
GeneralParticleHandler.SpawnParticle(crackLight);
}
// Explosion visuals.
Color brightTwlight = Color.Lerp(new(109, 21, 150), Color.White, 0.15f);
for (int i = 0; i < 3; i++)
{
CustomPulse plasmaExplosion = new(Projectile.Center, Vector2.Zero, brightTwlight * 0.8f * brightnessMultiplier, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 1.25f + i * 0.05f, 45);
GeneralParticleHandler.SpawnParticle(plasmaExplosion);
}
CustomPulse shineExplosion = new(Projectile.Center, Vector2.Zero, brightTwlight * 0.75f * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.75f, 45);
GeneralParticleHandler.SpawnParticle(shineExplosion);
CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * 0.7f * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion2", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f, 45);
GeneralParticleHandler.SpawnParticle(shineExplosion2);
StrongBloom bloom = new(Projectile.Center, Vector2.Zero, Color.White * 0.8f * brightnessMultiplier, 8f, 30);
GeneralParticleHandler.SpawnParticle(bloom);
SoundEngine.PlaySound(BreakSound, Projectile.Center);
CalamityUtils.AddScreenshakeAt(Projectile.Center, 14f);
}
else
{
for (int i = 0; i < 3; i++)
{
PulseRing fakerDeathRing = new(Projectile.Center, Vector2.Zero, Color.White * brightnessMultiplier, 0f, 3f + i * 0.25f, 30 + i * 15);
GeneralParticleHandler.SpawnParticle(fakerDeathRing);
StrongBloom bloom = new(Projectile.Center, Vector2.Zero, Color.White * 0.55f * brightnessMultiplier, 6f, 30);
GeneralParticleHandler.SpawnParticle(bloom);
}
}
}
public override bool PreDraw(ref Color lightColor)
{
float lerpMult = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f;
Texture2D crackTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value;
Texture2D starTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/StarProj").Value;
Texture2D bloomRingTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomRing").Value;
float chargeInterpolant = CalamityUtils.SineInOutEasing(Timer / RiftLifetime, 1);
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Color baseColor = new Color(150, 100, 255, 255) * Projectile.Opacity;
baseColor *= 0.5f;
baseColor.A = 0;
Color colorA = baseColor;
Color colorB = baseColor * 0.5f;
colorA *= lerpMult;
colorB *= lerpMult;
Vector2 origin = texture.Size() / 2f;
Vector2 scale = new Vector2(3f, 9f) * Projectile.Opacity * lerpMult;
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
Vector2 verticalStarPartScale = new Vector2(1f, 6f) * chargeInterpolant * Projectile.scale * 3.25f;
Vector2 horizontalStarPartScale = new Vector2(1f, 3f) * chargeInterpolant * Projectile.scale * 3.25f;
SpriteEffects spriteEffects = SpriteEffects.None;
if (Projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Main.spriteBatch.SetBlendState(BlendState.Additive);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0);
// Draw the glowing star.
Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale, 0);
Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2 + Projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, Projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2 + Projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, Projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0);
// Draw the crack.
var opacityShader = CalamityShaders.CircularOpacityShader;
float crackOpcity = (AIState == 1f) ? Projectile.Opacity * 0.15f : 0.15f;
Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 + Projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + Projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 + Projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + Projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0);
return false;
}
public override void OnKill(int timeLeft)
{
if (Projectile.ai[0] == -1f || Projectile.ai[2] == 1f)
return;
int dustAmt = 50;
int random = 5;
for (int j = 0; j < 10; j++)
opacityShader.Parameters["opacityCutoffValue"].SetValue(CrackExposure);
opacityShader.Parameters["fadeoutPower"].SetValue(1f);
opacityShader.Parameters["overallOpacity"].SetValue(crackOpcity);
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, opacityShader, Main.GameViewMatrix.TransformationMatrix, () =>
{
random += j * 2;
int dustAmtSpawned = 0;
int scale = random * 13;
float dustPositionX = Projectile.Center.X - (scale / 2);
float dustPositionY = Projectile.Center.Y - (scale / 2);
while (dustAmtSpawned < dustAmt)
{
float dustVelocityX = Main.rand.Next(-random, random);
float dustVelocityY = Main.rand.Next(-random, random);
float dustVelocityScalar = random * 2f;
float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY);
dustVelocity = dustVelocityScalar / dustVelocity;
dustVelocityX *= dustVelocity;
dustVelocityY *= dustVelocity;
int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f);
Main.dust[dust].noGravity = true;
Main.dust[dust].position.X = Projectile.Center.X;
Main.dust[dust].position.Y = Projectile.Center.Y;
Main.dust[dust].position.X += Main.rand.Next(-10, 11);
Main.dust[dust].position.Y += Main.rand.Next(-10, 11);
Main.dust[dust].velocity.X = dustVelocityX;
Main.dust[dust].velocity.Y = dustVelocityY;
dustAmtSpawned++;
}
Main.EntitySpriteDraw(crackTexture, drawPosition + Vector2.UnitY * 8f, null, Color.White * Projectile.Opacity, 0f, crackTexture.Size() * 0.5f, CrackScale, 0);
});
if (AIState != 1f)
{
// Draw the bloom ring which closes inwards.
float ringScale = MathHelper.Lerp(8f, 0f, chargeInterpolant);
Main.EntitySpriteDraw(bloomRingTexture, drawPosition, null, Color.White * chargeInterpolant * 0.6f, 0f, bloomRingTexture.Size() * 0.5f, ringScale, 0);
}
Main.spriteBatch.SetBlendState(BlendState.AlphaBlend);
return false;
}
}
}
+5 -140
View File
@@ -5,6 +5,7 @@ using CalamityMod.Events;
using CalamityMod.Graphics;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs.DevourerofGods;
using CalamityMod.Systems.Graphic;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -415,7 +416,8 @@ namespace CalamityMod.Skies
Asset<Texture2D> cracksTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/CrackedGlass_Glowing");
shader.Parameters["opacityCutoffValue"].SetValue(0.8f * SkyIntensity);
shader.Parameters["fadeoutPower"].SetValue(1.75f);
shader.Parameters["fadeoutPower"].SetValue(1f);
shader.Parameters["overallOpacity"].SetValue(0.2f);
shader.CurrentTechnique.Passes[0].Apply();
for (int i = 0; i < RealityCracks.Count; i++)
@@ -430,8 +432,8 @@ namespace CalamityMod.Skies
{
// Impose the distortion rift contents onto the primitives via shader.
var metaballShader = CalamityShaders.MetaballEdgeShader;
Texture2D distortionRiftContents = DoGWorldVisualChangesManager.DistortionRiftBackgroundContentsTarget;
Texture2D distortionRift = DoGWorldVisualChangesManager.DistortionRiftPrimitivesTarget;
Texture2D distortionRiftContents = DoGVisualsManager.DistortionRiftBackgroundContentsTarget;
Texture2D distortionRift = DoGVisualsManager.DistortionRiftPrimitivesTarget;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
@@ -478,141 +480,4 @@ namespace CalamityMod.Skies
return CanSkyBeActive || SkyIntensity > 0f;
}
}
public class DoGWorldVisualChangesManager : ModSystem
{
public float FillProgress = 0;
public static ManagedRenderTarget DistortionRiftBackgroundContentsTarget { get; private set; }
public static ManagedRenderTarget DistortionRiftPrimitivesTarget { get; private set; }
public override void OnModLoad()
{
if (!Main.dedServ)
On_Main.DrawSunAndMoon += DiscardCelestialObjects;
}
public override void PostSetupContent()
{
if (Main.dedServ)
return;
Main.QueueMainThreadAction(() =>
{
DistortionRiftBackgroundContentsTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
DistortionRiftPrimitivesTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
});
RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets;
}
public override void OnModUnload()
{
if (Main.dedServ)
return;
On_Main.DrawSunAndMoon -= DiscardCelestialObjects;
RenderTargetManager.RenderTargetUpdateLoopEvent -= PrepareTargets;
}
public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor)
{
var cplayer = Main.LocalPlayer.Calamity();
if (cplayer.monolithDevourerBShader > 0 || cplayer.monolithDevourerPShader > 0 || NPC.AnyNPCs(ModContent.NPCType<DevourerofGodsHead>()))
FillProgress += 0.05f;
else
FillProgress -= 0.05f;
// Darken the lighting color of both the background and foreground.
FillProgress = MathHelper.Clamp(FillProgress, 0, 1);
if (FillProgress > 0)
{
Color colorToUse = DoGSky.DoGSkyColor;
backgroundColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, Color.White.R * 0.035f, FillProgress);
backgroundColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, Color.White.G * 0.035f, FillProgress);
backgroundColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, Color.White.B * 0.035f, FillProgress);
backgroundColor = new(backgroundColor.ToVector3() + colorToUse.ToVector3() * 0.025f * FillProgress);
tileColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, 35f, FillProgress);
tileColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, 35f, FillProgress);
tileColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, 35f, FillProgress);
tileColor = new(tileColor.ToVector3() + colorToUse.ToVector3() * 0.075f * FillProgress);
}
}
private void DiscardCelestialObjects(On_Main.orig_DrawSunAndMoon orig, Main self, Main.SceneArea sceneArea, Color moonColor, Color sunColor, float tempMushroomInfluence)
{
if (DoGSky.SkyIntensity > 0f)
tempMushroomInfluence = DoGSky.SkyIntensity;
orig(self, sceneArea, moonColor, sunColor, tempMushroomInfluence);
}
private void PrepareTargets()
{
DistortionRiftBackgroundContentsTarget.SwapTo();
// Draw the background which'll be displayed inside the rift onto a render target.
DrawDistortionRiftBackground();
DistortionRiftPrimitivesTarget.SwapTo();
// Draw the primitives which compromise the rift to another render target.
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
if (SkyManager.Instance["CalamityMod:DevourerofGodsHead"].IsActive())
(SkyManager.Instance["CalamityMod:DevourerofGodsHead"] as DoGSky).DrawRiftToRenderTarget();
Main.spriteBatch.End();
Main.instance.GraphicsDevice.SetRenderTarget(null);
}
private static void DrawDistortionRiftBackground()
{
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw a black tile behind everything since the shader used to generate the clouds will appear transparent with dark colors.
Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw the layer of rolling clouds in the background.
DrawDistortionBackgroundClouds();
Main.spriteBatch.End();
}
private static void DrawDistortionBackgroundClouds()
{
Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
Asset<Texture2D> cloudsTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds");
Asset<Texture2D> erosionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise");
rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
rollingCloudsShader.Parameters["overallOpacity"].SetValue(0.7f);
rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.12f);
rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(2f);
rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f);
rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f);
rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f);
rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f);
rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f);
rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.001f);
rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, Color.DarkGray, 0.25f).ToVector3());
rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, DoGSky.DoGSkyColor, 0.4f).ToVector3());
Main.instance.GraphicsDevice.Textures[1] = cloudsTexture.Value;
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
Main.instance.GraphicsDevice.Textures[2] = erosionTexture.Value;
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap;
rollingCloudsShader.CurrentTechnique.Passes[0].Apply();
Main.spriteBatch.Draw(cloudsTexture.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White);
}
}
}
+466
View File
@@ -0,0 +1,466 @@
using CalamityMod.Effects;
using CalamityMod.Graphics;
using CalamityMod.NPCs.DevourerofGods;
using CalamityMod.Skies;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using ReLogic.Content;
using Terraria.GameContent;
using Terraria.Graphics.Effects;
using Terraria;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.ID;
using System;
using CalamityMod.Graphics.Metaballs;
using System.Linq;
namespace CalamityMod.Systems.Graphic
{
public class DoGVisualsManager : ModSystem
{
public class DistortionDebris
{
public Vector2 Position;
public Vector2 Velocity;
public float Scale;
public float Opacity;
public float Rotation;
public float Depth;
public int FrameX;
public int FrameY;
public int Time;
public int Lifetime;
public void Update()
{
if (Time <= 30)
Opacity += 0.05f;
if (Time >= Lifetime - 30)
Opacity -= 0.05f;
Position += Velocity;
Opacity = MathHelper.Clamp(Opacity, 0f, 1f);
Rotation += Velocity.X * 0.03f;
Time++;
}
}
public class DistortionStar
{
public Vector2 Position;
public float Scale;
public float StoredScale;
public float Depth;
public Color Color;
public int Time;
public int Lifetime;
public void Update()
{
Scale = MathHelper.Lerp(0f, StoredScale, MathF.Sin(Time / (float)Lifetime) * 0.5f + 0.5f);
Time++;
}
}
public float FillProgress = 0;
public List<DistortionDebris> ForegroundDebris;
public List<DistortionStar> ForegroundStars;
/// <summary>
/// Whether or not the background render targets should have their contents drawn to them.
/// </summary>
public bool ShouldDrawToBackgroundTargets => DoGSky.SkyIntensity > 0f;
/// <summary>
/// Whether or not the foreground render target should have its contents drawn to it.
/// </summary>
public bool ShouldDrawToForegroundTarget => MetaballManager.metaballs.Any(m => m.AnythingToDraw && m is DoGDistortionMetaball);
/// <summary>
/// The actual effects and contents seen inside the rift in the background of DoG's fight.
/// </summary>
public static ManagedRenderTarget DistortionRiftBackgroundContentsTarget { get; private set; }
/// <summary>
/// The primitives used to make up the shape of the rift seen in the background of DoG's fight.
/// </summary>
public static ManagedRenderTarget DistortionRiftPrimitivesTarget { get; private set; }
/// <summary>
/// The actual effects and contents seen inside of certain attacks used by DoG. Also used for DoG's distortion metaballs.
/// </summary>
public static ManagedRenderTarget DistortionForegroundContentsTarget { get; private set; }
public override void OnModLoad()
{
if (Main.dedServ)
return;
ForegroundDebris = [];
ForegroundStars = [];
On_Main.DrawSunAndMoon += DiscardCelestialObjects;
}
public override void PostSetupContent()
{
if (Main.dedServ)
return;
Main.QueueMainThreadAction(() =>
{
DistortionRiftBackgroundContentsTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
DistortionRiftPrimitivesTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
DistortionForegroundContentsTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
});
RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets;
}
public override void OnModUnload()
{
if (Main.dedServ)
return;
On_Main.DrawSunAndMoon -= DiscardCelestialObjects;
RenderTargetManager.RenderTargetUpdateLoopEvent -= PrepareTargets;
}
public override void PostUpdateEverything()
{
if (ForegroundDebris.Count < 100 && Main.rand.NextBool(12))
{
DistortionDebris debris = new DistortionDebris()
{
Position = Main.LocalPlayer.Center + Main.rand.NextVector2Circular(4500f, 4500f),
Velocity = Vector2.UnitX * Main.rand.NextFloat(4f, 12f),
Scale = Main.rand.NextFloat(0.4f, 1.2f),
Depth = Main.rand.NextFloat(3f, 10f),
FrameX = Main.rand.Next(3),
FrameY = Main.rand.Next(4)
};
ForegroundDebris.Add(debris);
}
if (ForegroundStars.Count < 100 && Main.rand.NextBool(12))
{
DistortionStar star = new DistortionStar()
{
Position = Main.LocalPlayer.Center + Main.rand.NextVector2Circular(4500f, 4500f),
StoredScale = Main.rand.NextFloat(0.75f, 1.25f),
Depth = Main.rand.NextFloat(8f, 12f),
Color = Utils.SelectRandom(Main.rand, Color.Fuchsia, new Color(0, 221, 250), new(117, 21, 161))
};
ForegroundStars.Add(star);
}
if (ForegroundDebris.Count > 0)
{
for (int i = 0; i < ForegroundDebris.Count; i++)
ForegroundDebris[i].Update();
}
if (ForegroundStars.Count > 0)
{
for (int i = 0; i < ForegroundStars.Count; i++)
ForegroundStars[i].Update();
}
}
public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor)
{
var cplayer = Main.LocalPlayer.Calamity();
if (cplayer.monolithDevourerBShader > 0 || cplayer.monolithDevourerPShader > 0 || NPC.AnyNPCs(ModContent.NPCType<DevourerofGodsHead>()))
FillProgress += 0.05f;
else
FillProgress -= 0.05f;
// Darken the lighting color of both the background and foreground.
FillProgress = MathHelper.Clamp(FillProgress, 0, 1);
if (FillProgress > 0)
{
Color colorToUse = DoGSky.DoGSkyColor;
backgroundColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, Color.White.R * 0.035f, FillProgress);
backgroundColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, Color.White.G * 0.035f, FillProgress);
backgroundColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, Color.White.B * 0.035f, FillProgress);
backgroundColor = new(backgroundColor.ToVector3() + colorToUse.ToVector3() * 0.025f * FillProgress);
tileColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, 35f, FillProgress);
tileColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, 35f, FillProgress);
tileColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, 35f, FillProgress);
tileColor = new(tileColor.ToVector3() + colorToUse.ToVector3() * 0.075f * FillProgress);
}
}
private void DiscardCelestialObjects(On_Main.orig_DrawSunAndMoon orig, Main self, Main.SceneArea sceneArea, Color moonColor, Color sunColor, float tempMushroomInfluence)
{
// Fade out the sun during DoG's fight.
if (DoGSky.SkyIntensity > 0f)
tempMushroomInfluence = DoGSky.SkyIntensity;
orig(self, sceneArea, moonColor, sunColor, tempMushroomInfluence);
}
private void PrepareTargets()
{
// Determine when targets should have their contents drawn onto them in order to save on performance.
if (ShouldDrawToBackgroundTargets)
{
// Draw the background which'll be displayed inside the rift onto a render target.
DistortionRiftBackgroundContentsTarget.SwapTo();
DrawDistortionRiftBackground();
// Draw the primitives which compromise the rift to another render target.
DistortionRiftPrimitivesTarget.SwapTo();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
if (SkyManager.Instance["CalamityMod:DevourerofGodsHead"].IsActive())
(SkyManager.Instance["CalamityMod:DevourerofGodsHead"] as DoGSky).DrawRiftToRenderTarget();
Main.spriteBatch.End();
}
if (ShouldDrawToForegroundTarget)
{
// Draw the background which'll be displayed for all distortion-related effects done in the foreground (same layer as the player).
DistortionForegroundContentsTarget.SwapTo();
DrawDistortionForeground();
}
// Reset the current render target at the end of the method once any targets are being drawn to.
if (ShouldDrawToForegroundTarget || ShouldDrawToBackgroundTargets)
Main.instance.GraphicsDevice.SetRenderTarget(null);
}
#region Distortion Background Drawing
private void DrawDistortionRiftBackground()
{
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw a black tile behind everything since the shader used to generate the clouds will appear transparent with dark colors, thus revealing
// the sky and any of its effects under the rift.
Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw the layer of rolling clouds in the background.
DrawDistortionClouds_Background();
Main.spriteBatch.End();
}
private void DrawDistortionClouds_Background()
{
Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
Asset<Texture2D> cloudsTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds");
Asset<Texture2D> erosionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise");
rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
rollingCloudsShader.Parameters["overallOpacity"].SetValue(0.5f);
rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.12f);
rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(2f);
rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f);
rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f);
rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f);
rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f);
rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f);
rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.001f);
rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, Color.DarkGray, 0.6f).ToVector3());
rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, DoGSky.DoGSkyColor, 0.3f).ToVector3());
Main.instance.GraphicsDevice.Textures[1] = cloudsTexture.Value;
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
Main.instance.GraphicsDevice.Textures[2] = erosionTexture.Value;
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap;
rollingCloudsShader.CurrentTechnique.Passes[0].Apply();
Main.spriteBatch.Draw(cloudsTexture.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White);
}
#endregion
#region Distortion Foreground Drawing
private void DrawDistortionForeground()
{
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw a black tile for the same reasoning explained above for the background drawing.
Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw a layer of rolling clouds in the background.
DrawDistortionClouds_Foreground();
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw the stars in front of the clouds.
DrawDistortionStars_Foreground();
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw the flying debris.
DrawDistortionDebris_Foreground();
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix);
// Draw the winds effect in front of everything.
DrawDistortionWinds_Foreground();
Main.spriteBatch.End();
}
private void DrawDistortionWinds_Foreground()
{
Effect windsShader = CalamityShaders.DoGDistortionWindsShader;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
Texture2D windsTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value;
Texture2D highlightsTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/SharpNoise").Value;
Texture2D distortionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise").Value;
Texture2D erosionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles").Value;
windsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 1.075f);
windsShader.Parameters["overallOpacity"].SetValue(0.8f);
windsShader.Parameters["distortionStrength"].SetValue(0.3f);
windsShader.Parameters["mainNoiseTextureScale"].SetValue(2.64f);
windsShader.Parameters["distortionTextureScale"].SetValue(1.76f);
windsShader.Parameters["erosionTextureScale"].SetValue(2f);
windsShader.Parameters["erosionMin"].SetValue(0.5f);
windsShader.Parameters["gradientPrecision"].SetValue(20f);
windsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f);
windsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / windsTexture.Size() * 0.025f);
windsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.64f).ToVector3());
windsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.32f).ToVector3());
windsShader.Parameters["highlightsColor"].SetValue(Color.Fuchsia.ToVector3());
Main.instance.GraphicsDevice.Textures[1] = highlightsTexture;
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap;
Main.instance.GraphicsDevice.Textures[2] = distortionTexture;
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap;
Main.instance.GraphicsDevice.Textures[3] = erosionTexture;
Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearWrap;
// Fuchsia highlights.
windsShader.CurrentTechnique.Passes[0].Apply();
Main.spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White);
windsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.8f);
windsShader.Parameters["overallOpacity"].SetValue(0.7f);
windsShader.Parameters["distortionStrength"].SetValue(0.6f);
windsShader.Parameters["mainNoiseTextureScale"].SetValue(3.72f);
windsShader.Parameters["distortionTextureScale"].SetValue(0.46f);
windsShader.Parameters["erosionTextureScale"].SetValue(3f);
windsShader.Parameters["erosionMin"].SetValue(0.75f);
windsShader.Parameters["highlightsColor"].SetValue(new Color(0, 221, 250).ToVector3());
// Cyan highlights.
windsShader.CurrentTechnique.Passes[0].Apply();
Main.spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White);
}
private void DrawDistortionClouds_Foreground()
{
Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader;
Texture2D cloudsTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value;
Texture2D erosionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 2f);
rollingCloudsShader.Parameters["overallOpacity"].SetValue(1f);
rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.12f);
rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(1f);
rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f);
rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f);
rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f);
rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f);
rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f);
rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.025f);
rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, new(0, 221, 250), 0.25f).ToVector3());
rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, Color.Fuchsia, 0.25f).ToVector3());
Main.instance.GraphicsDevice.Textures[1] = cloudsTexture;
Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
Main.instance.GraphicsDevice.Textures[2] = erosionTexture;
Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap;
rollingCloudsShader.CurrentTechnique.Passes[0].Apply();
Main.spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White);
}
private void DrawDistortionDebris_Foreground()
{
if (ForegroundDebris.Count <= 0)
return;
Texture2D rubbleTexture = TextureAssets.Projectile[ProjectileID.DeerclopsRangedProjectile].Value;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f);
for (int i = 0; i < ForegroundDebris.Count; i++)
{
Vector2 depthFactor = new(1f / ForegroundDebris[i].Depth, 1.1f / ForegroundDebris[i].Depth);
Vector2 drawPosition = (ForegroundDebris[i].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition;
Rectangle frame = rubbleTexture.Frame(3, 4, ForegroundDebris[i].FrameX, ForegroundDebris[i].FrameY);
Color debrisColor = Color.Lerp(Color.White, Color.Black, 0.8f) * ForegroundDebris[i].Opacity;
Main.spriteBatch.Draw(rubbleTexture, drawPosition, frame, debrisColor, ForegroundDebris[i].Rotation, frame.Size() * 0.5f, ForegroundDebris[i].Scale / ForegroundDebris[i].Depth, 0, 0f);
}
}
private void DrawDistortionStars_Foreground()
{
if (ForegroundStars.Count <= 0)
return;
Texture2D starTexture = TextureAssets.Extra[ExtrasID.ThePerfectGlow].Value;
Vector2 screenSize = new(Main.screenWidth, Main.screenHeight);
Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f);
for (int i = 0; i < ForegroundStars.Count; i++)
{
Vector2 depthFactor = new(1f / ForegroundStars[i].Depth, 1.1f / ForegroundStars[i].Depth);
Vector2 drawPosition = (ForegroundStars[i].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition;
// Colored outer glow.
Main.spriteBatch.Draw(starTexture, drawPosition, null, ForegroundStars[i].Color, 0f, starTexture.Size() * 0.5f, ForegroundStars[i].Scale, 0, 0f);
Main.spriteBatch.Draw(starTexture, drawPosition, null, ForegroundStars[i].Color, MathHelper.PiOver2, starTexture.Size() * 0.5f, ForegroundStars[i].Scale / ForegroundStars[i].Depth, 0, 0f);
// White inner core.
Main.spriteBatch.Draw(starTexture, drawPosition, null, Color.White, 0f, starTexture.Size() * 0.5f, ForegroundStars[i].Scale * 0.6f, 0, 0f);
Main.spriteBatch.Draw(starTexture, drawPosition, null, Color.White, MathHelper.PiOver2, starTexture.Size() * 0.5f, (ForegroundStars[i].Scale * 0.6f) / ForegroundStars[i].Depth, 0, 0f);
}
}
#endregion
}
}