customizable noise

This commit is contained in:
vis2k 2021-03-16 16:30:27 +08:00
parent e9081c468c
commit c957500710

View File

@ -66,6 +66,9 @@ public void Awake()
void OnEnable() { wrap.enabled = true; }
void OnDisable() { wrap.enabled = false; }
// noise function can be replaced if needed
protected virtual float Noise(float time) => Mathf.PerlinNoise(time, time);
// helper function to simulate latency
float SimulateLatency(int channeldId)
{
@ -73,8 +76,7 @@ float SimulateLatency(int channeldId)
// no spikes isn't realistic.
// sin is too predictable / no realistic.
// perlin is still deterministic and random enough.
float sample = Time.time * latencySpikeSpeedMultiplier;
float spike = Mathf.PerlinNoise(sample, sample) * latencySpikeMultiplier;
float spike = Noise(Time.time * latencySpikeSpeedMultiplier) * latencySpikeMultiplier;
// base latency
switch (channeldId)