Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PirateInvasionShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _cannonBallColor;
10
11 private readonly Vector4 _splashColor;
12
13 private readonly Vector4 _waterColor;
14
15 private readonly Vector4 _backgroundColor;
16
17 public PirateInvasionShader(Color cannonBallColor, Color splashColor, Color waterColor, Color backgroundColor)
18 {
19 _cannonBallColor = cannonBallColor.ToVector4();
20 _splashColor = splashColor.ToVector4();
21 _waterColor = waterColor.ToVector4();
22 _backgroundColor = backgroundColor.ToVector4();
23 }
24
25 [RgbProcessor(/*Could not decode attribute arguments.*/)]
26 private void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
27 {
28 for (int i = 0; i < fragment.Count; i++)
29 {
30 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
31 Vector4 vector = Vector4.Lerp(_waterColor, _cannonBallColor, (float)Math.Sin(time * 0.5f + canvasPositionOfIndex.X) * 0.5f + 0.5f);
32 fragment.SetColor(i, vector);
33 }
34 }
35
36 [RgbProcessor(/*Could not decode attribute arguments.*/)]
37 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
38 {
39 for (int i = 0; i < fragment.Count; i++)
40 {
41 Point gridPositionOfIndex = fragment.GetGridPositionOfIndex(i);
42 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
43 gridPositionOfIndex.X /= 2;
44 float num = (NoiseHelper.GetStaticNoise(gridPositionOfIndex.X) * 40f + time * 1f) % 40f;
45 float amount = 0f;
46 float num2 = num - canvasPositionOfIndex.Y / 1.2f;
47 if (num > 1f)
48 {
49 float num3 = 1f - canvasPositionOfIndex.Y / 1.2f;
50 amount = (1f - Math.Min(1f, num2 - num3)) * (1f - Math.Min(1f, num3 / 1f));
51 }
53 if (num2 > 0f)
54 {
55 float amount2 = Math.Max(0f, 1.2f - num2 * 4f);
56 if (num2 < 0.1f)
57 {
58 amount2 = num2 / 0.1f;
59 }
60 vector = Vector4.Lerp(vector, _cannonBallColor, amount2);
61 vector = Vector4.Lerp(vector, _splashColor, amount);
62 }
63 if (canvasPositionOfIndex.Y > 0.8f)
64 {
65 vector = _waterColor;
66 }
67 fragment.SetColor(i, vector);
68 }
69 }
70}
Point GetGridPositionOfIndex(int index)
Definition Fragment.cs:81
void SetColor(int index, Vector4 color)
Definition Fragment.cs:97
Vector2 GetCanvasPositionOfIndex(int index)
Definition Fragment.cs:75
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Sin(double a)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static float GetStaticNoise(int index)
PirateInvasionShader(Color cannonBallColor, Color splashColor, Color waterColor, Color backgroundColor)
void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277