Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CorruptSurfaceShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _baseColor;
10
11 private readonly Vector4 _skyColor;
12
14
16 {
17 _baseColor = color.ToVector4();
18 _skyColor = Vector4.Lerp(_baseColor, Color.DeepSkyBlue.ToVector4(), 0.5f);
19 }
20
21 public CorruptSurfaceShader(Color vineColor, Color skyColor)
22 {
23 _baseColor = vineColor.ToVector4();
24 _skyColor = skyColor.ToVector4();
25 }
26
27 public override void Update(float elapsedTime)
28 {
29 _lightColor = Main.ColorOfTheSkies.ToVector4() * 0.75f + Vector4.One * 0.25f;
30 }
31
32 [RgbProcessor(/*Could not decode attribute arguments.*/)]
33 private void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
34 {
36 for (int i = 0; i < fragment.Count; i++)
37 {
38 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
39 Vector4 vector = Vector4.Lerp(_baseColor, value, (float)Math.Sin(time * 0.5f + canvasPositionOfIndex.X) * 0.5f + 0.5f);
40 fragment.SetColor(i, vector);
41 }
42 }
43
44 [RgbProcessor(/*Could not decode attribute arguments.*/)]
45 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
46 {
47 Vector4 vector = _skyColor * _lightColor;
48 for (int i = 0; i < fragment.Count; i++)
49 {
50 Point gridPositionOfIndex = fragment.GetGridPositionOfIndex(i);
51 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
52 float staticNoise = NoiseHelper.GetStaticNoise(gridPositionOfIndex.X);
53 staticNoise = (staticNoise * 10f + time * 0.4f) % 10f;
54 float num = 1f;
55 if (staticNoise > 1f)
56 {
57 num = MathHelper.Clamp(1f - (staticNoise - 1.4f), 0f, 1f);
58 staticNoise = 1f;
59 }
60 float num2 = (float)Math.Sin(canvasPositionOfIndex.X) * 0.3f + 0.7f;
61 float num3 = staticNoise - (1f - canvasPositionOfIndex.Y);
62 Vector4 vector2 = vector;
63 if (num3 > 0f)
64 {
65 float num4 = 1f;
66 if (num3 < 0.2f)
67 {
68 num4 = num3 * 5f;
69 }
70 vector2 = Vector4.Lerp(vector2, _baseColor, num4 * num);
71 }
72 if (canvasPositionOfIndex.Y > num2)
73 {
74 vector2 = _baseColor;
75 }
76 fragment.SetColor(i, vector2);
77 }
78 }
79}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
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 double Sin(double a)
CorruptSurfaceShader(Color vineColor, Color skyColor)
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
static float GetStaticNoise(int index)
static Microsoft.Xna.Framework.Color ColorOfTheSkies
Definition Main.cs:2577
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277