Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SepiaScreenShaderData.cs
Go to the documentation of this file.
4
6
8{
9 public SepiaScreenShaderData(string passName)
10 : base(passName)
11 {
12 }
13
14 public override void Update(GameTime gameTime)
15 {
16 float x = (Main.screenPosition.Y + (float)(Main.screenHeight / 2)) / 16f;
17 float num = 1f - Utils.SmoothStep((float)Main.worldSurface, (float)Main.worldSurface + 30f, x);
18 Vector3 value;
19 Vector3 vector = (value = new Vector3(0.191f, -0.054f, -0.221f));
20 Vector3 value2 = vector * 0.5f;
21 Vector3 value3 = new Vector3(0f, -0.03f, 0.15f);
22 Vector3 value4 = new Vector3(-0.11f, 0.01f, 0.16f);
23 float cloudAlpha = Main.cloudAlpha;
24 GetDaylightPowers(out var nightlightPower, out var daylightPower, out var moonPower, out var dawnPower);
25 float num2 = nightlightPower * 0.13f;
26 if (Main.starGame)
27 {
28 float num3 = (float)Main.starGameMath() - 1f;
29 nightlightPower = num3;
30 daylightPower = 1f - num3;
31 moonPower = num3;
32 dawnPower = 1f - num3;
33 num2 = nightlightPower * 0.13f;
34 }
35 else if (!Main.dayTime)
36 {
37 if (Main.GetMoonPhase() == MoonPhase.Full)
38 {
39 value = new Vector3(-0.19f, 0.01f, 0.22f);
40 num2 += 0.07f * moonPower;
41 }
42 if (Main.bloodMoon)
43 {
44 value = new Vector3(0.2f, -0.1f, -0.221f);
45 num2 = 0.2f;
46 }
47 }
48 nightlightPower *= num;
49 daylightPower *= num;
50 moonPower *= num;
51 dawnPower *= num;
52 UseOpacity(1f);
53 UseIntensity(1.4f - daylightPower * 0.2f);
54 float value5 = 0.3f - num2 * nightlightPower;
55 value5 = MathHelper.Lerp(value5, 0.1f, cloudAlpha);
56 float value6 = 0.2f;
57 value5 = MathHelper.Lerp(value5, value6, 1f - num);
58 UseProgress(value5);
59 Vector3 value7 = Vector3.Lerp(vector, value, moonPower);
60 value7 = Vector3.Lerp(value7, value3, dawnPower);
61 value7 = Vector3.Lerp(value7, value4, cloudAlpha);
62 value7 = Vector3.Lerp(value7, value2, 1f - num);
63 UseColor(value7);
64 }
65
66 private static void GetDaylightPowers(out float nightlightPower, out float daylightPower, out float moonPower, out float dawnPower)
67 {
68 nightlightPower = 0f;
69 daylightPower = 0f;
70 moonPower = 0f;
71 Vector2 dayTimeAsDirectionIn24HClock = Utils.GetDayTimeAsDirectionIn24HClock();
72 Vector2 dayTimeAsDirectionIn24HClock2 = Utils.GetDayTimeAsDirectionIn24HClock(4.5f);
73 Vector2 dayTimeAsDirectionIn24HClock3 = Utils.GetDayTimeAsDirectionIn24HClock(0f);
74 float fromValue = Vector2.Dot(dayTimeAsDirectionIn24HClock, dayTimeAsDirectionIn24HClock3);
75 float fromValue2 = Vector2.Dot(dayTimeAsDirectionIn24HClock, dayTimeAsDirectionIn24HClock2);
76 nightlightPower = Utils.Remap(fromValue, -0.2f, 0.1f, 0f, 1f);
77 daylightPower = Utils.Remap(fromValue, 0.1f, -1f, 0f, 1f);
78 dawnPower = Utils.Remap(fromValue2, 0.66f, 1f, 0f, 1f);
79 if (!Main.dayTime)
80 {
81 float num = (float)(Main.time / 32400.0) * 2f;
82 if (num > 1f)
83 {
84 num = 2f - num;
85 }
86 moonPower = Utils.Remap(num, 0f, 0.25f, 0f, 1f);
87 }
88 }
89}
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static void GetDaylightPowers(out float nightlightPower, out float daylightPower, out float moonPower, out float dawnPower)
ScreenShaderData UseProgress(float progress)
ScreenShaderData UseIntensity(float intensity)
ScreenShaderData UseOpacity(float opacity)
ScreenShaderData UseColor(float r, float g, float b)
static double time
Definition Main.cs:1284
static MoonPhase GetMoonPhase()
Definition Main.cs:3058
static double starGameMath(double value=1.0)
Definition Main.cs:59630
static float cloudAlpha
Definition Main.cs:1302
static double worldSurface
Definition Main.cs:1272
static bool starGame
Definition Main.cs:2597
static bool dayTime
Definition Main.cs:1282
static bool bloodMoon
Definition Main.cs:1296
static int screenHeight
Definition Main.cs:1721
static float Remap(float fromValue, float fromMin, float fromMax, float toMin, float toMax, bool clamped=true)
Definition Utils.cs:233
static float SmoothStep(float min, float max, float x)
Definition Utils.cs:83
static Vector2 GetDayTimeAsDirectionIn24HClock()
Definition Utils.cs:364
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121
static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount)
Definition Vector3.cs:307