Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(effects): a Hologram effect, from holo-stage

Jareer86d4a5c9166f
diff --git a/src/crates/concat-effects/packages/concat.hologram/effect.toml b/src/crates/concat-effects/packages/concat.hologram/effect.toml
new file mode 100644
index 00000000..2966f9ce
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.hologram/effect.toml
@@ -0,0 +1,72 @@
+[effect]
+id = "concat.hologram"
+name = "Hologram"
+kind = "effect"
+category = "Stylize"
+order = 48
+intensity = "glow"
+aliases = ["hologram"]
+description = "The picture as a sci-fi projection: its hue thrown away for a blue ramp, edges glowing, scan lines drifting, a refresh sweep, tears and grain."
+
+[[param]]
+key = "glow"
+label = "Edge glow"
+min = 0
+max = 100
+default = 40
+step = 1
+unit = "%"
+
+[[param]]
+key = "scanlines"
+label = "Scanlines"
+min = 0
+max = 100
+default = 55
+step = 1
+unit = "%"
+
+[[param]]
+key = "split"
+label = "RGB split"
+min = 0
+max = 100
+default = 35
+step = 1
+unit = "%"
+
+[[param]]
+key = "glitch"
+label = "Tear"
+min = 0
+max = 100
+default = 25
+step = 1
+unit = "%"
+
+[[param]]
+key = "grain"
+label = "Grain"
+min = 0
+max = 100
+default = 15
+step = 1
+unit = "%"
+
+[[param]]
+key = "hue"
+label = "Tint"
+min = -180
+max = 180
+default = 0
+step = 1
+unit = "°"
+
+[ffmpeg]
+let = [
+ "shift = round(split / 100 * 8)",
+]
+chain = "hue=s=0,split[holoa{index}][holob{index}];[holob{index}]edgedetect=low=0.1:high=0.3,format=rgb24,lutrgb=r=val*0.5:g=val*0.91:b=val[holoe{index}];[holoa{index}]curves=r='0/0.009 0.6/0.14 1/0.78':g='0/0.08 0.6/0.57 1/1':b='0/0.14 0.6/0.83 1/1'[holor{index}];[holor{index}][holoe{index}]blend=all_mode=addition:all_opacity={fixed(glow / 100, 2)},hue=h={round(hue)},rgbashift=rh={round(0 - shift)}:bh={shift},drawgrid=x=-1:w=iw+2:h=4:t=1:c=black@{fixed(scanlines / 100 * 0.55, 2)},noise=alls={round(grain / 100 * 40)}:allf=t,vignette=angle=0.55"
+
+[wgsl]
+entry = "effect.wgsl"
diff --git a/src/crates/concat-effects/packages/concat.hologram/effect.wgsl b/src/crates/concat-effects/packages/concat.hologram/effect.wgsl
new file mode 100644
index 00000000..d15dcda1
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.hologram/effect.wgsl
@@ -0,0 +1,76 @@
+struct Params { glow: f32, scanlines: f32, split: f32, glitch: f32, grain: f32, hue: f32 }
+
+// The hologram from holo-stage (https://github.com/jub0t/holo-stage), cut
+// down to the knobs that matter. The source's hue is thrown away and its
+// value laid onto a three-stop blue ramp; the edges are drawn back over it
+// as glowing contours, then the artifacts of a projection that is not
+// quite locked: a prism split from the centre, scan lines drifting, a
+// refresh band sweeping, a few rows torn sideways, grain, a flutter and a
+// vignette. Exposure, gamma, the sweep, the flicker and the vignette are
+// held at the original's defaults.
+
+const SHADOW: vec3<f32> = vec3<f32>(0.008, 0.071, 0.122);
+const MID: vec3<f32> = vec3<f32>(0.122, 0.498, 0.722);
+const HIGH: vec3<f32> = vec3<f32>(0.682, 0.949, 1.0);
+const EDGE: vec3<f32> = vec3<f32>(0.498, 0.910, 1.0);
+
+fn luma_at(uv: vec2<f32>) -> f32 {
+ return luma(sample(clamp(uv, vec2<f32>(0.0), vec2<f32>(1.0))).rgb);
+}
+
+// One luminance onto the ramp: this is the whole of the look, the rest is
+// dressing.
+fn ramp(l: f32) -> vec3<f32> {
+ let v = pow(clamp(l, 0.0, 1.0), 0.9);
+ var c = mix(SHADOW, MID, smoothstep(0.0, 0.6, v));
+ c = mix(c, HIGH, smoothstep(0.55, 1.0, v));
+ return c * 1.15;
+}
+
+fn effect(at: vec2<f32>) -> vec4<f32> {
+ let src = sample(at);
+ let glow = params.glow / 100.0 * 2.0;
+ let depth = params.scanlines / 100.0;
+ let split = params.split / 100.0;
+ let glitch = params.glitch / 100.0;
+ let grain = params.grain / 100.0 * 0.4;
+ let time = frame.time;
+ var uv = at;
+
+ // A few bands of rows per frame shoved sideways, and a fine wobble
+ // under everything.
+ let row = floor(uv.y * 48.0);
+ let seed = hash(vec2<f32>(row, floor(time * 9.0)), 1.0);
+ let torn = step(1.0 - glitch * 0.25, seed);
+ uv.x += torn * (hash(vec2<f32>(seed, 1.0), 2.0) - 0.5) * 0.12;
+ uv.x += sin(uv.y * 90.0 + time * 3.0) * 0.0012 * glitch;
+
+ // Red and blue taken along the line from the centre, a prism's fringe.
+ let dir = uv - vec2<f32>(0.5);
+ let shift = dir * split * 0.02;
+ let lr = luma_at(uv + shift);
+ let lg = luma_at(uv);
+ let lb = luma_at(uv - shift);
+ var col = ramp(lg);
+ col.r += (lr - lg) * split * 1.5;
+ col.b += (lb - lg) * split * 1.5;
+
+ col += edge_at(uv) * glow * EDGE;
+
+ // Scan lines counted across the frame, not in pixels, so the look holds
+ // at any size; then the refresh band sweeping through.
+ let scan = 1.0 - depth * 0.5 * (0.5 + 0.5 * sin(uv.y * 180.0 * 6.2831853 - time * 6.0));
+ col *= scan;
+ let sweep = fract(uv.y * 0.5 - time * 0.11);
+ let bar = smoothstep(0.0, 0.05, sweep) * smoothstep(0.14, 0.05, sweep);
+ col += bar * 0.18 * HIGH;
+
+ col *= 1.0 + 0.036 * sin(time * 31.0) * sin(time * 7.3);
+ col += grain_at(at, grain);
+
+ let vig = 1.0 - 0.5 * pow(length(dir) * 1.45, 2.2);
+ col *= max(vig, 0.0);
+
+ col = hue_rotate(col, params.hue);
+ return vec4<f32>(clamp01(col), src.a);
+}
diff --git a/src/crates/concat-effects/packages/concat.hologram/fixtures.toml b/src/crates/concat-effects/packages/concat.hologram/fixtures.toml
new file mode 100644
index 00000000..5c8e4dc0
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.hologram/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "hue=s=0,split[holoa0][holob0];[holob0]edgedetect=low=0.1:high=0.3,format=rgb24,lutrgb=r=val*0.5:g=val*0.91:b=val[holoe0];[holoa0]curves=r='0/0.009 0.6/0.14 1/0.78':g='0/0.08 0.6/0.57 1/1':b='0/0.14 0.6/0.83 1/1'[holor0];[holor0][holoe0]blend=all_mode=addition:all_opacity=0.40,hue=h=0,rgbashift=rh=-3:bh=3,drawgrid=x=-1:w=iw+2:h=4:t=1:[email protected],noise=alls=6:allf=t,vignette=angle=0.55"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "hue=s=0,split[holoa0][holob0];[holob0]edgedetect=low=0.1:high=0.3,format=rgb24,lutrgb=r=val*0.5:g=val*0.91:b=val[holoe0];[holoa0]curves=r='0/0.009 0.6/0.14 1/0.78':g='0/0.08 0.6/0.57 1/1':b='0/0.14 0.6/0.83 1/1'[holor0];[holor0][holoe0]blend=all_mode=addition:all_opacity=0.00,hue=h=-180,rgbashift=rh=0:bh=0,drawgrid=x=-1:w=iw+2:h=4:t=1:[email protected],noise=alls=0:allf=t,vignette=angle=0.55"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "hue=s=0,split[holoa0][holob0];[holob0]edgedetect=low=0.1:high=0.3,format=rgb24,lutrgb=r=val*0.5:g=val*0.91:b=val[holoe0];[holoa0]curves=r='0/0.009 0.6/0.14 1/0.78':g='0/0.08 0.6/0.57 1/1':b='0/0.14 0.6/0.83 1/1'[holor0];[holor0][holoe0]blend=all_mode=addition:all_opacity=1.00,hue=h=180,rgbashift=rh=-8:bh=8,drawgrid=x=-1:w=iw+2:h=4:t=1:[email protected],noise=alls=40:allf=t,vignette=angle=0.55"
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index e03f705b..f416d013 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -197,6 +197,7 @@
"Duration": "Duration",
"Dust": "Dust",
"Echo": "Echo",
+ "Edge glow": "Edge glow",
"Edit": "Edit",
"effect": "effect",
"Effect library": "Effect library",
@@ -291,6 +292,7 @@
"Higher and squeakier.": "Higher and squeakier.",
"Highlights": "Highlights",
"Hindi": "Hindi",
+ "Hologram": "Hologram",
"Horizontal": "Horizontal",
"Hue Shift": "Hue Shift",
"Images": "Images",
@@ -508,6 +510,7 @@
"Retro": "Retro",
"Retro Cartoon": "Retro Cartoon",
"Reverse": "Reverse",
+ "RGB split": "RGB split",
"Richer colour where it is muted, without blowing out what is already strong.": "Richer colour where it is muted, without blowing out what is already strong.",
"Right": "Right",
"Robot": "Robot",
@@ -608,6 +611,7 @@
"Target": "Target",
"Teal & Orange": "Teal & Orange",
"Teal in the shadows, orange in the highlights, skin held as skin, a film curve over it. The blockbuster grade, and the most requested look there is.": "Teal in the shadows, orange in the highlights, skin held as skin, a film curve over it. The blockbuster grade, and the most requested look there is.",
+ "Tear": "Tear",
"Telephone": "Telephone",
"Temperature": "Temperature",
"Templates": "Templates",
@@ -626,6 +630,7 @@
"The left half, reflected onto the right.": "The left half, reflected onto the right.",
"The manual colour panel every picture clip carries: exposure, tone, balance, sharpness and edge.": "The manual colour panel every picture clip carries: exposure, tone, balance, sharpness and edge.",
"The narrow band of a phone line.": "The narrow band of a phone line.",
+ "The picture as a sci-fi projection: its hue thrown away for a blue ramp, edges glowing, scan lines drifting, a refresh sweep, tears and grain.": "The picture as a sci-fi projection: its hue thrown away for a blue ramp, edges glowing, scan lines drifting, a refresh sweep, tears and grain.",
"The picture pressed into relief, lit from the top left.": "The picture pressed into relief, lit from the top left.",
"The picture's edges drawn over it in its own colours.": "The picture's edges drawn over it in its own colours.",
"The project folder is created now; the edit autosaves into it.": "The project folder is created now; the edit autosaves into it.",
diff --git a/src/crates/concat/ui/assets/effect-previews/hologram.jpg b/src/crates/concat/ui/assets/effect-previews/hologram.jpg
new file mode 100644
index 00000000..2896910d
Binary files /dev/null and b/src/crates/concat/ui/assets/effect-previews/hologram.jpg differ
diff --git a/src/crates/concat/ui/workspace/media-pane.slint b/src/crates/concat/ui/workspace/media-pane.slint
index bb89226b..29f06082 100644
--- a/src/crates/concat/ui/workspace/media-pane.slint
+++ b/src/crates/concat/ui/workspace/media-pane.slint
@@ -1414,6 +1414,7 @@ export component MediaPane inherits Rectangle {
if (id == "concat.sketch") { return @image-url("../assets/effect-previews/sketch.jpg"); }
if (id == "concat.solarize") { return @image-url("../assets/effect-previews/solarize.jpg"); }
if (id == "concat.scanlines") { return @image-url("../assets/effect-previews/scanlines.jpg"); }
+ if (id == "concat.hologram") { return @image-url("../assets/effect-previews/hologram.jpg"); }
return root.no-art;
}
/// The category column. In-out, because it is dragged.