Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PillarShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _primaryColor;
10
11 private readonly Vector4 _secondaryColor;
12
13 public PillarShader(Color primaryColor, Color secondaryColor)
14 {
15 _primaryColor = primaryColor.ToVector4();
16 _secondaryColor = secondaryColor.ToVector4();
17 }
18
19 [RgbProcessor(/*Could not decode attribute arguments.*/)]
20 private void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
21 {
22 for (int i = 0; i < fragment.Count; i++)
23 {
24 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
25 Vector4 vector = Vector4.Lerp(_primaryColor, _secondaryColor, (float)Math.Sin(time * 2.5f + canvasPositionOfIndex.X) * 0.5f + 0.5f);
26 fragment.SetColor(i, vector);
27 }
28 }
29
30 [RgbProcessor(/*Could not decode attribute arguments.*/)]
31 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
32 {
33 Vector2 vector = new Vector2(1.5f, 0.5f);
34 time *= 4f;
35 for (int i = 0; i < fragment.Count; i++)
36 {
37 Vector2 vector2 = fragment.GetCanvasPositionOfIndex(i) - vector;
38 float num = vector2.Length() * 2f;
39 float num2 = (float)Math.Atan2(vector2.Y, vector2.X);
40 float amount = (float)Math.Sin(num * 4f - time - num2) * 0.5f + 0.5f;
42 if (num < 1f)
43 {
44 float num3 = num / 1f;
45 num3 *= num3 * num3;
46 float amount2 = (float)Math.Sin(4f - time - num2) * 0.5f + 0.5f;
47 vector3 = Vector4.Lerp(_primaryColor, _secondaryColor, amount2) * num3;
48 }
49 vector3.W = 1f;
50 fragment.SetColor(i, vector3);
51 }
52 }
53}
void SetColor(int index, Vector4 color)
Definition Fragment.cs:97
Vector2 GetCanvasPositionOfIndex(int index)
Definition Fragment.cs:75
static double Atan2(double y, double x)
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)
PillarShader(Color primaryColor, Color secondaryColor)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277