Loot Beam Shader (Rarity Light Pillar)
A column of light over dropped loot, like in an ARPG. White core, colored glow, light streaming up, a few sparks and a bright pool at the foot. rarity 0 to 4 picks common, uncommon, rare, epic or legendary, and higher rarity makes the beam wider and brighter. Set rarity to -1 to use your own color.
Put it on a tall QuadMesh of about 1.8 x 6 as Material Override, bottom edge on the item. The quad turns to the camera but stays upright, so it reads as a column from any side. appear fades it in when the item drops. My first version cut the glow off at the quad edge in a hard rectangle, so now the edges fade out.
It’s additive, turn Glow on. No textures, and it looked the same on Forward+, Mobile and Compatibility in 4.4 and 4.7.
The code was written with the help of an AI coding assistant.
I wrote this as a small take on the rarity beams in my Level Up, Loot & Heal VFX pack for Godot 4, which also has level-up, buff and pickup effects.
https://gennai.itch.io/level-up-loot-heal-vfx-godot-4?utm_source=godotshaders&utm_medium=referral&utm_campaign=lootbeam
Shader code
// Loot Rarity Beam for Godot 4
// MIT License. Copyright (c) 2026 gennai (https://gennai.itch.io)
//
// A column of light for dropped loot. It has a white core, a soft coloured glow, light
// that streams upward, small sparks that rise inside it and a bright pool at the foot.
// The colour comes from rarity: 0 common, 1 uncommon, 2 rare, 3 epic, 4 legendary. The
// higher the rarity, the brighter, wider and sparklier it gets.
//
// Put it on a MeshInstance3D with a tall QuadMesh (for example 1.6 x 6) as Material
// Override. The quad turns to face the camera and stays upright, so it looks like a column
// from every side. Put the bottom of the quad on the item. Change rarity per drop; for your
// own colour set rarity to -1 and use custom_color.
// No textures: the pattern is computed in the shader with sin-free hashes, so it looks
// the same on every renderer.
shader_type spatial;
render_mode unshaded, blend_add, depth_draw_never, cull_disabled, shadows_disabled, fog_disabled;
group_uniforms beam;
// 0 common, 1 uncommon, 2 rare, 3 epic, 4 legendary. -1 uses custom_color.
uniform int rarity : hint_range(-1, 4) = 2;
// Colour used when rarity is -1.
uniform vec4 custom_color : source_color = vec4(1.0, 0.4, 0.8, 1.0);
// Brightness. Values above 1 bloom when glow is on.
uniform float intensity : hint_range(0.0, 8.0) = 1.3;
// Fades the beam in from 0 to 1 when the item drops.
uniform float appear : hint_range(0.0, 1.0) = 1.0;
group_uniforms motion;
// How fast the light streams upward.
uniform float stream_speed : hint_range(0.0, 3.0) = 0.8;
// Amount of sparks. They increase with rarity.
uniform float sparks : hint_range(0.0, 1.0) = 0.7;
// Changes the pattern, so two beams do not match.
uniform float seed : hint_range(0.0, 100.0) = 0.0;
const vec3 LB_COLORS[5] = vec3[5](
vec3(0.85, 0.88, 0.95),
vec3(0.25, 1.0, 0.35),
vec3(0.2, 0.55, 1.0),
vec3(0.7, 0.25, 1.0),
vec3(1.0, 0.55, 0.08));
float lb_hash(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
float lb_noise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(lb_hash(i), lb_hash(i + vec2(1.0, 0.0)), f.x),
mix(lb_hash(i + vec2(0.0, 1.0)), lb_hash(i + vec2(1.0, 1.0)), f.x), f.y);
}
void vertex() {
// Upright billboard: faces the camera but keeps the node's up axis. Scale is kept.
vec3 up = normalize(MODEL_MATRIX[1].xyz);
vec3 right = normalize(cross(up, INV_VIEW_MATRIX[2].xyz));
vec3 fwd = cross(right, up);
mat4 bb = mat4(vec4(right * length(MODEL_MATRIX[0].xyz), 0.0),
vec4(up * length(MODEL_MATRIX[1].xyz), 0.0),
vec4(fwd * length(MODEL_MATRIX[2].xyz), 0.0),
MODEL_MATRIX[3]);
MODELVIEW_MATRIX = VIEW_MATRIX * bb;
}
void fragment() {
float x = (UV.x - 0.5) * 2.0;
float y = 1.0 - UV.y;
vec3 col = rarity < 0 ? custom_color.rgb : LB_COLORS[clamp(rarity, 0, 4)];
float rr = rarity < 0 ? 2.0 : float(rarity);
float t = TIME * stream_speed;
float s = seed * 1.7;
// width: the beam is a little wider at the foot and gets wider with rarity
float w = (0.14 + 0.035 * rr) * (1.0 + 0.6 * (1.0 - smoothstep(0.0, 0.15, y)));
float ax = abs(x);
float core = exp(-pow(ax / (w * 0.35), 2.0));
float glow = exp(-pow(ax / w, 2.0));
float halo = exp(-pow(ax / (w * 2.2), 2.0)) * 0.25;
// streams of light running up the beam
float st = lb_noise(vec2(x * 3.0 + s, y * 2.5 - t)) * 0.6 + lb_noise(vec2(x * 7.0 + s + 4.0, y * 5.0 - t * 1.7)) * 0.4;
float stream = mix(0.55, 1.15, st);
// fade at the top and a quick fade-in from the base while appearing
float top = 1.0 - smoothstep(0.35, 1.0, y);
float grow = smoothstep(0.0, 1.0, appear * 1.4 - y * 0.6);
float body = (glow * 0.8 + core * 0.9 + halo) * stream * top * grow;
// sparks rising inside the beam
float spk = 0.0;
float cols = 5.0 + rr;
float gx = (x * 0.5 + 0.5) * cols;
float cx = floor(gx);
for (int k = -1; k <= 1; k++) {
float c = cx + float(k);
float h = lb_hash(vec2(c, s));
float spd = 0.35 + 0.5 * lb_hash(vec2(c, s + 3.0));
float py = fract(t * spd * 0.6 + h * 7.0);
float px = (c + 0.5 + (lb_hash(vec2(c, s + 9.0)) - 0.5) * 0.6) / cols * 2.0 - 1.0;
vec2 d = vec2(x - px, (y - py * 0.9) * 0.4);
float on = step(lb_hash(vec2(c, s + 1.0)), 0.35 + 0.1 * rr);
spk += on * exp(-dot(d, d) * 900.0) * (1.0 - py);
}
spk *= sparks * (0.5 + 0.2 * rr) * (1.0 - smoothstep(0.5, 1.0, y)) * step(ax, w * 1.6);
// bright pool and flare at the foot
float foot = exp(-pow(y / 0.05, 2.0)) * exp(-pow(ax / (w * 2.2), 2.0));
float foot_core = exp(-pow(y / 0.02, 2.0)) * exp(-pow(ax / (w * 3.0), 2.0));
vec3 hot = mix(col, vec3(1.0), 0.75);
vec3 rgb = col * (body * (0.9 + 0.18 * rr) + foot * 1.2) + hot * (core * stream * top * grow * 0.35 + spk * 1.4 + foot_core);
float edge = 1.0 - smoothstep(0.6, 1.0, ax);
rgb *= edge;
float v = clamp(body + spk + foot, 0.0, 1.0) * edge;
ALBEDO = rgb * intensity * appear;
ALPHA = v;
}



Comments 0
No comments yet.