Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EyeOfCthulhuShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _eyeColor;
10
11 private readonly Vector4 _veinColor;
12
13 private readonly Vector4 _backgroundColor;
14
15 public EyeOfCthulhuShader(Color eyeColor, Color veinColor, Color backgroundColor)
16 {
17 _eyeColor = eyeColor.ToVector4();
18 _veinColor = veinColor.ToVector4();
19 _backgroundColor = backgroundColor.ToVector4();
20 }
21
22 [RgbProcessor(/*Could not decode attribute arguments.*/)]
23 private void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
24 {
25 for (int i = 0; i < fragment.Count; i++)
26 {
27 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
28 Vector4 vector = Vector4.Lerp(_veinColor, _eyeColor, (float)Math.Sin(time + canvasPositionOfIndex.X * 4f) * 0.5f + 0.5f);
29 fragment.SetColor(i, vector);
30 }
31 }
32
33 [RgbProcessor(/*Could not decode attribute arguments.*/)]
34 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
35 {
36 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
37 //IL_0009: Unknown result type (might be due to invalid IL or missing references)
38 //IL_000f: Invalid comparison between Unknown and I4
39 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
40 if ((int)device.Type != 0 && (int)device.Type != 6)
41 {
42 ProcessLowDetail(device, fragment, quality, time);
43 return;
44 }
45 float num = time * 0.2f % 2f;
46 int num2 = 1;
47 if (num > 1f)
48 {
49 num = 2f - num;
50 num2 = -1;
51 }
52 Vector2 vector = new Vector2(num * 7f - 3.5f, 0f) + fragment.CanvasCenter;
53 for (int i = 0; i < fragment.Count; i++)
54 {
55 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
56 Vector4 vector2 = _backgroundColor;
57 Vector2 vector3 = canvasPositionOfIndex - vector;
58 float num3 = vector3.Length();
59 if (num3 < 0.5f)
60 {
61 float amount = 1f - MathHelper.Clamp((num3 - 0.5f + 0.2f) / 0.2f, 0f, 1f);
62 float num4 = MathHelper.Clamp((vector3.X + 0.5f - 0.2f) / 0.6f, 0f, 1f);
63 if (num2 == 1)
64 {
65 num4 = 1f - num4;
66 }
68 vector2 = Vector4.Lerp(vector2, value, amount);
69 }
70 fragment.SetColor(i, vector2);
71 }
72 }
73}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
void SetColor(int index, Vector4 color)
Definition Fragment.cs:97
Vector2 GetCanvasPositionOfIndex(int index)
Definition Fragment.cs:75
readonly RgbDeviceType Type
Definition RgbDevice.cs:8
static double Sin(double a)
void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
EyeOfCthulhuShader(Color eyeColor, Color veinColor, Color backgroundColor)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277