Damage / Low-Health Vignette with Heartbeat Pulse
A drop-in “you’re hurt” screen effect for action, shooter, survival and horror games: a coloured vignette that closes in from the screen edges, pulses with a two-beat heartbeat, wobbles slightly, splits red/blue at the edges and greys out the picture as health drops. Drive a single `intensity` uniform from your health value (or tween it up on a hit and back to 0) and you’re done. One canvas_item shader, no textures needed.
USAGE:
Add a CanvasLayer above your game, add a ColorRect inside it, set its anchors to Full Rect and Mouse Filter to Ignore, then give it a ShaderMaterial with this shader. It reads the screen behind it (hint_screen_texture), so it works on top of 2D and 3D.
Example (GDScript): material.set_shader_parameter(“intensity”, 1.0 – float(hp) / max_hp)
or for a hit flash: var tw = create_tween(); tw.tween_method(func(v): material.set_shader_parameter(“intensity”, v), 1.0, 0.0, 0.6)
Uniforms:
– vignette_color – colour of the edge glow (alpha = how opaque it gets)
– intensity – 0 = off, 1 = full effect; drive this from code
– radius – distance from the centre where the vignette starts (it shrinks as intensity rises)
– softness – width of the edge falloff
– pulse_speed – heartbeat speed (0 = no pulse)
– pulse_amount – how far each beat pushes the edge inwards
– distortion – organic wobble of the vignette shape
– desaturate – how much colour drains from the screen at full intensity
– chroma_offset – red/blue split in pixels near the edges
Works in Godot 4.3+ (Compatibility, Forward+, Mobile).
AI-assisted (code + text)
Make every hit land with sound too: free Combat SFX sampler: https://crtforge.pages.dev/combat-sfx-sampler/ and the full Fantasy RPG Combat SFX pack: https://assetsmithpixels.itch.io/fantasy-rpg-combat-sfx
Shader code
shader_type canvas_item;
// Damage / Low-Health Vignette - MIT License - Godot 4.3+
// Put on a full-screen ColorRect in a CanvasLayer above the game.
uniform vec4 vignette_color : source_color = vec4(0.75, 0.0, 0.05, 1.0);
uniform float intensity : hint_range(0.0, 1.0) = 0.0; // drive from code: 0 = off, 1 = full
uniform float radius : hint_range(0.0, 1.5) = 0.55; // where the edge glow starts
uniform float softness : hint_range(0.01, 1.0) = 0.45; // edge falloff width
uniform float pulse_speed : hint_range(0.0, 10.0) = 3.0; // heartbeat speed (0 = no pulse)
uniform float pulse_amount : hint_range(0.0, 1.0) = 0.25; // how much the pulse moves the edge
uniform float distortion : hint_range(0.0, 0.05) = 0.008; // wobble of the edge shape
uniform float desaturate : hint_range(0.0, 1.0) = 0.5; // greys out the screen as intensity rises
uniform float chroma_offset : hint_range(0.0, 8.0) = 2.0; // red/blue split in pixels at the edges
uniform sampler2D screen_tex : hint_screen_texture, filter_linear_mipmap;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float noise(vec2 p) {
vec2 i = floor(p); vec2 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x), f.y);
}
void fragment() {
vec2 uv = SCREEN_UV;
vec2 centered = uv - 0.5;
float aspect = SCREEN_PIXEL_SIZE.y / SCREEN_PIXEL_SIZE.x;
centered.x *= aspect;
float d = length(centered);
// heartbeat: two quick beats then a rest
float t = TIME * pulse_speed;
float beat = pow(max(sin(t), 0.0), 8.0) + 0.6 * pow(max(sin(t - 0.6), 0.0), 8.0);
float wobble = (noise(uv * 6.0 + TIME * 0.5) - 0.5) * distortion * 10.0;
float r = radius * (1.0 - intensity * 0.5) - beat * pulse_amount * 0.15 * intensity + wobble;
float edge = smoothstep(r, r + softness, d) * intensity;
vec2 off = centered / max(d, 0.0001) * SCREEN_PIXEL_SIZE * chroma_offset * edge;
vec3 col;
col.r = texture(screen_tex, uv + off).r;
col.g = texture(screen_tex, uv).g;
col.b = texture(screen_tex, uv - off).b;
float grey = dot(col, vec3(0.299, 0.587, 0.114));
col = mix(col, vec3(grey), desaturate * intensity);
col = mix(col, vignette_color.rgb, clamp(edge * vignette_color.a, 0.0, 1.0));
COLOR = vec4(col, 1.0);
}

Comments 0
No comments yet.