Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
Loading...
Searching...
No Matches
shockwave.h File Reference

Visual shockwave effect for N-body confinement boundary impacts. More...

#include "gl_common.h"
#include <cglm/types.h>
#include <stdbool.h>
Include dependency graph for shockwave.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ShockwaveEvent
 One active shockwave expanding from an impact point. More...
 
struct  ShockwaveRenderer
 Manages and renders active shockwave effects. More...
 

Enumerations

enum  { SHOCKWAVE_MAX_ACTIVE = 16 }
 

Functions

bool shockwave_renderer_init (ShockwaveRenderer *renderer)
 Initializes shockwave renderer (shader + GPU resources).
 
void shockwave_renderer_cleanup (ShockwaveRenderer *renderer)
 Releases all GPU resources.
 
void shockwave_emit (ShockwaveRenderer *renderer, const vec3 position, const vec3 color, float velocity, float sim_time)
 Registers a new shockwave at the given position.
 
void shockwave_update (ShockwaveRenderer *renderer, float sim_time)
 Removes expired shockwaves based on current simulation time.
 
void shockwave_draw (const ShockwaveRenderer *renderer, mat4 view, mat4 proj, vec3 camera_pos, float sim_time, int screen_w, int screen_h)
 Draws all active shockwaves as billboard quads with lensing.
 

Variables

static const float SHOCKWAVE_DURATION = 1.2F * 3.0F
 
static const float SHOCKWAVE_MAX_RADIUS = 6.0F
 
static const float SHOCKWAVE_MIN_VELOCITY = 0.05F
 
static const float SHOCKWAVE_HDR_INTENSITY = 4.0F
 

Detailed Description

Visual shockwave effect for N-body confinement boundary impacts.

When a body crosses the confinement radius, a radial energy ring expands from the impact point and fades out. Rendered as screen-aligned quads that sample the scene behind them and apply radial UV distortion with chromatic aberration — a localized lens-like refraction effect.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Maximum simultaneous active shockwaves.

Enumerator
SHOCKWAVE_MAX_ACTIVE 

Function Documentation

◆ shockwave_draw()

void shockwave_draw ( const ShockwaveRenderer *  renderer,
mat4  view,
mat4  proj,
vec3  camera_pos,
float  sim_time,
int  screen_w,
int  screen_h 
)

Draws all active shockwaves as billboard quads with lensing.

Performs a grab pass (copies scene_color_tex to an internal texture) then draws billboard quads that sample the copy and apply radial UV distortion with chromatic aberration.

Should be called after scene geometry, before post-processing.

Parameters
rendererRenderer state.
viewView matrix.
projProjection matrix.
camera_posCamera world position.
sim_timeCurrent simulation time.
screen_wViewport width in pixels.
screen_hViewport height in pixels.
Here is the call graph for this function:

◆ shockwave_emit()

void shockwave_emit ( ShockwaveRenderer *  renderer,
const vec3  position,
const vec3  color,
float  velocity,
float  sim_time 
)

Registers a new shockwave at the given position.

Oldest event is evicted if the buffer is full.

Parameters
swRenderer state.
positionWorld-space impact point.
colorBody albedo color.
velocityRadial velocity at impact (determines intensity).
sim_timeCurrent simulation time.

◆ shockwave_renderer_cleanup()

void shockwave_renderer_cleanup ( ShockwaveRenderer *  renderer)

Releases all GPU resources.

Here is the call graph for this function:

◆ shockwave_renderer_init()

bool shockwave_renderer_init ( ShockwaveRenderer *  renderer)

Initializes shockwave renderer (shader + GPU resources).

Returns
true on success, false on shader load failure.
Here is the call graph for this function:

◆ shockwave_update()

void shockwave_update ( ShockwaveRenderer *  renderer,
float  sim_time 
)

Removes expired shockwaves based on current simulation time.

Variable Documentation

◆ SHOCKWAVE_DURATION

const float SHOCKWAVE_DURATION = 1.2F * 3.0F
static

Shockwave lifetime in seconds.

◆ SHOCKWAVE_HDR_INTENSITY

const float SHOCKWAVE_HDR_INTENSITY = 4.0F
static

HDR intensity for the shockwave ring (drives bloom).

◆ SHOCKWAVE_MAX_RADIUS

const float SHOCKWAVE_MAX_RADIUS = 6.0F
static

Maximum ring expansion radius in world units.

◆ SHOCKWAVE_MIN_VELOCITY

const float SHOCKWAVE_MIN_VELOCITY = 0.05F
static

Minimum velocity to trigger a shockwave (avoids spam from bodies barely grazing the boundary).