Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IceShader.cs
Go to the documentation of this file.
1using System;
4
6
7public class IceShader : ChromaShader
8{
9 private readonly Vector4 _baseColor;
10
11 private readonly Vector4 _iceColor;
12
13 private readonly Vector4 _shineColor = new Vector4(1f, 1f, 0.7f, 1f);
14
15 public IceShader(Color baseColor, Color iceColor)
16 {
17 _baseColor = baseColor.ToVector4();
18 _iceColor = iceColor.ToVector4();
19 }
20
21 [RgbProcessor(/*Could not decode attribute arguments.*/)]
22 private void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
23 {
24 for (int i = 0; i < fragment.Count; i++)
25 {
26 Vector2 canvasPositionOfIndex = fragment.GetCanvasPositionOfIndex(i);
27 float dynamicNoise = NoiseHelper.GetDynamicNoise(new Vector2((canvasPositionOfIndex.X - canvasPositionOfIndex.Y) * 0.2f, 0f), time / 5f);
28 dynamicNoise = Math.Max(0f, 1f - dynamicNoise * 1.5f);
29 float dynamicNoise2 = NoiseHelper.GetDynamicNoise(new Vector2((canvasPositionOfIndex.X - canvasPositionOfIndex.Y) * 0.3f, 0.3f), time / 20f);
30 dynamicNoise2 = Math.Max(0f, 1f - dynamicNoise2 * 5f);
31 Vector4 value = Vector4.Lerp(_baseColor, _iceColor, dynamicNoise);
32 value = Vector4.Lerp(value, _shineColor, dynamicNoise2);
33 fragment.SetColor(i, value);
34 }
35 }
36}
void SetColor(int index, Vector4 color)
Definition Fragment.cs:97
Vector2 GetCanvasPositionOfIndex(int index)
Definition Fragment.cs:75
static byte Max(byte val1, byte val2)
Definition Math.cs:738
IceShader(Color baseColor, Color iceColor)
Definition IceShader.cs:15
void ProcessHighDetail(RgbDevice device, Fragment fragment, EffectDetailLevel quality, float time)
Definition IceShader.cs:22
static float GetDynamicNoise(int index, float currentTime)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277