返回提交历史
Modified
Common/DeathDomainBackdropTextureSystem.cs
+15
-27
Modified
Common/DeathDomainVisualSystem.cs
+53
-11
XFEstudio/DeathMod
修正领域视差回溯并重制近景血雾
d4c381c
代码差异
2 个文件
+68
-38
@@ -53,7 +53,7 @@ internal sealed class DeathDomainBackdropTextureSystem : ModSystem
53
53
{
54
54
0 => BuildFarPixel(x, y, u, v),
55
55
1 => BuildMiddlePixel(u, v),
56
_ => BuildNearPixel(x, u, v)
56
_ => BuildNearPixel(u, v)
57
57
};
58
58
}
59
59
}
@@ -130,35 +130,23 @@ internal sealed class DeathDomainBackdropTextureSystem : ModSystem
130
130
return Premultiplied(color, alpha);
131
131
}
132
132
133
private static Color BuildNearPixel(int x, float u, float v)
133
private static Color BuildNearPixel(float u, float v)
134
134
{
135
const int cellWidth = 64;
136
int cell = x / cellWidth;
137
float cellPosition = (x % cellWidth + 0.5f) / cellWidth;
138
float seed = Hash01(cell, 0, 4271);
139
float halfWidth = MathHelper.Lerp(0.18f, 0.34f, Hash01(cell, 1, 7727));
140
float spireTip = MathHelper.Lerp(0.43f, 0.64f, seed);
141
float towerShoulder = spireTip + Math.Abs(cellPosition - 0.5f) / halfWidth * 0.18f;
142
bool inTower = Math.Abs(cellPosition - 0.5f) <= halfWidth && v >= towerShoulder;
143
float ground = 0.86f + (float)Math.Sin(u * MathHelper.TwoPi * 8f) * 0.018f;
144
bool inGround = v >= ground;
145
if (!inTower && !inGround)
135
float broadMist = Wave(u, v, 2f, 1f, 0.35f)
136
+ Wave(u, v, 4f, -2f, 2.2f) * 0.52f
137
+ Wave(u, v, 7f, 3f, 4.6f) * 0.24f;
138
float curledMist = Wave(u, v, 3f, -3f, 1.1f)
139
+ Wave(u, v, 9f, 4f, 3.7f) * 0.34f;
140
float body = Smooth01((broadMist + 0.72f) / 2.2f);
141
float curls = Smooth01((curledMist + 0.82f) / 1.85f);
142
float alpha = MathHelper.Clamp(body * 0.34f + body * curls * 0.32f, 0f, 0.62f);
143
if (alpha <= 0.002f)
146
144
return Color.Transparent;
147
145
148
float edgeDistance = Math.Abs(v - towerShoulder);
149
Vector3 color = edgeDistance < 0.008f && inTower
150
? new Vector3(0.36f, 0.012f, 0.075f)
151
: new Vector3(0.012f, 0.002f, 0.026f);
152
float alpha = inGround ? 0.96f : 0.88f;
153
154
// Narrow crimson windows keep the skyline readable without brightening it.
155
bool window = inTower
156
&& Math.Abs(cellPosition - 0.5f) < 0.035f
157
&& v > towerShoulder + 0.07f
158
&& PositiveModulo(v * 34f + cell * 0.73f, 1f) < 0.18f;
159
if (window)
160
color = new Vector3(0.68f, 0.012f, 0.09f);
161
146
Vector3 color = Vector3.Lerp(
147
new Vector3(0.18f, 0.002f, 0.035f),
148
new Vector3(0.72f, 0.018f, 0.12f),
149
curls * 0.72f);
162
150
return Premultiplied(color, alpha);
163
151
}
164
152
@@ -254,8 +254,8 @@ internal class DeathDomainVisualSystem : ModSystem
254
254
Texture2D texture = DeathDomainBackdropTextureSystem.GetLayer(layer);
255
255
float viewWidth = texture.Width * horizontalViewFraction;
256
256
float viewHeight = texture.Height * verticalViewFraction;
257
float sourceOffsetX = PingPong(worldCenter.X * parallax, texture.Width - viewWidth);
258
float sourceOffsetY = PingPong(worldCenter.Y * parallax, texture.Height - viewHeight);
257
float sourceOffsetX = PositiveModulo(worldCenter.X * parallax, texture.Width);
258
float sourceOffsetY = PositiveModulo(worldCenter.Y * parallax, texture.Height);
259
259
260
260
for (int index = 0; index < bands; index++)
261
261
{
@@ -312,6 +312,57 @@ internal class DeathDomainVisualSystem : ModSystem
312
312
if (destinationWidth <= 0.05f || destinationHeight <= 0.05f || opacity <= 0.001f)
313
313
return;
314
314
315
float remainingSourceHeight = sourceHeight;
316
float consumedSourceHeight = 0f;
317
float wrappedSourceY = PositiveModulo(sourceY, texture.Height);
318
while (remainingSourceHeight > 0.001f)
319
{
320
float sourceHeightPart = Math.Min(remainingSourceHeight, texture.Height - wrappedSourceY);
321
float destinationHeightPart = destinationHeight * sourceHeightPart / sourceHeight;
322
float destinationY = destination.Y + destinationHeight * consumedSourceHeight / sourceHeight;
323
float remainingSourceWidth = sourceWidth;
324
float consumedSourceWidth = 0f;
325
float wrappedSourceX = PositiveModulo(sourceX, texture.Width);
326
while (remainingSourceWidth > 0.001f)
327
{
328
float sourceWidthPart = Math.Min(remainingSourceWidth, texture.Width - wrappedSourceX);
329
float destinationWidthPart = destinationWidth * sourceWidthPart / sourceWidth;
330
float destinationX = destination.X + destinationWidth * consumedSourceWidth / sourceWidth;
331
DrawBackdropPart(
332
batch,
333
texture,
334
new Vector2(destinationX, destinationY),
335
destinationWidthPart,
336
destinationHeightPart,
337
wrappedSourceX,
338
wrappedSourceY,
339
sourceWidthPart,
340
sourceHeightPart,
341
opacity);
342
343
remainingSourceWidth -= sourceWidthPart;
344
consumedSourceWidth += sourceWidthPart;
345
wrappedSourceX = 0f;
346
}
347
348
remainingSourceHeight -= sourceHeightPart;
349
consumedSourceHeight += sourceHeightPart;
350
wrappedSourceY = 0f;
351
}
352
}
353
354
private static void DrawBackdropPart(
355
SpriteBatch batch,
356
Texture2D texture,
357
Vector2 destination,
358
float destinationWidth,
359
float destinationHeight,
360
float sourceX,
361
float sourceY,
362
float sourceWidth,
363
float sourceHeight,
364
float opacity)
365
{
315
366
int sourceLeft = Math.Clamp((int)Math.Floor(sourceX), 0, texture.Width - 1);
316
367
int sourceTop = Math.Clamp((int)Math.Floor(sourceY), 0, texture.Height - 1);
317
368
int sourceRight = Math.Clamp((int)Math.Ceiling(sourceX + sourceWidth), sourceLeft + 1, texture.Width);
@@ -329,15 +380,6 @@ internal class DeathDomainVisualSystem : ModSystem
329
380
0f);
330
381
}
331
382
332
private static float PingPong(float value, float length)
333
{
334
if (length <= 0.001f)
335
return 0f;
336
337
float wrapped = PositiveModulo(value, length * 2f);
338
return length - Math.Abs(wrapped - length);
339
}
340
341
383
private static void DrawSovereignSeal(SpriteBatch batch, Texture2D pixel, Vector2 center, int mastery, float animation)
342
384
{
343
385
float time = Main.GlobalTimeWrappedHourly;