From c3ee433cd1e23765311c676d7ad635fbfe3dfae0 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Thu, 31 Jul 2025 00:46:56 -0400 Subject: [PATCH] DoGSky touchups + misc fixes and changes - Made some visual improvements to DoG's CustomSky, involving the creation of two new shaders, DoGRealityCrackShader and DoGRiftAuraShader - - Descriptions for each can be found in CalamityShaders - Ambient sky entities are now disabled while DoG's CustomSky is active - The code for the distortion rift's lightning effect should now no longer run at all times and only when DoG's CustomSky is active - DoG no longer has its death animation shader applied to all segments individually. Instead, all segments are now drawn to a render target, which is what the shader is then applied to via a new BaseRenderer class, DoGDeathAnimationRenderer. This was done to prevent all of DoG's sprites from suddenly rendering in full brightness during his death animation - - Additionally, DoGDisintegration's code has been cleaned up - Fixed DoG not spawning out of the correct teleport rift projectile on GFB due to not properly accommodating for fake rifts when searching for the correct teleport location - Improved the visuals of DoGTeleportRift and decreased the visual intensity of fake rifts - DoG's teleport rift indicator icon will no longer appear on GFB due to the inclusion of fake rifts as a mechanic on that seed. There are many differences between the real rift and fake rifts which should make up for this --- CalPlayer/CalamityPlayerDrawEffects.cs | 4 +- Effects/CalamityShaders.cs | 13 + Effects/CircularOpacityShader.fx | 2 + Effects/DoGDisintegration.fx | 42 +- Effects/DoGDisintegration.xnb | Bin 2336 -> 1852 bytes Effects/DoGRealityCrackShader.fx | 54 +++ Effects/DoGRealityCrackShader.xnb | Bin 0 -> 2420 bytes Effects/DoGRiftAuraShader.fx | 62 +++ Effects/DoGRiftAuraShader.xnb | Bin 0 -> 3632 bytes .../DoGDeathAnimationRenderer.cs | 112 ++++++ NPCs/CalamityGlobalNPC.cs | 4 + NPCs/DevourerofGods/DevourerofGodsBody.cs | 14 +- NPCs/DevourerofGods/DevourerofGodsHead.cs | 67 ++-- NPCs/DevourerofGods/DevourerofGodsTail.cs | 14 +- Projectiles/Boss/DoGTeleportRift.cs | 81 ++-- Skies/DoGSky.cs | 374 +++++++++--------- Systems/Graphic/DoGVisualsManager.cs | 69 ++-- 17 files changed, 579 insertions(+), 333 deletions(-) create mode 100644 Effects/DoGRealityCrackShader.fx create mode 100644 Effects/DoGRealityCrackShader.xnb create mode 100644 Effects/DoGRiftAuraShader.fx create mode 100644 Effects/DoGRiftAuraShader.xnb create mode 100644 Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs 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 bbc4f237f381c2214c711fd87ea8cc324e0221c4..a841c844da141a2542a947461ca48df3e498aa51 100644 GIT binary patch literal 1852 zcmb7E&uSY@pE4%7i_vJ&!y_YRHou2IUve#NI+3c-LYg@V*^WVI$ zyHC+T{&(^)EHbNtJgrGC5DcjZz?_Is|?&Y0EyR@-jgl8@@nJ=s}WEX+4s zi(B%-wp_?9EaZtrJf9`{_4vX26Uq!9;%G4TMW`RcG=uS7XilCfXj_&i>vET)lJ+Z4 zJVNCZrfu7^amc%_)kDUbL6nGm{b=Ti!$zU$H1uh1)phQ=((^uZ-!mzaICl=%G`H5Y z+ET@2zrQpIvw@*wGW<0L?xww6bv&C>hRwOMPcG(on8!8f+Pkt{vmeXIKaH8|7nhST z%2PF|T70JC!0WQP)3G1)X}Ku4Rti_hi#_hOT9LY>AoKh56Ar6GsB@!`G@&(fayN$dYk#p98JCs=K1v> z%o~+j#jNe{hr=v6_q%o*%BAf5#q6bp`Rx2+p+LjoI9Q|V`n8%c8mr^r`^nvGA_il8 zE_FA8%%7p>Fm!)khF-z=uRO6lCB5DMpXE46A;;Ry`1=yCH|x9>$Hsv{rOM4Z2OkG> zwA!eY!n|`Qv>)4An9tujLDTEnm)F0+IDn)f+}S@8C6kmM04@^w#e60 z$WOq=nvZV=C@ElNa6&Gx6aBe|SZXh}XW$>V!5yrq^|abg92rHizx4%e0Hc>C*6}7m z-$49VQG9`Qf*lNqXfKRuz~|K-Yv! literal 2336 zcmbVNL2nyH6n^VCtxJuJ3I`6B*b7oBMV8|@l`ADR#BLzMfUzAgQl+rnjN?@uuUYS^ z3F5H5APz`?=%t9mBK1%ummI>091wp1R53TJ59{gq-a&wulJ#p}7ABUbvta~-2Muh+fXJC;msme=RT zhL=L#`vb$Y+&$(}pOymnRDGKDO#>A+T$FvHU!J1pns^P{jn!xK_onDCu)byO2=sD~ z4;3xH1BHUc7UyMqjwu>AKa+!XkXF!YFeM+jLDe8{~U96=1!HE zX?1*s^K5qc>uU~#X>}~KYPd$Uf36qDsrE8R)f!s(c(>ytQ8$J|BCbTewYrtKF?*iXf_!02$ z3O@x-DfP+%mlWOxb`|~=@FRu)0{m3rMSgKGULvdD?;A9bx;hv-Z6oF?n;qko7d@3SPO zBeg6`>|emUJLi}8$HBpYTtUWQx_{VUxLMfD)8t;)=Neb_w`dGr=q~Ai9M~n9rpDR93>b>>6 zJl);@lVch=HrLg?pU2Eq-zdC7mD+kM1^@Hx>aDMT{cG;HJWV$WGql#ORpK@3fjoY) z=Qtjd-!S*wp20FOK4~8i%_b-l5c%cB#l`aX4<6j;biOFFe6Bb7=J^lOdzoajJ$9}Q_yT2BCh~<30xX@=+8!D31IRQv>(Kr#|T&7 zey|#iXTVQ 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 0000000000000000000000000000000000000000..fb989a9310cf0f7ef6a43a51e1240cd58996aaca GIT binary patch literal 2420 zcmcIkKWrOi6n}SiVwVOv&`K~MaY77$EGsohl}HT@IhwY@fJvOnVxYa)pPN%Icj0^{ zsnp@RGX%lV@hUMnO9lppN-!{1VyVQ+;DMn-2FA+A@7;HIJ*T!>2A=hN@BO~_|NGPY ze06_H@y-w_-z%S)E!XKf9k0@~jmny9?23KI-Kpq~?FrkfTU{3~mE&+>Y%Shhvaa}BGk)q7i(+4@x6X*fH=US6E9wmOSj z;zC<2%q=W@NKDG3BGDgbPae)js{B*Vgu|zblwZLo4}MFk>HiF*Eu$+M;()VKE?%jn z76=YG4nrl#&bI=ESzqiKEz`S0sgFOw=N$V;W4-4&oz4xz>WOE5zfACZ6?g}8bb4Oh z*%vOGCG|a-;KR9gO?%ZfZ*P0H=yp%#dN*kVcGZC6nB%+&PN)pwTB6{43w$@D--rBjMt=nP?~I;D zUs|TOOOTrx{VwGD8U0Bt^XG9!{vnR}8?c8NJV_OT68WzwNNN}k!>>tie7wqMdWC&} zP2&@vacv3MkI>~Fs1!hEItHsWP3-bJ_%V18VfhIAC&supm8M3pHzF)If_)HS>Ijy- zQ+b-f8vi6cx6emMM+&Nx92=ebjNAj*b644zW6u1TD|hPV?sacgZ_ZKrNNMk_zpq`Z zZPc`lZGOKr-PzqUEeK1M>cz^^LbXy|oS!G;ABKIZuV2|v)aKeS)YEUw2VrPX`f~1cG z<0bZ)iES9?cSoVQG**JK39m8bPUYgaiz$hlqZMsjF2<4={AE4?l|cMzd`UD_pi%(% zS1=v*`yUbcm*3_i34y3|_)N|n$MPW+OTlXNe3W1_IHux&d(A0SguV$TU+N0vzOPUS zCRL%lU!Z<~I`D)jjDh<;=J@~&e~H0AV0)DcSRcgpEOXp}KMhRAD*KBiE=94qR_-NRJFvs74xfPg#Jr>4c+dU?oA7Qo literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1042c870247798a66b4552b122331c30e445889d GIT binary patch literal 3632 zcmc&$O>7%Q6rQ#7*Ve5g=%I%qEW`m&WTk0Rr4misIQ?onhV{Bl zQ6)CFLOG=3f&huF!~txn;?M&JXp7VXh$4F6fYcr+@}WowMWPZFNLjvbX2)J94hJqg zd%W*`^WK~9y`7!)^edz1JB|KrLKs(!m#w^Gm+gX^o-XCmhn?KKdER!;rZaZQHA`;# zP@!Pv-Q#9%)^z$(8+jjbatm`-zTB5OVLD~YF6|pk_w&=2%2bMO#WDAl%!=#eihZex z%1qJ9zhqvRvd@~OeZzwT`NHswxog%O>K_`~EhxsNtwQ{;W#!9WX{sM%Q?TmAl)f34 z4vd}3Z2Tsm&E(4Fl)1=Nh4ve3cqruwTxPAZYdbF3YVUz~JoLL5@i(AzP&zSOYu==; zeLtlUO4K(A%sywL=;EsjxxD3GXvW;v0k}qEo`l`xHR(EL>5MzqjN7h>w28CTBAJS7 z7YZkG#R^zzj^i7|q0ORzduvzR3H!Y1z-+{L8^n;~yj2=?tTS_N$t;)Gto6kPaqRgS zCpT+hUrjh>-r`0H*JH?|NE~l-#FY1O!CEwnlh&JTKI`IqU$`HjHZba1$aO{%HJu5@ zXY8VlDjCcB!#xxg?zb`f$Z@OS9;`UIiCnoXwg8(l^K&KZjf%NT?4Zqf#&UUHcVKAg zgK|I{xSqmTjM$f;e-g33g#J^+egwTYQhXouqY?Xc=ocgQ`_QjP?7Pr^i`X3?nTqsj zA=K$|Dx$v^aySZXEP`ul0YvK$H$jUB!D{f1$V?p^-3jv#CIrT3jy5Dk9(5?{e#OL! zgz*DBhR!mCd-_?7L5X!rjP(+m#)tzkM3*Q+r?B>z=x*_QTVk79un#5H(}G=-SXT@7 zwZuAFF!nHpU5AUfj~{Z0o+}+9fjNGZwAo`dLoz4(_R{7#ujy)aOw&i7QMKCIwOgLw z^$%E^N43pKvF4y^K5MnGj##6Ph4Sg$r~5_YU66Y2`17fwM`^pMhqYJ!oyg` z@G*!GyN*HZw!~DQ?}pgV5>wCV!w_5Fn%cU4!?i`)G;dwZzx7JKD{AZ4aTotf{}Slm zwk4MVvxT&bD?AMf5gHdsK zdOXt&z!3e7BalZC-|G}z+uC`)$0(du5vYbYmD=p>%mydn;3=jtZ@aBgz%(&4SzQhBIyHWk8Ym6R()~L$!lK` z-wOPfbHgJYPknY{_|Law4~cJ6{&4q*-MW|jc0ci?!o7RRW4CVn^~}ikckYZ3?*(3~ zR!895kf+f;oZ%kckjvCNq2nx*I-Hh8Ptqq&-GGjsLXUe1QTI^?z6tn`EpHZMK72g9 zgJX#Ig!tW~Bj@o}pwANh^&BwxXFaS3pDy@3#<=S<#!xxmHN^JI(};;7pCPIk^~;8M zATe|pcHrTUt-noV{Vus~2i8|doMUY&PI&l#;wMoD>!+XgQT^zUHZf&0 zw^%YzYqLMh$v!{uPRhKjk9Hlk1b(;d4>94XUd5!YIP@TI7F@I7D*PtKJ_J7d%$hWR za9<)9RktCzB~hp1)``47a`>aDB_@*4A9_YlUG|AN;K$g|?m~QB=3qXx7wYIo(1;h} zS5F|G`B8@C${bC*iuf$n;odVmJoCQd8`HRlXYZ=YuQ0^Q_2Z&j`fR~|WPBX_*a!NO zdkoy-79^xxwbzaP&FWJzS`ysnT-xP9@7w2#vBo8CZjWxr4ki>jduE%?( z__KF)4}ZUW0Y5%l()) + 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;