Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UndergroundMushroomShader.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 private readonly Vector4 _baseColor = new Color(10, 10, 10).ToVector4();
10
11 private readonly Vector4 _edgeGlowColor = new Color(0, 0, 255).ToVector4();
12
13 private readonly Vector4 _sporeColor = new Color(255, 230, 150).ToVector4();
14
15 [RgbProcessor(/*Could not decode attribute arguments.*/)]
16 private void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
17 {
18 for (int i = 0; i < fragment.Count; i++)
19 {
20 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
21 Vector4 vector = Vector4.Lerp(_edgeGlowColor, _sporeColor, (float)Math.Sin(time * 0.5f + canvasPositionOfIndex.X) * 0.5f + 0.5f);
22 fragment.SetColor(i, vector);
23 }
24 }
25
26 [RgbProcessor(/*Could not decode attribute arguments.*/)]
27 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
28 {
29 for (int i = 0; i < fragment.Count; i++)
30 {
31 Point gridPositionOfIndex = fragment.GetGridPositionOfIndex(i);
32 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
34 float num = ((NoiseHelper.GetStaticNoise(gridPositionOfIndex.X) * 10f + time * 0.2f) % 10f - (1f - canvasPositionOfIndex.Y)) * 2f;
35 if (num > 0f)
36 {
37 float amount = Math.Max(0f, 1.5f - num);
38 if (num < 0.5f)
39 {
40 amount = num * 2f;
41 }
43 }
44 float staticNoise = NoiseHelper.GetStaticNoise(canvasPositionOfIndex * 0.3f + new Vector2(0f, time * 0.1f));
45 staticNoise = Math.Max(0f, 1f - staticNoise * (1f + (1f - canvasPositionOfIndex.Y) * 4f));
46 staticNoise *= Math.Max(0f, (canvasPositionOfIndex.Y - 0.3f) / 0.7f);
47 value = Vector4.Lerp(value, _edgeGlowColor, staticNoise);
48 fragment.SetColor(i, value);
49 }
50 }
51}
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 Sin(double a)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static float GetStaticNoise(int index)
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
void ProcessLowDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277