Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CavernShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _backColor;
10
11 private readonly Vector4 _frontColor;
12
13 private readonly float _speed;
14
15 public CavernShader(Color backColor, Color frontColor, float speed)
16 {
17 _backColor = backColor.ToVector4();
18 _frontColor = frontColor.ToVector4();
19 _speed = speed;
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(_backColor, _frontColor, (float)Math.Sin(time * _speed + canvasPositionOfIndex.X) * 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 time *= _speed * 0.5f;
37 float num = time % 1f;
38 bool num2 = time % 2f > 1f;
39 Vector4 vector = (num2 ? _frontColor : _backColor);
41 num *= 1.2f;
42 for (int i = 0; i < fragment.Count; i++)
43 {
44 float staticNoise = NoiseHelper.GetStaticNoise(fragment.GetCanvasPositionOfIndex(i) * 0.5f + new Vector2(0f, time * 0.5f));
45 Vector4 vector2 = vector;
46 staticNoise += num;
47 if (staticNoise > 0.999f)
48 {
49 float amount = MathHelper.Clamp((staticNoise - 0.999f) / 0.2f, 0f, 1f);
50 vector2 = Vector4.Lerp(vector2, value, amount);
51 }
52 fragment.SetColor(i, vector2);
53 }
54 }
55}
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
static double Sin(double a)
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
CavernShader(Color backColor, Color frontColor, float speed)
void ProcessLowDetail(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