Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GolemShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _glowColor;
10
11 private readonly Vector4 _coreColor;
12
13 private readonly Vector4 _backgroundColor;
14
15 public GolemShader(Color glowColor, Color coreColor, Color backgroundColor)
16 {
17 _glowColor = glowColor.ToVector4();
18 _coreColor = coreColor.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 Vector4 value = Vector4.Lerp(_backgroundColor, _coreColor, Math.Max(0f, (float)Math.Sin(time * 0.5f)));
26 for (int i = 0; i < fragment.Count; i++)
27 {
28 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
29 Vector4 vector = Vector4.Lerp(value, _glowColor, Math.Max(0f, (float)Math.Sin(canvasPositionOfIndex.X * 2f + time + 101f)));
30 fragment.SetColor(i, vector);
31 }
32 }
33
34 [RgbProcessor(/*Could not decode attribute arguments.*/)]
35 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
36 {
37 float num = 0.5f + (float)Math.Sin(time * 3f) * 0.1f;
38 Vector2 vector = new Vector2(1.6f, 0.5f);
39 for (int i = 0; i < fragment.Count; i++)
40 {
41 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
42 Point gridPositionOfIndex = fragment.GetGridPositionOfIndex(i);
43 Vector4 vector2 = _backgroundColor;
44 float num2 = (NoiseHelper.GetStaticNoise(gridPositionOfIndex.Y) * 10f + time * 2f) % 10f - Math.Abs(canvasPositionOfIndex.X - vector.X);
45 if (num2 > 0f)
46 {
47 float amount = Math.Max(0f, 1.2f - num2);
48 if (num2 < 0.2f)
49 {
50 amount = num2 * 5f;
51 }
52 vector2 = Vector4.Lerp(vector2, _glowColor, amount);
53 }
54 float num3 = (canvasPositionOfIndex - vector).Length();
55 if (num3 < num)
56 {
57 float amount2 = 1f - MathHelper.Clamp((num3 - num + 0.1f) / 0.1f, 0f, 1f);
58 vector2 = Vector4.Lerp(vector2, _coreColor, amount2);
59 }
60 fragment.SetColor(i, vector2);
61 }
62 }
63}
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 Abs(double value)
static double Sin(double a)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
GolemShader(Color glowColor, Color coreColor, Color backgroundColor)
void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
static float GetStaticNoise(int index)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277