]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/noise.qc
Merge remote-tracking branch 'origin/tzork/vehicles-2'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / noise.qc
1 .float noise_baccum;
2 .float noise_paccum;
3 .float noise_paccum2;
4 .float noise_paccum3;
5 .float noise_bstate;
6 float Noise_Brown(entity e, float dt)
7 {
8         e.noise_baccum += random() * sqrt(dt); // same stddev for all dt
9         return e.noise_baccum;
10 }
11 float Noise_Pink(entity e, float dt)
12 {
13         float f;
14         f = dt * 60;
15         // http://home.earthlink.net/~ltrammell/tech/pinkalg.htm
16         if(random() > pow(0.3190, f))
17                 e.noise_paccum = 0.34848 * (2 * random() - 1);
18         if(random() > pow(0.7756, f))
19                 e.noise_paccum2 = 0.28768 * (2 * random() - 1);
20         if(random() > pow(0.9613, f))
21                 e.noise_paccum3 = 0.43488 * (2 * random() - 1);
22         return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3;
23 }
24 float Noise_White(entity e, float dt)
25 {
26         return random() * 2 - 1;
27 }
28 float Noise_Burst(entity e, float dt, float p)
29 {
30         if(random() > pow(p, dt))
31                 e.noise_bstate = !e.noise_bstate;
32         return 2 * e.noise_bstate - 1;
33 }