XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

DeathMod

【Terraria】DeathMod (now aka Soul Harvest)

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/DeathMod

为死亡领域远景加入稀有黑洞

edc44f6
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

2 个文件 +68 -2
Modified Common/DeathDomainBackdropTextureSystem.cs +66 -0
@@ -86,9 +86,75 @@ internal sealed class DeathDomainBackdropTextureSystem : ModSystem
86 86 color = Vector3.Lerp(color, starColor, 0.42f + star * 0.58f);
87 87 }
88 88
89 // Sparse, fixed singularities live only on the farthest plate. They do not
90 // animate on their own: parallax reveals them like distant landmarks while
91 // the nearer mountains and blood mist intermittently hide them again.
92 ApplyDistantBlackHole(ref color, u, v, 0.18f, 0.27f, 0.034f, 0.22f, 1.7f);
93 ApplyDistantBlackHole(ref color, u, v, 0.79f, 0.64f, 0.022f, -0.38f, 4.9f);
94
89 95 return Opaque(color);
90 96 }
91 97
98 private static void ApplyDistantBlackHole(
99 ref Vector3 color,
100 float u,
101 float v,
102 float centerU,
103 float centerV,
104 float radius,
105 float tilt,
106 float seed)
107 {
108 float dx = u - centerU;
109 if (dx > 0.5f)
110 dx -= 1f;
111 else if (dx < -0.5f)
112 dx += 1f;
113 float dy = v - centerV;
114 float reach = radius * 3.35f;
115 if (Math.Abs(dx) > reach || Math.Abs(dy) > reach)
116 return;
117
118 float radialDistance = (float)Math.Sqrt(dx * dx + dy * dy);
119 if (radialDistance > reach)
120 return;
121
122 float cosine = (float)Math.Cos(tilt);
123 float sine = (float)Math.Sin(tilt);
124 float localX = dx * cosine + dy * sine;
125 float localY = -dx * sine + dy * cosine;
126 float angle = (float)Math.Atan2(dy, dx);
127
128 // The surrounding stars and nebula are dimmed before the event horizon,
129 // suggesting gravitational lensing without requiring a distortion shader.
130 float gravityWell = 1f - SmoothRange(radius * 1.05f, reach, radialDistance);
131 color *= 1f - gravityWell * 0.52f;
132
133 float coreDistance = (float)Math.Sqrt(localX * localX + localY * localY * 1.16f);
134 float core = 1f - SmoothRange(radius * 0.7f, radius, coreDistance);
135 color = Vector3.Lerp(color, new Vector3(0.0008f, 0f, 0.004f), core * 0.985f);
136
137 float photonRing = SmoothRange(radius * 0.84f, radius * 1.02f, radialDistance)
138 * (1f - SmoothRange(radius * 1.02f, radius * 1.17f, radialDistance));
139 float brokenArc = 0.3f + 0.7f * Smooth01(
140 ((float)Math.Sin(angle * 7f + seed) + 0.42f) / 1.42f);
141 color += new Vector3(0.92f, 0.018f, 0.11f) * photonRing * brokenArc * 0.92f;
142
143 // A thin, tilted accretion disc crosses the core. Its rear half is muted so
144 // the black centre remains readable instead of becoming a bright red dot.
145 float discDistance = (float)Math.Sqrt(localX * localX + localY * localY * 24f);
146 float disc = SmoothRange(radius * 1.04f, radius * 1.28f, discDistance)
147 * (1f - SmoothRange(radius * 2.35f, radius * 2.8f, discDistance));
148 float discBreakup = 0.48f + 0.52f * Smooth01(
149 ((float)Math.Sin(localX / radius * 15f + seed * 2.1f) + 0.7f) / 1.7f);
150 float rearFade = localY < 0f ? 0.48f : 1f;
151 color += new Vector3(0.74f, 0.006f, 0.075f) * disc * discBreakup * rearFade * 0.76f;
152
153 float lensHalo = SmoothRange(radius * 1.12f, radius * 1.45f, radialDistance)
154 * (1f - SmoothRange(radius * 2.15f, radius * 3f, radialDistance));
155 color += new Vector3(0.12f, 0.008f, 0.09f) * lensHalo * (0.28f + brokenArc * 0.24f);
156 }
157
92 158 private static Color BuildMiddlePixel(float u, float v)
93 159 {
94 160 Vector3 color = Vector3.Zero;
Modified Common/DeathDomainVisualSystem.cs +2 -2
@@ -210,8 +210,8 @@ internal class DeathDomainVisualSystem : ModSystem
210 210 for (int layer = 0; layer < 3; layer++)
211 211 {
212 212 float parallax = layer switch { 0 => 0.07f, 1 => 0.18f, _ => 0.34f };
213 float horizontalViewFraction = layer switch { 0 => 0.96f, 1 => 0.9f, _ => 0.84f };
214 float verticalViewFraction = layer switch { 0 => 0.96f, 1 => 0.9f, _ => 0.86f };
213 float horizontalViewFraction = layer switch { 0 => 0.68f, 1 => 0.9f, _ => 0.84f };
214 float verticalViewFraction = layer switch { 0 => 0.78f, 1 => 0.9f, _ => 0.86f };
215 215 float opacity = layer switch
216 216 {
217 217 0 => MathHelper.Lerp(0.88f, 1f, mastery) * reveal,