diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 228afb677f..5d94e84921 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -71,8 +71,8 @@ namespace CalamityMod.CalPlayer if (DoG != null && Main.mapStyle != 2) { Rectangle screen = new((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight); - var rift = DoG.GetRiftLocationSafe(); - if (rift != Vector2.Zero) + var rift = DoG.GetRiftLocation(); + if (rift != Vector2.Zero && !Main.zenithWorld) { var dist = Player.Distance(rift); var tex = ModContent.Request("Terraria/Images/Extra_173").Value; diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 19ccaaf79a..c523fbac5c 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -234,6 +234,13 @@ namespace CalamityMod.Effects // Allows a texture to control its opacity from the edges to the center in the shape of a circle. internal static Effect CircularOpacityShader; + + // The shader effect imposed onto the static crack textures seen during DoG's fight. Fades out the texture from its edges to its center and + // allows it to lerp between two colors depending on the brightness of individual pixels along the sampled texture. + internal static Effect DoGRealityCrackShader; + + // The distorted circular effect seen emanating from the distortion rift during DoG's fight. + internal static Effect DoGRiftAuraShader; #endregion public override void PostSetupContent() @@ -465,6 +472,12 @@ namespace CalamityMod.Effects CircularOpacityShader = LoadShader("CircularOpacityShader"); RegisterMiscShader(CircularOpacityShader, "CircularOpacityPass", "CircularOpacity"); + + DoGRealityCrackShader = LoadShader("DoGRealityCrackShader"); + RegisterMiscShader(DoGRealityCrackShader, "DoGRealityCrackPass", "DoGRealityCrack"); + + DoGRiftAuraShader = LoadShader("DoGRiftAuraShader"); + RegisterMiscShader(DoGRiftAuraShader, "DoGRiftAuraPass", "DoGRiftAura"); #endregion } diff --git a/Effects/CircularOpacityShader.fx b/Effects/CircularOpacityShader.fx index 1f4cc18cb1..64ca9b6163 100644 --- a/Effects/CircularOpacityShader.fx +++ b/Effects/CircularOpacityShader.fx @@ -15,6 +15,8 @@ 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. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. if (-polarCoords.y < opacityCutoffValue) color.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); diff --git a/Effects/DoGDisintegration.fx b/Effects/DoGDisintegration.fx index 7473ea481a..3e0f61e541 100644 --- a/Effects/DoGDisintegration.fx +++ b/Effects/DoGDisintegration.fx @@ -1,39 +1,35 @@ -sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -float3 uColor; -float3 uSecondaryColor; -float uOpacity : register(C0); -float uSaturation; -float uRotation; -float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; -float2 uImageSize0; -float2 uImageSize1; -float4 uShaderSpecificData; +sampler baseTexture : register(s0); +sampler disintegrationTexture : register(s1); + +float disintegrationProgress : register(C0); +float disintegrationScale; +float2 worldPosition; +float2 pixelSize; // This shader is largely based on code used for ExampleMod's cool death animation thing; it is suprisingly useful for this use case. float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 { - float4 color = tex2D(uImage0, coords); + float4 color = tex2D(baseTexture, coords); if (!any(color)) return color; - float fade = pow(saturate(1 - uOpacity), 0.7); - float4 color1 = tex2D(uImage1, float2(coords.x, frac(coords.y + uSaturation * 0.11)) * 0.3); + coords += worldPosition; + coords = round(coords * pixelSize) / pixelSize; + + float disintegration = pow(saturate(1 - disintegrationProgress), 0.7); + float2 disintegrationCoords = coords * disintegrationScale; + float4 disintegrationColor = tex2D(disintegrationTexture, disintegrationCoords); - float readRed = fade * 1.05; - - if (color1.r > readRed) + float disappearThreshold = disintegration * 1.05; + if (disintegrationColor.r > disappearThreshold) { color.rgba = 0; } - else if (color1.b > fade) + else if (disintegrationColor.b > disintegration) { color = float4(1, 105.0 / 255, 180.0 / 255, 1); } + return color; } @@ -41,6 +37,6 @@ technique Technique1 { pass DisintegrationPass { - PixelShader = compile ps_2_0 PixelShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); } } \ No newline at end of file diff --git a/Effects/DoGDisintegration.xnb b/Effects/DoGDisintegration.xnb index bbc4f237f3..a841c844da 100644 Binary files a/Effects/DoGDisintegration.xnb and b/Effects/DoGDisintegration.xnb differ diff --git a/Effects/DoGRealityCrackShader.fx b/Effects/DoGRealityCrackShader.fx new file mode 100644 index 0000000000..2c9f7b0c28 --- /dev/null +++ b/Effects/DoGRealityCrackShader.fx @@ -0,0 +1,54 @@ +sampler baseTexture : register(s0); + +float overallOpacity; +float opacityCutoffValue; +float fadeoutPower; +float minBrightnessValue; +float gradientPrecision; + +float3 brighterPixelColor; +float3 darkerPixelColor; + +float InverseLerp(float from, float to, float value) +{ + return (value - from) / (to - from); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + + float2 polarCoords = float2(polarAngle, distanceToCenter); + float4 color = tex2D(baseTexture, coords); + + // Get the horizontal brightness of the sampled texture and apply coloration. + float brightness = (color.r + color.g + color.b) / 3; + float brightnessRatio = InverseLerp(minBrightnessValue, 1, brightness); + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, brightnessRatio); + + float4 coloredSample = color * float4(colorFromBrightness, 1); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + coloredSample.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + // Apply optional posterization. + /*if (gradientPrecision > 0) + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + */ + return coloredSample * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass DoGRealityCrackPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} + diff --git a/Effects/DoGRealityCrackShader.xnb b/Effects/DoGRealityCrackShader.xnb new file mode 100644 index 0000000000..fb989a9310 Binary files /dev/null and b/Effects/DoGRealityCrackShader.xnb differ diff --git a/Effects/DoGRiftAuraShader.fx b/Effects/DoGRiftAuraShader.fx new file mode 100644 index 0000000000..6d6439cf93 --- /dev/null +++ b/Effects/DoGRiftAuraShader.fx @@ -0,0 +1,62 @@ +sampler baseTexture : register(s0); +sampler distortionTexture : register(s1); + +float time; +float overallOpacity; +float distortionStrength; +float opacityCutoffValue; +float fadeoutPower; +float minBrightnessValue; +float gradientPrecision; +float2 pixelSize; +float3 brighterPixelColor; + +float InverseLerp(float from, float to, float value) +{ + return (value - from) / (to - from); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelate. + coords = round(coords * pixelSize) / pixelSize; + + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + float2 polarCoords = float2(polarAngle, distanceToCenter); + + // Apply distortion to the main texture. + float distortion = tex2D(distortionTexture, polarCoords + float2(time * 0.017, time * -0.026)).r * distortionStrength; + float2 baseCoords = coords * distortion; + baseCoords *= 0.4; + float4 color = tex2D(baseTexture, baseCoords); + + // Get the horizontal brightness of the sampled texture and apply coloration. + float brightness = (color.r + color.g + color.b) / 3; + float brightnessRatio = InverseLerp(minBrightnessValue, 1, brightness); + float3 colorFromBrightness = lerp(float3(0, 0, 0), brighterPixelColor, brightnessRatio); + + float4 coloredSample = color * float4(colorFromBrightness, 1); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing/decreasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + coloredSample.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + // Apply optional posterization. + if (gradientPrecision > 0) + coloredSample = round(coloredSample * gradientPrecision) / gradientPrecision; + + return coloredSample * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass DoGRiftAuraPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGRiftAuraShader.xnb b/Effects/DoGRiftAuraShader.xnb new file mode 100644 index 0000000000..1042c87024 Binary files /dev/null and b/Effects/DoGRiftAuraShader.xnb differ diff --git a/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs b/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs new file mode 100644 index 0000000000..8cf9e75687 --- /dev/null +++ b/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs @@ -0,0 +1,112 @@ +using CalamityMod.NPCs; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.Providence; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Renderers.CalamityRenderers +{ + public class DoGDeathAnimationRenderer : BaseRenderer + { + private static DevourerofGodsHead DoGHead + { + get + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.DoGHead)) + return null; + + if (Main.npc[CalamityGlobalNPC.DoGHead].type != ModContent.NPCType()) + return null; + + if (Main.npc[CalamityGlobalNPC.DoGHead].ModNPC is not null && Main.npc[CalamityGlobalNPC.DoGHead].ModNPC is DevourerofGodsHead dogHead) + return dogHead; + + return null; + } + } + + /// + /// Used to determine whether the npc should return true in predraw or not, for exclusively drawing to the drawer target. + /// + public static bool ActuallyDoPreDraw + { + get; + private set; + } + + public override DrawLayer Layer => DrawLayer.NPC; + + public override bool ShouldDraw => !Main.gameMenu && CalamityGlobalNPC.DoGHead != -1 && Main.npc[CalamityGlobalNPC.DoGHead].active && DoGHead.DeathAnimationTimer > 0; + + public static bool ValidToDraw(NPC npc) + { + // Do not draw inactive npcs, or ones with weird MP types less than or equal to 0. + if (!npc.active || npc.type <= NPCID.None) + return false; + + // Don't consider any other NPCs besides the DoG NPCs valid. + if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + return false; + + // Don't draw if DoG's Head cannot be found active. + if (DoGHead is null) + return false; + + // Don't draw if DoG hasn't started it's death animation yet. + if (DoGHead.DeathAnimationTimer <= 0) + return false; + + return true; + } + + public override void DrawToTarget(SpriteBatch spriteBatch) + { + // Indicate that DoG and his segments should draw. + ActuallyDoPreDraw = true; + + // Draw every npc to a single target that should have the disintegration visual. + foreach (NPC npc in Main.ActiveNPCs) + { + // Extra check to ensure that index errors will not occur. If not in range, something has gone wrong and the loop should terminate. + if (!Main.npc.IndexInRange(npc.whoAmI)) + break; + + // Draw the NPCs to the target once everything is valid and set the disintegration progress variable. + // Also ensure to indicate that the renderer should allow drawing the target here as well. + if (ValidToDraw(npc)) + Main.instance.DrawNPC(npc.whoAmI, npc.behindTiles); + } + + // Indicate that DoG and his segments should no longer draw. + ActuallyDoPreDraw = false; + } + + public override void DrawTarget(SpriteBatch spriteBatch) + { + var disintegrationShader = GameShaders.Misc["CalamityMod:DoGDisintegration"].Shader; + NPC npc = DoGHead.NPC; + if (npc == null || !npc.active) + return; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 worldPosition = Main.screenPosition / MainTarget.Size; + float disintegrationProgress = DoGHead.DeathAnimationTimer / 600f; + + disintegrationShader.Parameters["disintegrationProgress"].SetValue(disintegrationProgress); + disintegrationShader.Parameters["disintegrationScale"].SetValue(1.75f); + disintegrationShader.Parameters["worldPosition"].SetValue(new Vector2(worldPosition.X, worldPosition.Y)); + disintegrationShader.Parameters["pixelSize"].SetValue(screenSize * 0.5f); + + Main.instance.GraphicsDevice.Textures[1] = Main.Assets.Request("Images/Misc/Perlin").Value; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + disintegrationShader.Techniques[0].Passes[0].Apply(); + Main.spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White); + } + } +} diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 2c844d8826..df2e9fdda2 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -7418,6 +7418,10 @@ namespace CalamityMod.NPCs // Only draw the NPC if told to by the miracle blight drawer. if (MiracleBlightRenderer.ValidToDraw(npc)) return MiracleBlightRenderer.ActuallyDoPreDraw; + + // Only draw DoG's death animation when told to by the renderer. + if (DoGDeathAnimationRenderer.ValidToDraw(npc)) + return DoGDeathAnimationRenderer.ActuallyDoPreDraw; } if (Main.zenithWorld) diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index 980debcb5e..18b9320fe0 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.World; @@ -281,16 +282,6 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.npc[NPC.realLife].type != ModContent.NPCType()) return true; - float disintegrationFactor = Main.npc[NPC.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } - SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; @@ -319,9 +310,6 @@ namespace CalamityMod.NPCs.DevourerofGods spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor2, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - return false; } diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index ae2f656cf1..d1fc817932 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -6,6 +6,7 @@ using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Vanity; @@ -717,7 +718,7 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) // Disable teleports if (teleportTimer > 0) { - GetRiftLocation(); + GetRiftLocation(true); teleportTimer = 0; } } @@ -2237,16 +2238,17 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) { if (teleportTimer > 0 || player.dead || !player.active) return; + if (NPC.ai[3] < 2) - { NPC.ai[3] = 3; - } + + int baseTeleportTime = ((CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal); + if ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.life / (float)NPC.lifeMax < 0.25f && NPC.ai[3] < 8 && NPC.ai[3] > 3) + baseTeleportTime -= 45; + if (!phase2Transition) - teleportTimer = (CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal; - if ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.life / (float)NPC.lifeMax < 0.25f && NPC.ai[3] < 8 && NPC.ai[3] > 3) - { - teleportTimer -= 45; //Much faster for the first 3 dashes in death. - } + teleportTimer = baseTeleportTime; + SoundEngine.PlaySound(RiftOpenSound with {Volume = 1.5f}, player.Center); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -2260,10 +2262,7 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); int rift = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 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().RiftLifetime = phase2Transition ? timeForPhaseTransition : teleportTimer; - } + Main.projectile[rift].ModProjectile().RiftLifetime = baseTeleportTime; // GFB, spawn a ton of fake rifts alongside the real one. if (Main.zenithWorld) @@ -2276,7 +2275,7 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) if (Main.projectile.IndexInRange(faker)) { Main.projectile[faker].ModProjectile().FakeRift = true; - Main.projectile[faker].ModProjectile().RiftLifetime = teleportTimer; + Main.projectile[faker].ModProjectile().RiftLifetime = baseTeleportTime; } } } @@ -2285,7 +2284,7 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) private void Teleport(Player player, bool death, bool revenge, bool expertMode, bool phase5) { - Vector2 newPosition = GetRiftLocation(); + Vector2 newPosition = GetRiftLocation(true); if ((!AwaitingPhase2Teleport && (player.dead || !player.active)) || newPosition == default) return; @@ -2467,30 +2466,21 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) DeathAnimationTimer++; } - //public Vector2 GetRiftLocation() - private Vector2 GetRiftLocation() + public Vector2 GetRiftLocation(bool activateRift = false) { Vector2 realSpot = Vector2.Zero; foreach (Projectile proj in Main.ActiveProjectiles) { if (proj.type == ModContent.ProjectileType()) { - realSpot = proj.Center; - // Safeguard for if the rift doesn't activate at its designated time. - proj.ModProjectile().SwitchAIStates(); - } - } - return realSpot; - } + if (proj.ModProjectile is DoGTeleportRift rift && !rift.FakeRift) + { + realSpot = proj.Center; - public Vector2 GetRiftLocationSafe() - { - Vector2 realSpot = Vector2.Zero; - foreach (Projectile proj in Main.ActiveProjectiles) - { - if (proj.type == ModContent.ProjectileType()) - { - realSpot = proj.Center; + // Safeguard for if the rift doesn't activate at its designated time. + if (activateRift) + proj.ModProjectile().SwitchAIStates(); + } } } return realSpot; @@ -2511,16 +2501,6 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, TextureP2_Full.Value, DevourerofGodsBody.TextureP2.Value, 4, 26, 0.5f, new Vector2(30, 10), 2, 20); } - float disintegrationFactor = DeathAnimationTimer / 800f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage0("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } - SpriteEffects spriteEffects = (NPC.spriteDirection == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 halfSizeTexture = mainTexture.Size() * 0.5f; @@ -2543,7 +2523,7 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) spriteBatch.Draw(mainJawGlowTexture, jawDrawPosition, null, NPC.GetAlpha(Color.White), NPC.rotation + JawRotation * i, jawOrigin, NPC.scale, jawSpriteEffect, 0f); // Draw the additional special jaw textures above these for the Rift Dash attack. - if (GodSlayerDashJawFadeProgress > 0.02f && disintegrationFactor <= 0f) + if (GodSlayerDashJawFadeProgress > 0.02f && !DoGDeathAnimationRenderer.ValidToDraw(NPC)) { spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => { @@ -2568,9 +2548,6 @@ if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + 115) glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); spriteBatch.Draw(mainGlowTexture, drawPosition, NPC.frame, NPC.GetAlpha(glowmaskColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - return false; } diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 440446e238..b503b43e9e 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.Sounds; using CalamityMod.World; @@ -303,16 +304,6 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.npc[NPC.realLife].type != ModContent.NPCType()) return true; - float disintegrationFactor = Main.npc[NPC.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } - SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; @@ -341,9 +332,6 @@ namespace CalamityMod.NPCs.DevourerofGods spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - return false; } diff --git a/Projectiles/Boss/DoGTeleportRift.cs b/Projectiles/Boss/DoGTeleportRift.cs index d23593a1a0..6758288007 100644 --- a/Projectiles/Boss/DoGTeleportRift.cs +++ b/Projectiles/Boss/DoGTeleportRift.cs @@ -4,6 +4,7 @@ using CalamityMod.Dusts; using CalamityMod.Effects; using CalamityMod.Graphics.Metaballs; using CalamityMod.Particles; +using CalamityMod.Skies; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -19,6 +20,7 @@ namespace CalamityMod.Projectiles.Boss public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/NPCHit/CryogenPhaseTransitionCrack"); + // GFB exclusive; DoG can spawn fake rifts on that seed to confuse the player. public bool FakeRift; public int RiftLifetime; @@ -96,7 +98,7 @@ namespace CalamityMod.Projectiles.Boss { 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); + Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor); GeneralParticleHandler.SpawnParticle(crackSpark); } @@ -105,7 +107,7 @@ namespace CalamityMod.Projectiles.Boss { 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); + Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45)); GeneralParticleHandler.SpawnParticle(crackLight); } @@ -113,23 +115,21 @@ namespace CalamityMod.Projectiles.Boss 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); + float brightnessMultiplier = FakeRift ? 0.75f : 1f; + CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * brightnessMultiplier, "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; + CrackScale += 0.525f * 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(); - AIState = 1; - } - if (Projectile.timeLeft < 30) - Projectile.timeLeft = 30; + if (Projectile.timeLeft < 45) + Projectile.timeLeft = 45; CrackExposure = MathHelper.Lerp(CrackExposure, MaxExposure, 0.075f); Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.05f, 0f, 1f); @@ -139,8 +139,8 @@ namespace CalamityMod.Projectiles.Boss // Post-explosion, slowly fade out. if (AIState == 1f) { - Projectile.Opacity = MathHelper.Lerp(1f, 0f, Timer / RiftLifetime); - Projectile.scale = MathHelper.Lerp(1f, 0f, Timer / RiftLifetime); + Projectile.Opacity = MathHelper.Lerp(1f, 0f, Timer / 45f); + CrackExposure = MathHelper.Lerp(MaxExposure, 0f, Timer / 45f); } Timer++; @@ -150,6 +150,7 @@ namespace CalamityMod.Projectiles.Boss { AIState = 1f; Timer = 0f; + CrackScale += 3f; Projectile.timeLeft = 30; SpawnExplosionVisuals(); Projectile.netUpdate = true; @@ -184,7 +185,7 @@ namespace CalamityMod.Projectiles.Boss { 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); + Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor); GeneralParticleHandler.SpawnParticle(crackSpark); } @@ -193,22 +194,21 @@ namespace CalamityMod.Projectiles.Boss { 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); + Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), 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); + CustomPulse plasmaExplosion = new(Projectile.Center, Vector2.Zero, DoGSky.DoGTwlight * 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); + CustomPulse shineExplosion = new(Projectile.Center, Vector2.Zero, DoGSky.DoGTwlight * 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); + CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * 0.6f * 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); @@ -220,10 +220,8 @@ namespace CalamityMod.Projectiles.Boss { 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); + PulseRing fakerDeathRing = new(Projectile.Center, Vector2.Zero, Color.White * 0.45f * brightnessMultiplier, 0f, 3f + i * 0.1f, 30 + i * 15); GeneralParticleHandler.SpawnParticle(fakerDeathRing); - StrongBloom bloom = new(Projectile.Center, Vector2.Zero, Color.White * 0.55f * brightnessMultiplier, 6f, 30); - GeneralParticleHandler.SpawnParticle(bloom); } } } @@ -233,35 +231,54 @@ namespace CalamityMod.Projectiles.Boss Texture2D crackTexture = ModContent.Request("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value; Texture2D starTexture = ModContent.Request("CalamityMod/Projectiles/StarProj").Value; Texture2D bloomRingTexture = ModContent.Request("CalamityMod/Particles/BloomRing").Value; + float chargeInterpolant = CalamityUtils.SineInOutEasing(Timer / RiftLifetime, 1); + float brightnessMultiplier = FakeRift ? 0.6f : 1f; 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; + Vector2 verticalStarPartScale = new Vector2(1f, 8f) * chargeInterpolant * Projectile.scale * 3.25f; + Vector2 horizontalStarPartScale = new Vector2(1f, 5f) * chargeInterpolant * Projectile.scale * 3.25f; Main.spriteBatch.SetBlendState(BlendState.Additive); // 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(starTexture, drawPosition, null, Color.White * 0.7f * brightnessMultiplier * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale, 0); + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * brightnessMultiplier * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale, 0); + + // Draw a smaller, twlight colored star at the center if this isn't a fake rift. + if (!FakeRift) + { + Main.EntitySpriteDraw(starTexture, drawPosition, null, DoGSky.DoGTwlight * 0.9f * brightnessMultiplier * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale * 0.8f, 0); + Main.EntitySpriteDraw(starTexture, drawPosition, null, DoGSky.DoGTwlight * 0.9f * brightnessMultiplier * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale * 0.8f, 0); + } // Draw the crack. - var opacityShader = CalamityShaders.CircularOpacityShader; - float crackOpcity = (AIState == 1f) ? Projectile.Opacity * 0.15f : 0.15f; + Effect crackShader = CalamityShaders.DoGRealityCrackShader; + float crackOpcity = (AIState == 1f) ? Projectile.Opacity * 0.1f : 0.1f; + Color darkerPixelColor = FakeRift ? Color.White : DoGSky.DoGTwlight; - 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, () => + crackShader.Parameters["opacityCutoffValue"].SetValue(CrackExposure); + crackShader.Parameters["fadeoutPower"].SetValue(1f); + crackShader.Parameters["overallOpacity"].SetValue(crackOpcity * brightnessMultiplier); + crackShader.Parameters["minBrightnessValue"].SetValue(0.75f); + crackShader.Parameters["darkerPixelColor"].SetValue(darkerPixelColor.ToVector3()); + crackShader.Parameters["brighterPixelColor"].SetValue(Color.White.ToVector3()); + Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, crackShader, Main.GameViewMatrix.TransformationMatrix, () => { - Main.EntitySpriteDraw(crackTexture, drawPosition + Vector2.UnitY * 8f, null, Color.White * Projectile.Opacity, 0f, crackTexture.Size() * 0.5f, CrackScale, 0); + int crackCount = FakeRift ? 1 : 3; + for (int i = 0; i < crackCount; i++) + { + float crackRotation = i * MathHelper.TwoPi / crackCount; + Main.EntitySpriteDraw(crackTexture, drawPosition + Vector2.UnitY * 8f, null, Color.White * Projectile.Opacity, crackRotation, 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); + Color ringColor = FakeRift ? Color.White : Color.Lerp(Color.White, DoGSky.DoGTwlight, chargeInterpolant); + Main.EntitySpriteDraw(bloomRingTexture, drawPosition, null, ringColor * brightnessMultiplier * chargeInterpolant * 0.6f, 0f, bloomRingTexture.Size() * 0.5f, ringScale, 0); } Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); diff --git a/Skies/DoGSky.cs b/Skies/DoGSky.cs index bbb438610e..39baf087c7 100644 --- a/Skies/DoGSky.cs +++ b/Skies/DoGSky.cs @@ -37,61 +37,29 @@ namespace CalamityMod.Skies public class DistortionRiftArm { - /// - /// The starting position of the arm. - /// public Vector2 ArmStartingPosition; - /// - /// A list of the positions for each point which makes up the arm. - /// public List ArmPoints; - /// - /// A parallax effect applied to the arm which affects how far back it appears in the background. - /// public float Depth; - /// - /// The maximum width of the rift arm. - /// - /// - /// Note that this width tapers off till the end. - /// public float MaxWidth; - /// - /// The maximum amount of distance which can be between two points. - /// public float MinDistanceBetweenPoints; - /// - /// The maximum amount of distance which can be between two points. - /// public float MaxDistanceBetweenPoints; - /// - /// The minimum angle at which the points along the arm can be placed at randomly. - /// - /// - /// Should ALWAYS be set as degrees. - /// public float MinPointAngularVariance; - /// - /// The minimum angle at which the points along the arm can be placed at randomly. - /// - /// - /// Should ALWAYS be set as degrees. - /// public float MaxPointAngularVariance; - /// - /// The total amount of points that make up this rift arm. - /// public int TotalPoints; } + public static readonly Color DoGTwlight = new(147, 24, 204); + + public static readonly Color DoGLightBlue = new(0, 221, 250); + public bool Initialized; public int DoGIndex; @@ -100,28 +68,24 @@ namespace CalamityMod.Skies public List OuterRiftCracks; + public List RealityCracks; + + public List DistortionRiftArms; + public static bool CanSkyBeActive { get; private set; } public static float SkyIntensity { get; private set; } public static Color DoGSkyColor { get; private set; } - public List RealityCracks { get; private set; } = []; - - public List DistortionRiftArms { get; private set; } = []; - public override void Update(GameTime gameTime) { + // Initialize the rift arms and background cracks. + GenerateRift(); + DoGIndex = NPC.FindFirstNPC(ModContent.NPCType()); GetCorrectDoGColor(); - // Initialize the rift arms and background cracks. - if (!Initialized) - { - GenerateRift(); - Initialized = true; - } - if (CanSkyBeActive) SkyIntensity = MathHelper.Clamp(SkyIntensity + 0.05f, 0f, 1f); else @@ -131,91 +95,99 @@ namespace CalamityMod.Skies private void GenerateRift() { Vector2 riftSpawnLocation = Main.LocalPlayer.Center - Vector2.UnitY * 2000f + Main.rand.NextVector2Circular(2000f, 2000f); - float crackRotation = MathHelper.ToRadians(Main.rand.NextFloat(-20f, 20f)); - for (int i = 0; i < 2; i++) + if (!Initialized) { - RealityCrack realityCrack = new RealityCrack() + MainRiftCracks = []; + OuterRiftCracks = []; + RealityCracks = []; + DistortionRiftArms = []; + + int crackCount = 3; + for (int i = 0; i < crackCount; i++) { - Position = riftSpawnLocation, - Depth = 30f, - Scale = 2.75f, - Rotation = (i == 0 ? 0f : MathHelper.Pi) + crackRotation, - }; - RealityCracks.Add(realityCrack); - } + RealityCrack realityCrack = new RealityCrack() + { + Position = riftSpawnLocation, + Depth = 30f, + Scale = 1.55f * Main.rand.NextFloat(0.9f, 1.1f), + Rotation = i * MathHelper.TwoPi / crackCount + }; + RealityCracks.Add(realityCrack); + } - // Generate up to 30 arms for the rift. - // The first 14 are larger cracks to form the main hole at the impact point. - // The rest are longer, skinner cracks protruding outwards from it. - MainRiftCracks = []; - OuterRiftCracks = []; - for (int i = 0; i < 14; i++) - { - DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + // Generate up to 30 arms for the rift. + // The first 14 are larger cracks to form the main hole at the impact point. + // The rest are longer, skinner cracks protruding outwards from it. + for (int i = 0; i < 14; i++) { - ArmStartingPosition = riftSpawnLocation, - Depth = 30f, - TotalPoints = 8, + DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + { + ArmStartingPosition = riftSpawnLocation, + Depth = 30f, + TotalPoints = 8, - MaxWidth = Main.rand.NextFloat(120f, 140f), - MinDistanceBetweenPoints = 80f, - MaxDistanceBetweenPoints = 120f, - MinPointAngularVariance = -6, - MaxPointAngularVariance = 6, + MaxWidth = Main.rand.NextFloat(100f, 120f), + MinDistanceBetweenPoints = 100f, + MaxDistanceBetweenPoints = 140f, + MinPointAngularVariance = -6, + MaxPointAngularVariance = 6, - ArmPoints = [], - }; - MainRiftCracks.Add(distortionRiftArm); - } + ArmPoints = [], + }; + MainRiftCracks.Add(distortionRiftArm); + } - int outerCracksAmount = Main.rand.Next(12, 17); - for (int i = 0; i < outerCracksAmount; i++) - { - DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + int outerCracksAmount = Main.rand.Next(12, 17); + for (int i = 0; i < outerCracksAmount; i++) { - ArmStartingPosition = riftSpawnLocation, - Depth = 30f, - TotalPoints = Main.rand.Next(6, 10), + DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + { + ArmStartingPosition = riftSpawnLocation, + Depth = 30f, + TotalPoints = Main.rand.Next(6, 10), - MaxWidth = Main.rand.NextFloat(6f, 9f), - MinDistanceBetweenPoints = 500f, - MaxDistanceBetweenPoints = 600f, - MinPointAngularVariance = Main.rand.Next(-10, -5), - MaxPointAngularVariance = Main.rand.Next(5, 10), + MaxWidth = Main.rand.NextFloat(6f, 9f), + MinDistanceBetweenPoints = 400f, + MaxDistanceBetweenPoints = 500f, + MinPointAngularVariance = Main.rand.Next(-10, -5), + MaxPointAngularVariance = Main.rand.Next(5, 10), - ArmPoints = [], - }; - OuterRiftCracks.Add(distortionRiftArm); - } + ArmPoints = [], + }; + OuterRiftCracks.Add(distortionRiftArm); + } - // Generate the points for each arm and add them all to the global arm list. - // Main cracks. - for (int i = 0; i < MainRiftCracks.Count; i++) - { - float minDistance = MainRiftCracks[i].MinDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; - float maxDistance = MainRiftCracks[i].MaxDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; - float minAngularVariance = MainRiftCracks[i].MinPointAngularVariance; - float maxAngularVariance = MainRiftCracks[i].MaxPointAngularVariance; - float placementAngle = i * MathHelper.TwoPi / MainRiftCracks.Count; + // Generate the points for each arm and add them all to the global arm list. + // Main cracks. + for (int i = 0; i < MainRiftCracks.Count; i++) + { + float minDistance = MainRiftCracks[i].MinDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; + float maxDistance = MainRiftCracks[i].MaxDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; + float minAngularVariance = MainRiftCracks[i].MinPointAngularVariance; + float maxAngularVariance = MainRiftCracks[i].MaxPointAngularVariance; + float placementAngle = i * MathHelper.TwoPi / MainRiftCracks.Count; - if (MainRiftCracks[i].ArmPoints.Count <= 0) - MainRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(MainRiftCracks[i].ArmStartingPosition, MainRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); - DistortionRiftArms.Add(MainRiftCracks[i]); - } + if (MainRiftCracks[i].ArmPoints.Count <= 0) + MainRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(MainRiftCracks[i].ArmStartingPosition, MainRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); + DistortionRiftArms.Add(MainRiftCracks[i]); + } - // Outer cracks. - for (int i = 0; i < OuterRiftCracks.Count; i++) - { - float minDistance = OuterRiftCracks[i].MinDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; - float maxDistance = OuterRiftCracks[i].MaxDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; - float minAngularVariance = OuterRiftCracks[i].MinPointAngularVariance; - float maxAngularVariance = OuterRiftCracks[i].MaxPointAngularVariance; - float placementAngle = i * MathHelper.TwoPi / OuterRiftCracks.Count; + // Outer cracks. + for (int i = 0; i < OuterRiftCracks.Count; i++) + { + float minDistance = OuterRiftCracks[i].MinDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; + float maxDistance = OuterRiftCracks[i].MaxDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; + float minAngularVariance = OuterRiftCracks[i].MinPointAngularVariance; + float maxAngularVariance = OuterRiftCracks[i].MaxPointAngularVariance; + float placementAngle = i * MathHelper.TwoPi / OuterRiftCracks.Count; - if (OuterRiftCracks[i].ArmPoints.Count <= 0) - OuterRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(OuterRiftCracks[i].ArmStartingPosition, OuterRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); - DistortionRiftArms.Add(OuterRiftCracks[i]); + if (OuterRiftCracks[i].ArmPoints.Count <= 0) + OuterRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(OuterRiftCracks[i].ArmStartingPosition, OuterRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); + DistortionRiftArms.Add(OuterRiftCracks[i]); + } + + Initialized = true; } } @@ -277,6 +249,10 @@ namespace CalamityMod.Skies spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + // Draw the rift aura. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawRiftAura(spriteBatch); + // Draw the cracked glass textures. if (minDepth >= 6f && maxDepth <= float.MaxValue) DrawRealityCracks(spriteBatch); @@ -294,72 +270,35 @@ namespace CalamityMod.Skies public void DrawRiftToRenderTarget() { + if (DistortionRiftArms == null || DistortionRiftArms.Count == 0) + return; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); for (int i = 0; i < DistortionRiftArms.Count; i++) { - Vector2 depthFactor = new(1f / DistortionRiftArms[i].Depth, 1.1f / DistortionRiftArms[i].Depth); + Vector2 depthFactor = new(1f / DistortionRiftArms[i].Depth, 0.9f / DistortionRiftArms[i].Depth); List parallaxedPoints = []; - for (int j = 0; j < DistortionRiftArms[i].ArmPoints.Count - 1; j++) + for (int j = 0; j < DistortionRiftArms[i].ArmPoints.Count; j++) parallaxedPoints.Add((DistortionRiftArms[i].ArmPoints[j] - screenCenter) * depthFactor + screenCenter); PrimitiveRenderer.RenderTrail(parallaxedPoints, new((completion) => MathHelper.Lerp(0f, DistortionRiftArms[i].MaxWidth, 1f - completion) * SkyIntensity, (_) => Color.White * 1f, null, false, useUnscaledMatrices: true), DistortionRiftArms[i].TotalPoints + 16); } } - private void GetCorrectDoGColor() - { - Color twlight = new(109, 21, 150); - Color lightBlue = new(0, 221, 250); - - if (DoGIndex != -1) - { - var DoG = Main.npc[DoGIndex].ModNPC(); - Color goalSkyColor = Color.Black; - if (DoG.isInAgressiveState) - goalSkyColor = Color.Fuchsia; - if (DoG.isInPassiveState) - goalSkyColor = lightBlue; - if (DoG.isInLaserWallState || DoG.isInPostWallState || DoG.postTeleportTimer > 0 || DoG.teleportTimer > 0 || DoG.NPC.localAI[2] < 180 && DoG.NPC.localAI[2] > 60) - goalSkyColor = twlight; - - //if (DoG.isInPostWallState || DoG.postTeleportTimer > 0 || DoG.teleportTimer > 0 || DoG.NPC.localAI[2] < 180 && DoG.NPC.localAI[2] > 60) - //{ - // if (DoG.Phase2Started) - // goalSkyColor = Color.Black; - // else - // goalSkyColor = new Color(117, 21, 161); - //} - - DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); - } - else - { - // Adopt the twlight color during laser walls if both monoliths are active simultaneously. - // Otherwise, use each phase's individual color depending on the monolith's color. - var goalSkyColor = Color.Black; - if (Main.LocalPlayer.Calamity().monolithDevourerPShader > 0) - goalSkyColor = Color.Fuchsia; - if (Main.LocalPlayer.Calamity().monolithDevourerBShader > 0) - goalSkyColor = lightBlue; - - DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); - } - } - private void DrawDistortionWinds(SpriteBatch spriteBatch) { Effect shader = CalamityShaders.DoGDistortionWindsShader; - - Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); Texture2D windsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; Texture2D highlightsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/SharpNoise").Value; Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise").Value; Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles").Value; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - shader.Parameters["overallOpacity"].SetValue(SkyIntensity * 0.6f); + shader.Parameters["overallOpacity"].SetValue(SkyIntensity); shader.Parameters["distortionStrength"].SetValue(0.3f); shader.Parameters["mainNoiseTextureScale"].SetValue(0.8f); shader.Parameters["distortionTextureScale"].SetValue(0.6f); @@ -370,8 +309,8 @@ namespace CalamityMod.Skies shader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); shader.Parameters["worldOffset"].SetValue(Main.screenPosition / windsTexture.Size() * 0.025f); - shader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.64f).ToVector3()); - shader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.32f).ToVector3()); + shader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.82f).ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, DoGSkyColor, 0.32f).ToVector3()); shader.Parameters["highlightsColor"].SetValue(DoGSkyColor.ToVector3()); Main.instance.GraphicsDevice.Textures[1] = highlightsTexture; @@ -390,11 +329,11 @@ namespace CalamityMod.Skies private void DrawRollingBackgroundFog(SpriteBatch spriteBatch) { Effect shader = CalamityShaders.DoGBackgroundFogShader; - - Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 3f); shader.Parameters["overallOpacity"].SetValue(SkyIntensity * 0.25f); shader.Parameters["distortionStrength"].SetValue(0.12f); @@ -420,23 +359,66 @@ namespace CalamityMod.Skies spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); } - private void DrawRealityCracks(SpriteBatch spriteBatch) + private void DrawRiftAura(SpriteBatch spriteBatch) { - Effect shader = CalamityShaders.CircularOpacityShader; + if (RealityCracks == null || RealityCracks.Count == 0) + return; + + Effect shader = CalamityShaders.DoGRiftAuraShader; + Texture2D riftAuraTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Smudges").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Swirls").Value; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["pixelSize"].SetValue(screenSize * 0.5f); + shader.Parameters["distortionStrength"].SetValue(0.78f); + + shader.Parameters["opacityCutoffValue"].SetValue(0.675f * SkyIntensity); + shader.Parameters["fadeoutPower"].SetValue(1.25f); + shader.Parameters["overallOpacity"].SetValue(0.6f); + + shader.Parameters["minBrightnessValue"].SetValue(0f); + shader.Parameters["brighterPixelColor"].SetValue(DoGSkyColor.ToVector3()); + shader.Parameters["gradientPrecision"].SetValue(8f); + + Main.instance.GraphicsDevice.Textures[1] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + + Vector2 depthFactor = new(1f / RealityCracks[0].Depth, 0.9f / RealityCracks[0].Depth); + Vector2 drawPosition = (RealityCracks[0].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition; + spriteBatch.Draw(riftAuraTexture, drawPosition, null, Color.White, Main.GlobalTimeWrappedHourly * MathHelper.TwoPi / 270f, riftAuraTexture.Size() * 0.5f, 1f, 0, 0f); + } + + private void DrawRealityCracks(SpriteBatch spriteBatch) + { + if (RealityCracks == null || RealityCracks.Count == 0) + return; + + Effect shader = CalamityShaders.DoGRealityCrackShader; Texture2D cracksTexture = ModContent.Request("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + shader.Parameters["opacityCutoffValue"].SetValue(0.8f * SkyIntensity); shader.Parameters["fadeoutPower"].SetValue(1f); - shader.Parameters["overallOpacity"].SetValue(0.2f); + shader.Parameters["overallOpacity"].SetValue(0.1015f); + + shader.Parameters["minBrightnessValue"].SetValue(0.6f); + shader.Parameters["darkerPixelColor"].SetValue(DoGSkyColor.ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.White.ToVector3()); + shader.CurrentTechnique.Passes[0].Apply(); for (int i = 0; i < RealityCracks.Count; i++) { - Vector2 depthFactor = new(1f / RealityCracks[i].Depth, 1.1f / RealityCracks[i].Depth); + Vector2 depthFactor = new(1f / RealityCracks[i].Depth, 0.9f / RealityCracks[i].Depth); Vector2 drawPosition = (RealityCracks[i].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition; - spriteBatch.Draw(cracksTexture, drawPosition, new Rectangle(0, 0, cracksTexture.Width, cracksTexture.Height), DoGSkyColor*0.75f, RealityCracks[i].Rotation, cracksTexture.Size() * 0.5f, RealityCracks[i].Scale * 0.5f, 0, 0f); + spriteBatch.Draw(cracksTexture, drawPosition, null, Color.White, RealityCracks[i].Rotation, cracksTexture.Size() * 0.5f, RealityCracks[i].Scale, 0, 0f); } } @@ -452,7 +434,7 @@ namespace CalamityMod.Skies metaballShader.Parameters["layerSize"]?.SetValue(distortionRiftContents.Size()); metaballShader.Parameters["screenSize"]?.SetValue(screenSize); metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["edgeColor"]?.SetValue(Color.Lerp(DoGSkyColor, Color.Black, 0.85f).ToVector4()); + metaballShader.Parameters["edgeColor"]?.SetValue(Color.Lerp(Color.Lerp(DoGSkyColor, Color.White, 0.6f), Color.Black, 0.15f).ToVector4()); Main.instance.GraphicsDevice.Textures[1] = distortionRiftContents; Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; @@ -461,6 +443,41 @@ namespace CalamityMod.Skies spriteBatch.Draw(distortionRift, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); } + private void GetCorrectDoGColor() + { + if (DoGIndex != -1) + { + var DoG = Main.npc[DoGIndex].ModNPC(); + Color goalSkyColor = Color.Black; + if (DoG.isInAgressiveState) + goalSkyColor = Color.Fuchsia; + if (DoG.isInPassiveState) + goalSkyColor = DoGLightBlue; + if (DoG.isInLaserWallState || DoG.isInPostWallState || DoG.postTeleportTimer > 0 || DoG.teleportTimer > 0 || DoG.NPC.localAI[2] < 180 && DoG.NPC.localAI[2] > 60) + goalSkyColor = DoGTwlight; + + //if (DoG.isInPostWallState || DoG.postTeleportTimer > 0 || DoG.teleportTimer > 0 || DoG.NPC.localAI[2] < 180 && DoG.NPC.localAI[2] > 60) + //{ + // if (DoG.Phase2Started) + // goalSkyColor = Color.Black; + // else + // goalSkyColor = new Color(117, 21, 161); + //} + + DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); + } + else + { + var goalSkyColor = Color.Black; + if (Main.LocalPlayer.Calamity().monolithDevourerPShader > 0) + goalSkyColor = Color.Fuchsia; + if (Main.LocalPlayer.Calamity().monolithDevourerBShader > 0) + goalSkyColor = DoGLightBlue; + + DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); + } + } + public override Color OnTileColor(Color inColor) => Color.Lerp(inColor, DoGSkyColor, SkyIntensity); public override float GetCloudAlpha() => 1f; @@ -472,17 +489,20 @@ namespace CalamityMod.Skies public override void Deactivate(params object[] args) { CanSkyBeActive = false; - RealityCracks.Clear(); - DistortionRiftArms.Clear(); - Initialized = false; + if (SkyIntensity <= 0.1f) + { + Initialized = false; + DistortionRiftArms?.Clear(); + RealityCracks?.Clear(); + } } public override void Reset() { CanSkyBeActive = false; - RealityCracks.Clear(); - DistortionRiftArms.Clear(); Initialized = false; + DistortionRiftArms?.Clear(); + RealityCracks?.Clear(); } } } diff --git a/Systems/Graphic/DoGVisualsManager.cs b/Systems/Graphic/DoGVisualsManager.cs index 08583e52bd..803143ed7c 100644 --- a/Systems/Graphic/DoGVisualsManager.cs +++ b/Systems/Graphic/DoGVisualsManager.cs @@ -85,32 +85,40 @@ namespace CalamityMod.Systems.Graphic public override void PostUpdateEverything() { - // Randomly flicker between different values to create a natural lightning effect in the background of the - // Distortion rift's clouds. - if (Main.rand.NextBool(200) && DoGSky.SkyIntensity > 0f && BackgroundLightningTimer <= 0f) + if (DoGSky.SkyIntensity > 0.1f) { - BackgroundLightningTimer = Main.rand.NextBool(10) ? Main.rand.Next(30, 45) : Main.rand.Next(5, 20); - BackgroundLightningMax = Main.rand.NextFloat(0.7f, 0.9f); + // Disable ambient sky entities while DoG's background effects are active. + if (SkyManager.Instance["Ambience"].IsActive()) + SkyManager.Instance["Ambience"].Deactivate(); + + // Randomly flicker between different values to create a natural lightning effect in the background of the + // Distortion rift's clouds. + if (Main.rand.NextBool(200) && DoGSky.SkyIntensity > 0f && BackgroundLightningTimer <= 0f) + { + BackgroundLightningTimer = Main.rand.NextBool(10) ? Main.rand.Next(30, 45) : Main.rand.Next(5, 20); + BackgroundLightningMax = Main.rand.NextFloat(0.7f, 0.9f); + } + + if (BackgroundLightningTimer > 0f) + { + float minFill = BackgroundLightningMax * 0.5f; + BackgroundLightningFill = Main.rand.NextFloat(minFill, BackgroundLightningMax); + BackgroundLightningTimer--; + } + else + { + if (BackgroundLightningTimer < 0f) + BackgroundLightningTimer = 0f; + BackgroundLightningFill = MathHelper.Lerp(BackgroundLightningFill, 0f, 0.05f); + } } - if (BackgroundLightningTimer > 0f) - { - float minFill = BackgroundLightningMax * 0.5f; - BackgroundLightningFill = Main.rand.NextFloat(minFill, BackgroundLightningMax); - BackgroundLightningTimer--; - } - else - { - if (BackgroundLightningTimer < 0f) - BackgroundLightningTimer = 0f; - BackgroundLightningFill = MathHelper.Lerp(BackgroundLightningFill, 0f, 0.05f); - } + } 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())) + if (DoGSky.SkyIntensity > 0f) FillProgress += 0.05f; else FillProgress -= 0.05f; @@ -134,9 +142,12 @@ namespace CalamityMod.Systems.Graphic 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. + // Fade out the sun and moon during DoG's fight. if (DoGSky.SkyIntensity > 0f) + { tempMushroomInfluence = DoGSky.SkyIntensity; + moonColor *= 1f - DoGSky.SkyIntensity; + } orig(self, sceneArea, moonColor, sunColor, tempMushroomInfluence); } @@ -150,12 +161,13 @@ namespace CalamityMod.Systems.Graphic 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); + + // Draw the primitives which comprise the rift to another render target. + DistortionRiftPrimitivesTarget.SwapTo(); if (SkyManager.Instance["CalamityMod:DevourerofGodsHead"].IsActive()) (SkyManager.Instance["CalamityMod:DevourerofGodsHead"] as DoGSky).DrawRiftToRenderTarget(); + Main.spriteBatch.End(); } @@ -200,15 +212,16 @@ namespace CalamityMod.Systems.Graphic { Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader; Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); - Color darkPixelColor = Color.Lerp(Color.Lerp(Color.Black, Color.DarkGray, 0.25f), Color.Black, BackgroundLightningFill * 0.8f); - Color brightPixelColor = Color.Lerp(Color.Lerp(Color.Black, DoGSky.DoGSkyColor, 0.3f), Color.Black, BackgroundLightningFill * 0.8f); + Color darkPixelColor = Color.Lerp(Color.Lerp(Color.Black, Color.DarkGray, 0.3f), Color.Black, BackgroundLightningFill * 0.8f); + Color brightPixelColor = Color.Lerp(Color.Lerp(Color.Black, DoGSky.DoGSkyColor, 0.6f), Color.Black, BackgroundLightningFill * 0.8f); rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - rollingCloudsShader.Parameters["overallOpacity"].SetValue(0.8f); - rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.12f); + rollingCloudsShader.Parameters["overallOpacity"].SetValue(1f); + rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.24f); rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(2f); rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f); rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f); @@ -221,7 +234,7 @@ namespace CalamityMod.Systems.Graphic rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(darkPixelColor.ToVector3()); rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(brightPixelColor.ToVector3()); - Main.instance.GraphicsDevice.Textures[1] = cloudsTexture; + Main.instance.GraphicsDevice.Textures[1] = distortionTexture; Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; Main.instance.GraphicsDevice.Textures[2] = erosionTexture;