Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DD2Shader.cs
Go to the documentation of this file.
3
5
6public class DD2Shader : ChromaShader
7{
8 private readonly Vector4 _darkGlowColor;
9
10 private readonly Vector4 _lightGlowColor;
11
12 public DD2Shader(Color darkGlowColor, Color lightGlowColor)
13 {
14 _darkGlowColor = darkGlowColor.ToVector4();
15 _lightGlowColor = lightGlowColor.ToVector4();
16 }
17
18 [RgbProcessor(/*Could not decode attribute arguments.*/)]
19 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
20 {
21 //IL_0007: Unknown result type (might be due to invalid IL or missing references)
22 Vector2 vector = fragment.CanvasCenter;
23 if ((int)quality == 0)
24 {
25 vector = new Vector2(1.7f, 0.5f);
26 }
27 time *= 0.5f;
28 for (int i = 0; i < fragment.Count; i++)
29 {
30 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
31 Vector4 value = new Vector4(0f, 0f, 0f, 1f);
32 float num = (canvasPositionOfIndex - vector).Length();
33 float num2 = num * num * 0.75f;
34 float num3 = (num - time) % 1f;
35 if (num3 < 0f)
36 {
37 num3 += 1f;
38 }
39 num3 = ((!(num3 > 0.8f)) ? (num3 / 0.8f) : (num3 * (1f - (num3 - 1f + 0.2f) / 0.2f)));
40 Vector4 value2 = Vector4.Lerp(_darkGlowColor, _lightGlowColor, num3 * num3);
41 num3 *= MathHelper.Clamp(1f - num2, 0f, 1f) * 0.75f + 0.25f;
42 value = Vector4.Lerp(value, value2, num3);
43 if (num < 0.5f)
44 {
45 float amount = 1f - MathHelper.Clamp((num - 0.5f + 0.4f) / 0.4f, 0f, 1f);
46 value = Vector4.Lerp(value, _lightGlowColor, amount);
47 }
48 fragment.SetColor(i, value);
49 }
50 }
51}
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 Vector4 _darkGlowColor
Definition DD2Shader.cs:8
DD2Shader(Color darkGlowColor, Color lightGlowColor)
Definition DD2Shader.cs:12
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
Definition DD2Shader.cs:19
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277