Implementation of hitscan energy beam with fBm path deviation.
More...
#include "HitscanEffect.hpp"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
|
| static float | randf () |
| | Return a random float in [0, 1].
|
| |
| static float | hash1 (int n) |
| | Good avalanche hash – gives uniform [0,1] output for any integer input.
|
| |
| static float | vnoise (float t) |
| | 1-D value noise with cubic (smoothstep) interpolation.
|
| |
| static float | fbm (float t, float seed, float time, int octaves=4) |
| | 4-octave fBm displacement (lacunarity ~ 3, persistence ~ 0.4).
|
| |
| static float | wfbm (float t, float seed, float warpSeed, float time, int octaves=4) |
| | Domain-warped fBm: warp t before sampling.
|
| |
Implementation of hitscan energy beam with fBm path deviation.
◆ fbm()
| static float fbm |
( |
float |
t, |
|
|
float |
seed, |
|
|
float |
time, |
|
|
int |
octaves = 4 |
|
) |
| |
|
static |
4-octave fBm displacement (lacunarity ~ 3, persistence ~ 0.4).
Higher octaves run at 2x the animation speed of the one below them, giving slow large-scale breathing overlaid with fast fine crackle.
- Parameters
-
| t | Sample position along the arc [0, 1]. |
| seed | Base seed for this noise instance. |
| time | Elapsed animation time (drives temporal evolution). |
| octaves | Number of fBm octaves to sum. |
- Returns
- Displacement value in approximately [-1, +1].
◆ hash1()
| static float hash1 |
( |
int |
n | ) |
|
|
static |
Good avalanche hash – gives uniform [0,1] output for any integer input.
- Parameters
-
- Returns
- Hashed value in [0, 1].
◆ randf()
Return a random float in [0, 1].
◆ vnoise()
| static float vnoise |
( |
float |
t | ) |
|
|
static |
1-D value noise with cubic (smoothstep) interpolation.
Continuous in t.
- Parameters
-
| t | Sample position along the noise domain. |
- Returns
- Noise value in [0, 1].
◆ wfbm()
| static float wfbm |
( |
float |
t, |
|
|
float |
seed, |
|
|
float |
warpSeed, |
|
|
float |
time, |
|
|
int |
octaves = 4 |
|
) |
| |
|
static |
Domain-warped fBm: warp t before sampling.
Warping causes frequency content to vary spatially – some regions are smooth, others suddenly jagged – matching how real lightning looks.
- Parameters
-
| t | Sample position along the arc [0, 1]. |
| seed | Base fBm seed. |
| warpSeed | Seed for the domain warp noise. |
| time | Elapsed animation time. |
| octaves | Number of fBm octaves to sum. |
- Returns
- Warped displacement value in approximately [-1, +1].