group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
HitscanEffect.cpp File Reference

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>
Include dependency graph for HitscanEffect.cpp:

Functions

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.
 

Detailed Description

Implementation of hitscan energy beam with fBm path deviation.

Function Documentation

◆ 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
tSample position along the arc [0, 1].
seedBase seed for this noise instance.
timeElapsed animation time (drives temporal evolution).
octavesNumber of fBm octaves to sum.
Returns
Displacement value in approximately [-1, +1].
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash1()

static float hash1 ( int  n)
static

Good avalanche hash – gives uniform [0,1] output for any integer input.

Parameters
nInteger input.
Returns
Hashed value in [0, 1].
Here is the caller graph for this function:

◆ randf()

static float randf ( )
static

Return a random float in [0, 1].

Here is the caller graph for this function:

◆ vnoise()

static float vnoise ( float  t)
static

1-D value noise with cubic (smoothstep) interpolation.

Continuous in t.

Parameters
tSample position along the noise domain.
Returns
Noise value in [0, 1].
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
tSample position along the arc [0, 1].
seedBase fBm seed.
warpSeedSeed for the domain warp noise.
timeElapsed animation time.
octavesNumber of fBm octaves to sum.
Returns
Warped displacement value in approximately [-1, +1].
Here is the call graph for this function:
Here is the caller graph for this function: