l1vmet3s.av

analogFX

Acabat analògic en tres famílies que es combinen: pel·lícula, cinta VHS i tub CRT.Acabado analógico en tres familias que se combinan: película, cinta VHS y tubo CRT.Analogue finish in three families that combine: film, VHS tape and CRT tube.

v2.1.1160 controlscontrolescontrols43 operadorsoperadoresoperators554 línies de codilíneas de códigolines of code58 KB
analogFX
  • in1TOP
  • in2CHOPaudio
analogFX
  • out1TOPanalog

UsarUsarUse

Prova aixòPrueba estoTry this

Puja només Chroma Bleed de la pàgina VHS: el color s'arrossega i el dibuix continua nítid.Sube solo Chroma Bleed de la página VHS: el color se arrastra y el dibujo sigue nítido.Raise only Chroma Bleed on the VHS page: colour smears while the drawing stays sharp.

Aquesta part és en castellà.This part is in Spanish.

  1. Arrastrar tox/FX/analogFX.tox y cablear la imagen a in1; la salida mantiene la resolución y el alpha (con curvatura / esquinas del CRT, fuera del cristal es negro opaco).
  2. Película: encender los bloques de Film / Optics y elegir un Film Stock como punto de partida.
  3. VHS: Tracking Error con Speed / Randomness bajos para un tracking que va y viene; Chroma Bleed + Luma Smear para el color de cinta; Tape Noise y Dropouts para el desgaste. Tape Update Rate más bajo = más lento.
  4. CRT: Curvature + Corner Radius + Glass Edge para el tubo; Scanlines y Phosphor Mask para la textura (Mask Pitch 2–3 px a 720p).
  5. A tempo: Flash, Tracking Burst y Vertical Roll (Every o on Audio Hit). Audio: un CHOP de nivel o audio en bruto en in2, Enable y los Level → X.

Va bé ambVa bien conGoes well with

ParàmetresParámetrosParameters

El panell real del mòdul amb els seus valors per defecte. Prem una fila per saber què fa; les notes són en castellà.El panel real del módulo con sus valores por defecto. Pulsa una fila para saber qué hace.The module's real panel with its default values. Press a row to see what it does; notes are in Spanish.

EntendreEntenderUnderstand

La cinta separa la llum del color, com feia el VHS de debò, i corre a la seva pròpia velocitat. El tub corba la imatge i hi afegeix línies i màscara de fòsfor.La cinta separa la luz del color, como hacía el VHS de verdad, y corre a su propia velocidad. El tubo curva la imagen y le añade líneas y máscara de fósforo.The tape splits light from colour, as real VHS did, and runs at its own speed. The tube bends the image and adds scanlines and a phosphor mask.

Aquesta part és en castellà.This part is in Spanish.

Con más detalle

Un solo shader de una pasada con los desenfoques a ¼ de resolución; lo apagado no cocina. La cinta separa luma y color como una VHS y cambia a su propio ritmo (no a cada frame), y el tubo curva la imagen sin mover el centro de los lados. ~0,25 ms la película, ~0,5 la cinta, ~0,8 todo junto. Ráfagas de tracking y rodillo vertical a tempo o con el golpe de audio.

La idea

Quitar el aspecto digital: de película antigua a cinta gastada o a tele de tubo, bloque a bloque. La impresión, que iba aquí, ahora es printFX.

Les idees que hi ha a sotaLas ideas que hay debajoThe ideas underneath

Per dinsPor dentroInside

Aquesta part és en castellà.This part is in Spanish.

El recorrido de la señal esquema en texto
in1 ─┬──────────────────────────────────────────────────────────────┐
     ├→ soft_down (¼ res, mipmap, 16f) → soft_blur → soft_sw ──────┤ (Switch: none_1px sin Softness ni Glow del CRT)
     │                     └→ halo_pick (brillos teñidos) → halo_blur → halo_sw ┤ (Switch: none_1px sin Halation)
     └─────────────────────────────────────────────────────── analog (GLSL TOP, 3 entradas)
analog → null_fx → cross1 (Dry/Wet) → switch1 (Bypass) → out1

beat_rate → beat_speed ┐
beat_lib (libclock) ───┴→ beat_src (Switch por Sync) → null_beats
in2 → audio_select → audio_mono → audio_lowpass / audio_band → audio_rms → audio_gain → null_audio
audio_level (util.gated) → audio_lag → null_level · hit_sub → hit_logic → null_hit (Cook Always) → exec_hit → hit
util · libclock · param_exec (Resync, Stock)

Entradas del shader analog: 0 = imagen, 1 = suave (¼ res, también para el Glow del CRT), 2 = halo (¼ res).

Orden en el shader: pantalla abombada → weave / tracking / franja de cabezas / dropouts (desplazamiento) / rodillo → muestreo con canales desplazados (+ convergencia) → color de cinta (luma, croma) → softness → halation → tono (contraste, saturación, tinte, split toning, fade) → flicker / flash / viñeta → polvo y rayas → nieve, franja de cabezas y dropouts (color) → grano → tubo (glow, scanlines, máscara, entrelazado, barra, borde del cristal).

Operador a operador configuración clave
OperadorConfiguración clave
soft_down / soft_blurResolution TOP quarter (mipmap, 16f) → Blur gaussiano de Softness Size
halo_pick / halo_blurGLSL: (L − umbral) / (1 − umbral) × tinte, premultiplicado → Blur de Halation Size
soft_sw / halo_swSwitch a none_1px si el bloque está apagado (soft_sw también con Phosphor Glow > 0)
analogGLSL TOP (3 entradas; la 1.1 usaba GLSL Multi por el ruido de la impresión), Extend = Hold; uniforms uTime, uGrain, uSoft, uChan (de util.chan), uChan2 (jitter, radial), uWeave, uVig, uTone, uFadeCol, uTint, uFlash, uDust / uDust2, uSplit / uSplitS / uSplitH, uVhs–uVhs5, uCrt–uCrt4
semillas y tiempoutil.vhs_seed (Tape Update Rate), dust_seed (Dust FPS), bar_phase, parity, glitch, roll_state: leen el reloj / el tiempo solo con su opción activa (sin cook por frame con todo apagado)
param_execParameter Execute sobre .., pars = Resync Stock, On Pulse y On Value Change; cook(force=True) al construirlo
beat_* / null_beatsSpeed CHOP del tempo o reloj común (libclock.held) según Sync
audio_* / null_hit / exec_hitRaw → mono → paso bajo 120 Hz (o Full) → RMS → gain; nivel con Gate y Smooth; golpe (mín. 0,12 s)

TallerTallerWorkshop

El codiEl códigoThe code

util python · 196 línieslíneaslines
# util: tempo, Flash, ráfagas y rodillo de la cinta, barra de refresco y audio. Python en expresiones
# de uniforms (unas pocas funciones por frame) y en los golpes de audio; nada por píxel.
import math
import random


def tempo(comp):
	p = comp.par
	mode = p.Sync.eval()
	if mode == 'manual':
		return max(p.Bpm.eval(), 1.0)
	if mode == 'free':
		return 60.0
	t = op('/local/time')
	try:
		return float(t.par.tempo.eval())
	except Exception:
		return 120.0


def rate(comp):
	return tempo(comp) / 60.0


def beats(comp):
	n = comp.op('null_beats')
	return float(n[0].eval()) if n is not None and n.numChans else 0.0


def resync(comp):
	lc = comp.op('libclock')
	if comp.par.Sync.eval() == 'timeline' and lc is not None:
		lc.module.resync()
	else:
		comp.op('beat_speed').par.resetpulse.pulse()


def am(comp):
	return comp.op('audiomod').module


def val(comp, name):
	"""El par tal cual, o su Modulate (lo resuelve audiomod)."""
	return am(comp).val(comp, name)


def hits(comp):
	return am(comp).hit_count(comp) if comp.par.Audio.eval() else 0


def last_hit_t(comp, key):
	"""Hora del último golpe. absTime vuelve a 0 al abrir el proyecto y el storage viaja en el .toe:
	un golpe "en el futuro" es de otra sesión y cuenta como ninguno (si no, se descartaban todos)."""
	t = comp.fetch(key, -1e9, search=False)
	return t if t <= absTime.seconds else -1e9


def since_hit(comp):
	# beats (al tempo actual) desde el último golpe de audio
	return am(comp).hit_age(comp) * rate(comp)


def env(ph, decay, attack=0.0):
	# golpe: sube en `attack` beats y baja a 0 en `decay` beats (cuadrático)
	if ph < 0.0:
		return 0.0
	a = min(ph / attack, 1.0) if attack > 0.0 else 1.0
	d = max(0.0, 1.0 - max(ph - attack, 0.0) / max(decay, 1e-3))
	return a * d * d


# ---- Flash ----
def flash(comp):
	p = comp.par
	e = 0.0
	if p.Flashevery.eval() != 'off':
		ev = float(p.Flashevery.eval())
		e = env((beats(comp) / ev) % 1.0, p.Flashdecay.eval())
	if p.Flashonhit.eval() and p.Audio.eval() and hits(comp) > 0:
		ev = float(p.Flashevery.eval()) if p.Flashevery.eval() != 'off' else 1.0
		e = max(e, env(since_hit(comp) / ev, p.Flashdecay.eval()))
	return p.Flashamount.eval() * e


# ---- VHS: ráfaga de tracking y rodillo vertical ----
def glitch(comp):
	"""Ráfaga de tracking 0.. (× Burst Amount): cada N beats o con el golpe de audio. Se apaga en Burst Decay beats."""
	p = comp.par
	e = 0.0
	if p.Vhsglitchevery.eval() != 'off':
		ev = float(p.Vhsglitchevery.eval())
		e = env((beats(comp) / ev) % 1.0 * ev, p.Vhsglitchdecay.eval(), 0.05)
	if p.Vhsglitchonhit.eval() and p.Audio.eval() and hits(comp) > 0:
		e = max(e, env(since_hit(comp), p.Vhsglitchdecay.eval(), 0.05))
	return e * p.Vhsglitchamount.eval()


def roll_state(comp):
	"""(desplazamiento vertical 0..1, hueco negro 0..): una vuelta completa que frena, al ritmo o con el golpe."""
	p = comp.par
	dur = p.Vhsrolldur.eval()
	ph = -1.0
	idx = 0
	if p.Vhsrollevery.eval() != 'off':
		ev = float(p.Vhsrollevery.eval())
		x = beats(comp) / ev
		idx = int(x // 1)
		if random.Random(idx * 6007 + 11).random() < p.Vhsrollchance.eval():
			ph = (x % 1.0) * ev
	if p.Vhsrollonhit.eval() and p.Audio.eval() and hits(comp) > 0:
		hp = since_hit(comp)
		if 0.0 <= hp < dur and (ph < 0.0 or hp < ph):
			ph = hp
	if ph < 0.0 or ph >= dur:
		return 0.0, 0.0
	x = ph / dur
	return 1.0 - (1.0 - x) * (1.0 - x), 0.05 * (1.0 - x)


def roll(comp, i):
	return roll_state(comp)[i]


def vhs_seed(comp):
	"""Semilla del ruido de la cinta: cambia a Tape Update Rate si algo de la cinta se mueve; 0 (sin depender del tiempo) si no."""
	p = comp.par
	on = val(comp, 'Vhstracking') > 0 or val(comp, 'Vhsdropouts') > 0 or val(comp, 'Vhsnoise') > 0 or val(comp, 'Vhsheadswitch') > 0
	if not on and p.Vhsglitchamount.eval() > 0 and (p.Vhsglitchevery.eval() != 'off' or p.Vhsglitchonhit.eval()):
		on = True
	return int(absTime.seconds * val(comp, 'Vhsrate')) % 100000 + 1 if on else 0


# ---- Optics: desplazamiento de canales ----
def chan(comp, i):
	"""uChan: (rojo x, rojo y, azul x, azul y) en px. Linear: a lo largo del ángulo; Radial: (px en el borde, 0)."""
	p = comp.par
	if not p.Chanoffset.eval():
		return 0.0
	r, b = val(comp, 'Chanred'), val(comp, 'Chanblue')
	if p.Chanmode.eval() == 'radial':
		return (r, 0.0, b, 0.0)[i]
	a = math.radians(val(comp, 'Chanangle'))
	c, s = math.cos(a), math.sin(a)
	return (r * c, r * s, b * c, b * s)[i]


# ---- película: polvo y rayas, stocks ----
def dust_seed(comp):
	"""Semilla del polvo: cambia a Dust FPS si hay polvo o rayas; 0 (sin depender del tiempo) si no."""
	p = comp.par
	if val(comp, 'Dustamount') > 0 or val(comp, 'Scratches') > 0:
		return int(absTime.seconds * val(comp, 'Dustfps')) % 100000 + 1
	return 0


STOCKS = {
	'warm': dict(Fade=0.04, Contrast=1.05, Saturation=1.1, Tint=(1.0, 0.9, 0.75), Tintamount=0.35, Splitamount=0.0),
	'cool': dict(Fade=0.04, Contrast=1.05, Saturation=1.0, Tint=(0.8, 0.92, 1.0), Tintamount=0.35, Splitamount=0.0),
	'bleach': dict(Fade=0.0, Contrast=1.35, Saturation=0.45, Tintamount=0.0, Splitamount=0.0),
	'cross': dict(Fade=0.04, Contrast=1.2, Saturation=1.25, Tintamount=0.0, Splitamount=0.7,
				  Splitshadow=(0.2, 0.75, 0.65), Splithigh=(1.0, 0.8, 0.35), Splitbalance=0.0),
	'sepia': dict(Fade=0.06, Contrast=1.0, Saturation=0.0, Tint=(1.0, 0.85, 0.6), Tintamount=1.0, Splitamount=0.0),
	'faded': dict(Fade=0.14, Contrast=0.9, Saturation=0.7, Tint=(1.0, 0.96, 0.88), Tintamount=0.25, Splitamount=0.0),
	'mono': dict(Fade=0.04, Contrast=1.2, Saturation=0.0, Tintamount=0.0, Splitamount=0.0),
}


def apply_stock(comp, name):
	d = STOCKS.get(name)
	if d is None:
		return
	for k, v in d.items():
		if isinstance(v, tuple):
			for ch, x in zip('rgb', v):
				getattr(comp.par, k + ch).val = x
		else:
			getattr(comp.par, k).val = v
	comp.par.Stock.val = 'pick'


def params_changed(comp, par):
	if par.name == 'Stock':
		apply_stock(comp, par.eval())


# ---- CRT ----
def bar_phase(comp):
	p = comp.par
	if val(comp, 'Crtbar') <= 0.0:
		return 0.0
	return (absTime.seconds * val(comp, 'Crtbarspeed')) % 1.0


def parity(comp):
	return int(absTime.frame) % 2 if val(comp, 'Crtinterlace') > 0.0 else 0
param_exec python · 24 línieslíneaslines
def onValueChange(par, prev):
	op('util').module.params_changed(parent(), par)
	return

def onValuesChanged(changes):
	return

def onPulse(par):
	if par.name == 'Resync':
		op('util').module.resync(parent())
	return

def onExpressionChange(par, val, prev):
	return

def onExportChange(par, val, prev):
	return

def onEnableChange(par, val, prev):
	return

def onModeChange(par, val, prev):
	return
halo_shader glsl · 11 línieslíneaslines
// halo_pick: solo lo que pasa del umbral, teñido (para Halation)
out vec4 fragColor;
uniform vec4 uHalo;    // rgb = Halation Tint, w = Halation Threshold
void main() {
	vec4 c = texture(sTD2DInputs[0], vUV.st);
	vec3 rgb = c.a > 0.0 ? c.rgb / c.a : vec3(0.0);
	float l = dot(rgb, vec3(0.299, 0.587, 0.114));
	float k = max(l - uHalo.w, 0.0) / max(1.0 - uHalo.w, 1e-3);
	fragColor = vec4(rgb * uHalo.rgb * k * c.a, 1.0);
}
analog_shader glsl · 323 línieslíneaslines
// analog: película, cinta VHS y tubo CRT en una pasada. Entradas: 0 = imagen, 1 = suave (¼ res), 2 = halo (¼ res)
out vec4 fragColor;
uniform vec4 uTime;    // x = tiempo (s, envuelto), y = semilla del grano (por Grain FPS), z = semilla del flicker, w = semilla del jitter
uniform vec4 uGrain;   // x = Amount (0 = apagado), y = tamaño px, z = color, w = medios tonos
uniform vec4 uSoft;    // x = Softness Amount (0 = apagado), y = solo bordes, z = Halation Amount (0 = apagado)
uniform vec4 uChan;    // xy = offset rojo px, zw = offset azul px (0 = apagado)
uniform vec4 uChan2;   // x = jitter px
uniform vec4 uWeave;   // x = Weave Amount px, y = Weave Speed, z = Flicker Amount
uniform vec4 uVig;     // x = Vignette Amount, y = radio, z = suavidad
uniform vec4 uTone;    // x = Fade, y = Contrast, z = Saturation, w = Tint Amount
uniform vec4 uFadeCol;
uniform vec4 uTint;
uniform vec4 uFlash;   // x = flash (brillo extra del golpe)
uniform vec4 uVhs;     // x = Tracking px, y = Chroma Bleed px, z = Luma Smear px, w = Edge Ringing
uniform vec4 uVhs2;    // x = Dropouts, y = Tape Wobble px, z = Tape Noise, w = Head Switching (alto)
uniform vec4 uVhs3;    // x = roll (0..1), y = hueco del roll, z = ráfaga de tracking, w = semilla de la cinta (0 = quieta)
uniform vec4 uVhs4;    // x = tamaño de las bandas de tracking, y = velocidad de las bandas, z = aleatoriedad, w = largo de los dropouts px
uniform vec4 uVhs5;    // x = tamaño del grano del ruido px, y = variabilidad del ruido, z = ruido de color, w = tipo de dropout (0 blanco, 1 oscuro, 2 ambos)
uniform vec4 uDust;    // x = polvo, y = tamaño de las motas px, z = rayas, w = ancho de las rayas px
uniform vec4 uDust2;   // x = semilla del polvo (0 = sin polvo ni rayas)
uniform vec4 uSplit;   // x = Split Tone Amount, y = balance
uniform vec4 uSplitS;  // tinte de las sombras
uniform vec4 uSplitH;  // tinte de las luces
uniform vec4 uCrt;     // x = curvatura, y = radio de las esquinas, z = borde del cristal, w = Glow
uniform vec4 uCrt2;    // x = Scanlines, y = paso px, z = máscara de fósforo, w = tipo (0 apertura, 1 sombra, 2 ranura)
uniform vec4 uCrt3;    // x = paso de la máscara px, y = convergencia px, z = barra de refresco, w = entrelazado
uniform vec4 uCrt4;    // x = fase de la barra 0..1, y = paridad del campo

uint hashu(uint x){
	x ^= x >> 16; x *= 0x7feb352du;
	x ^= x >> 15; x *= 0x846ca68bu;
	x ^= x >> 16; return x;
}
float h1(uint a, uint b){ return float(hashu(a * 747796405u + b * 2891336453u + 1u) & 0x00ffffffu) / 16777216.0; }
float vnoise(float t, uint s){                 // ruido 1D suave (para weave / flicker / cinta)
	float i = floor(t), f = fract(t);
	float u = f * f * (3.0 - 2.0 * f);
	return mix(h1(uint(int(i) + 100000), s), h1(uint(int(i) + 100001), s), u) * 2.0 - 1.0;
}

vec4 Unpre(vec4 c) { return vec4(c.a > 0.0 ? c.rgb / c.a : vec3(0.0), c.a); }
float Luma(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
// YIQ (el color de la cinta: luma nítida, croma arrastrada)
vec3 ToYIQ(vec3 c) { return vec3(dot(c, vec3(0.299, 0.587, 0.114)), dot(c, vec3(0.596, -0.274, -0.322)), dot(c, vec3(0.211, -0.523, 0.312))); }
vec3 FromYIQ(vec3 y) { return vec3(y.x + 0.956 * y.y + 0.621 * y.z, y.x - 0.272 * y.y - 0.647 * y.z, y.x - 1.106 * y.y + 1.703 * y.z); }

// máscara de fósforo: 0 rejilla de apertura (franjas), 1 máscara de sombra (tríadas en filas desplazadas), 2 ranura
vec3 PhosphorMask(vec2 fc, float pitch, int type) {
	float x = fc.x / pitch;
	vec3 lo = vec3(0.25);
	float g = 1.0;
	if (type == 1) {
		x += mod(floor(fc.y / (pitch * 2.0)), 2.0) * 1.5;
		float gy = fract(fc.y / (pitch * 2.0));
		g = 0.55 + 0.45 * smoothstep(0.0, 0.25, gy) * (1.0 - smoothstep(0.65, 0.9, gy));
	} else if (type == 2) {
		float row = floor(fc.y / (pitch * 4.0));
		x += mod(row, 2.0) * 1.5;
		g = 1.0 - 0.7 * smoothstep(0.78, 0.86, fract(fc.y / (pitch * 4.0)));
	}
	float i = mod(floor(x), 3.0);
	vec3 m = i < 0.5 ? vec3(1.0, 0.25, 0.25) : i < 1.5 ? vec3(0.25, 1.0, 0.25) : vec3(0.25, 0.25, 1.0);
	m *= g;
	return m * (3.0 / (m.r + m.g + m.b + 1e-3)) * (type == 0 ? 1.0 : 0.9);
}

// dropout: raya corta de cinta dañada (1-3 líneas, cabeza brillante que se apaga en cola). Devuelve su intensidad
// en este píxel, cuánto se desplaza la imagen debajo (px) y si es clara (1) u oscura (0)
float Dropout(vec2 fc, uint sd, float resx, out float shiftpx, out float kind) {
	float best = 0.0;
	shiftpx = 0.0;
	kind = 1.0;
	uint row = uint(fc.y);
	for (int dy = 0; dy < 3; dy++) {
		uint rs = row - uint(dy);
		if (uint(dy) > row || h1(rs, sd + 17u) >= uVhs2.x * 0.035) continue;
		float hgt = 1.0 + floor(h1(rs, sd + 31u) * 3.0);
		if (float(dy) >= hgt) continue;
		float x0 = h1(rs, sd + 19u) * resx;
		float len = uVhs4.w * (0.4 + 1.3 * h1(rs, sd + 23u));
		float t = (fc.x - x0) / len;
		if (t < 0.0 || t > 1.0) continue;
		float prof = smoothstep(0.0, 0.05, t) * (1.0 - smoothstep(0.45, 1.0, t));          // cabeza brillante, cola que se apaga
		float vf = 1.0 - 0.3 * float(dy);                                                 // las líneas de abajo, más flojas
		float k = h1(rs, sd + 37u);
		float typ = uVhs5.w < 0.5 ? 1.0 : uVhs5.w < 1.5 ? 0.0 : (k < 0.5 ? 1.0 : 0.0);
		if (prof * vf > best) {
			best = prof * vf;
			kind = typ;
			shiftpx = (h1(rs, sd + 41u) - 0.5) * 14.0 * best;
		}
	}
	return best;
}

void main() {
	vec2 res = uTDOutputInfo.res.zw;
	vec2 uv = vUV.st;
	vec2 sp = vUV.st * 2.0 - 1.0;                  // posición en la pantalla, −1..1
	float scr = 1.0;                                // 1 dentro del cristal
	// CRT: pantalla abombada (el centro de cada lado queda en su sitio) y esquinas redondeadas
	if (uCrt.x > 0.0) {
		vec2 p = sp * (1.0 + uCrt.x * 0.22 * dot(sp, sp)) / (1.0 + uCrt.x * 0.22);
		uv = p * 0.5 + 0.5;
		if (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) scr = 0.0;
	}
	if (uCrt.y > 0.0) {
		vec2 d = abs(sp) - (1.0 - uCrt.y);
		float sd = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - uCrt.y;
		scr *= clamp(0.5 - sd * res.y * 0.5, 0.0, 1.0);
	}
	// gate weave: el cuadro baila (ruido suave en el tiempo, px)
	if (uWeave.x > 0.0)
		uv += vec2(vnoise(uTime.x * uWeave.y, 11u), vnoise(uTime.x * uWeave.y, 23u)) * uWeave.x / res;
	// cinta: ondulación, tracking (bandas que se tuercen), franja de cabezas y rodillo vertical
	float dxpx = 0.0;
	if (uVhs.x > 0.0 || uVhs3.z > 0.0) {
		uint sd = uint(uVhs3.w);
		// bandas que derivan despacio por la imagen (Tracking Speed) y de tamaño ajustable
		float bn = vnoise(vUV.t * 14.0 / max(uVhs4.x, 0.1) + uTime.x * uVhs4.y, 71u);
		float band = smoothstep(0.45, 1.0, abs(bn)) * bn;
		// intermitencia: el error sube y baja con el tiempo, a rachas (Tracking Randomness)
		float act = mix(1.0, smoothstep(0.15, 0.8, 0.5 + 0.5 * vnoise(uTime.x * 0.4, 97u)), uVhs4.z);
		// temblor fino por línea, a la velocidad de la cinta
		float jit = 1.0 + (h1(uint(gl_FragCoord.y / 3.0), sd + 7u) - 0.5) * 0.7 * uVhs4.z;
		dxpx += band * jit * (act * uVhs.x * (1.0 + uVhs3.z * 2.0) + uVhs3.z * 40.0);
	}
	if (uVhs2.x > 0.0) {
		float sh, kd;
		Dropout(gl_FragCoord.xy, uint(uVhs3.w), res.x, sh, kd);
		dxpx += sh;
	}
	if (uVhs2.y > 0.0)
		dxpx += vnoise(vUV.t * 3.0 + uTime.x * 0.6, 83u) * uVhs2.y;
	if (uVhs2.w > 0.0 && vUV.t < uVhs2.w) {
		float k = 1.0 - vUV.t / uVhs2.w;
		dxpx += (h1(uint(gl_FragCoord.y), uint(uVhs3.w) + 3u) - 0.5) * 2.0 * 60.0 * k * k;
	}
	uv.x += dxpx / res.x;
	float rollmask = 1.0;
	if (uVhs3.x > 0.0 || uVhs3.y > 0.0) {
		float f = fract(uv.y + uVhs3.x);
		rollmask = step(uVhs3.y, f);
		uv.y = f;
	}
	// desplazamiento de canales (+ jitter por frame del grano) y convergencia del tubo (crece hacia los bordes)
	vec2 oR = uChan.xy / res, oB = uChan.zw / res;
	if (uChan2.y > 0.5) {                          // Radial: como la aberración de una lente (crece hacia los bordes)
		oR = sp * uChan.x / res;
		oB = sp * uChan.z / res;
	}
	if (uChan2.x > 0.0) {
		uint s = uint(uTime.w);
		oR += (vec2(h1(s, 1u), h1(s, 2u)) - 0.5) * 2.0 * uChan2.x / res;
		oB += (vec2(h1(s, 3u), h1(s, 4u)) - 0.5) * 2.0 * uChan2.x / res;
	}
	if (uCrt3.y > 0.0) {
		vec2 cv = sp * uCrt3.y / res;
		oR += cv;
		oB -= cv;
	}
	vec4 c = texture(sTD2DInputs[0], uv);
	c.r = texture(sTD2DInputs[0], uv + oR).r;
	c.b = texture(sTD2DInputs[0], uv + oB).b;
	// color de cinta: luma algo blanda con halos, croma arrastrada hacia la derecha
	if (uVhs.y > 0.0 || uVhs.z > 0.0 || uVhs.w > 0.0) {
		vec2 px = vec2(1.0 / res.x, 0.0);
		vec3 y0 = ToYIQ(c.rgb);
		float ys = y0.x;
		if (uVhs.z > 0.0 || uVhs.w > 0.0) {
			float lw = uVhs.z > 0.0 ? uVhs.z : 1.5;
			vec3 sn = vec3(0.0), sw = vec3(0.0);
			for (int i = -2; i <= 2; i++) {
				sn += texture(sTD2DInputs[0], uv + px * float(i) * lw * 0.5).rgb;
				sw += texture(sTD2DInputs[0], uv + px * float(i) * lw * 1.5).rgb;
			}
			float yn = Luma(sn / 5.0), yw = Luma(sw / 5.0);
			ys = uVhs.z > 0.0 ? yn : y0.x;
			ys += uVhs.w * (ys - yw);                // halos: lo que pasa de la media ancha rebota
		}
		vec3 iq = y0;
		if (uVhs.y > 0.0) {
			vec3 cs = vec3(0.0);
			for (int i = 0; i < 8; i++) cs += texture(sTD2DInputs[0], uv - px * (float(i) / 7.0) * uVhs.y).rgb;
			iq = ToYIQ(cs / 8.0);
		}
		c.rgb = FromYIQ(vec3(ys, iq.y, iq.z));
	}
	// softness: mezcla con la versión desenfocada (¼ res), opcionalmente solo hacia los bordes
	if (uSoft.x > 0.0) {
		vec4 b = texture(sTD2DInputs[1], uv);
		b.r = texture(sTD2DInputs[1], uv + oR).r;
		b.b = texture(sTD2DInputs[1], uv + oB).b;
		float e = smoothstep(0.15, 1.0, length((vUV.st - 0.5) * 2.0));
		c = mix(c, b, uSoft.x * mix(1.0, e, uSoft.y));
	}
	vec4 u = Unpre(c);
	vec3 rgb = u.rgb;
	// halation: halo de los brillos (ya teñido y premultiplicado por su alpha)
	if (uSoft.z > 0.0) rgb += texture(sTD2DInputs[2], uv).rgb * uSoft.z;
	// tono: contraste, saturación, tinte, negros levantados
	rgb = (rgb - 0.5) * uTone.y + 0.5;
	float l = Luma(rgb);
	rgb = mix(vec3(l), rgb, uTone.z);
	rgb = mix(rgb, rgb * uTint.rgb, uTone.w);
	if (uSplit.x > 0.0) {                          // sombras y luces con su tinte (se suma, para que también tiña los negros)
		float sw = smoothstep(0.0, 1.0, clamp(Luma(rgb) + uSplit.y * 0.35, 0.0, 1.0));
		rgb += ((uSplitS.rgb - 0.5) * (1.0 - sw) + (uSplitH.rgb - 0.5) * sw) * 0.4 * uSplit.x;
	}
	rgb = mix(uFadeCol.rgb, vec3(1.0), clamp(rgb, 0.0, 1.0)) * uTone.x + rgb * (1.0 - uTone.x);
	// flicker: brillo que parpadea a Flicker FPS · flash: brillo extra en el golpe
	if (uWeave.z > 0.0) rgb *= 1.0 + (h1(uint(uTime.z), 7u) * 2.0 - 1.0) * uWeave.z;
	if (uFlash.x > 0.0) rgb *= 1.0 + uFlash.x;
	// viñeta: oscurece hacia las esquinas (radio en fracción de la media diagonal)
	if (uVig.x > 0.0) {
		float r = length((vUV.st - 0.5) * 2.0);
		rgb *= 1.0 - uVig.x * smoothstep(uVig.y, uVig.y + uVig.z, r);
	}
	// película proyectada: polvo (motas oscuras y alguna clara) y rayas verticales finas, que cambian a Dust FPS
	if (uDust2.x > 0.0 && (uDust.x > 0.0 || uDust.z > 0.0)) {
		uint ds = uint(uDust2.x);
		if (uDust.x > 0.0) {
			float cell = max(uDust.y * 7.0, 8.0);
			vec2 q = gl_FragCoord.xy / cell;
			ivec2 gi = ivec2(floor(q));
			vec2 f = fract(q);
			uint kk = uint(gi.x + 4000) * 73856093u ^ uint(gi.y + 4000) * 19349663u;
			if (h1(kk, ds + 3u) < uDust.x * 0.12) {
				vec2 cc = vec2(0.2 + 0.6 * h1(kk, ds + 4u), 0.2 + 0.6 * h1(kk, ds + 5u));
				float r = uDust.y * (0.3 + 0.7 * h1(kk, ds + 6u));
				float cov = clamp((r - length((f - cc) * cell)) * 0.9 + 0.5, 0.0, 1.0);
				rgb = mix(rgb, h1(kk, ds + 7u) < 0.8 ? vec3(0.03) : vec3(0.95), cov * 0.85);
			}
		}
		if (uDust.z > 0.0) {
			for (int i = 0; i < 3; i++) {
				uint si = (ds / uint(1 + 2 * i)) * 3u + uint(i);           // la 2.ª y la 3.ª duran 3 y 5 cuadros
				if (h1(si, 41u) > uDust.z) continue;
				float x0 = h1(si, 43u) * res.x + 3.0 * sin(gl_FragCoord.y * 0.04 + float(i) * 2.1);
				float y0 = h1(si, 47u) * res.y * 0.6;
				float y1 = y0 + (0.3 + 0.7 * h1(si, 53u)) * res.y * 0.6;
				float ends = smoothstep(y0, y0 + 20.0, gl_FragCoord.y) * (1.0 - smoothstep(y1 - 30.0, y1, gl_FragCoord.y));
				float line = clamp(1.0 - abs(gl_FragCoord.x - x0) / uDust.w, 0.0, 1.0);
				rgb += line * ends * (0.2 + 0.35 * h1(si, 59u));
			}
		}
	}
	// cinta: nieve orgánica en rayas, franja de cabezas con ruido y dropouts
	if (uVhs2.z > 0.0 || uVhs2.x > 0.0 || uVhs2.w > 0.0) {
		uint sd = uint(uVhs3.w);
		uint row = uint(gl_FragCoord.y);
		if (uVhs2.z > 0.0) {
			// cada línea con su ancho de grano (rayas cortas y largas) y su nivel
			float cw = max(1.0, uVhs5.x * mix(1.0, mix(0.4, 2.8, h1(row, sd + 6u)), uVhs5.y));
			uint cx = uint(gl_FragCoord.x / cw);
			float n = h1(cx * 73856093u ^ row * 19349663u, sd + 9u) - 0.5;
			float rj = h1(row, sd + 5u) - 0.5;
			// zonas más cargadas que derivan y cambian despacio, y algún renglón entero que sube
			float mv = mix(1.0, 0.2 + 1.7 * smoothstep(0.15, 0.9, 0.5 + 0.5 * vnoise(vUV.t * 5.0 + uTime.x * 0.35, 131u)), uVhs5.y);
			float streak = h1(row / 2u, sd + 11u) < 0.05 * uVhs5.y ? (h1(row, sd + 12u) - 0.25) : 0.0;
			float low = 1.0 - smoothstep(0.0, 0.12, vUV.t);
			float amtn = uVhs2.z * mv * (0.6 + 1.4 * low);
			rgb += (n * 0.55 + rj * 0.3 * (0.4 + h1(row / 3u, sd + 13u)) + streak * 0.5) * amtn;
			if (uVhs5.z > 0.0)                                                             // ruido de color suave
			{
				uint ck = cx * 73856093u ^ row * 19349663u;
				rgb += vec3(h1(ck, sd + 14u) - 0.5, h1(ck, sd + 15u) - 0.5, h1(ck, sd + 16u) - 0.5) * 0.35 * uVhs5.z * amtn;
			}
		}
		if (uVhs2.w > 0.0 && vUV.t < uVhs2.w) {
			float n = h1(uint(gl_FragCoord.x / 3.0) * 73856093u ^ row * 19349663u, sd + 43u);
			rgb = mix(rgb, vec3(n * 0.9), (1.0 - vUV.t / uVhs2.w) * 0.8);
		}
		if (uVhs2.x > 0.0) {
			float sh, kd;
			float di = Dropout(gl_FragCoord.xy, sd, res.x, sh, kd);
			if (di > 0.0) {
				float n = h1(uint(gl_FragCoord.x / 2.0), row * 7u + sd);
				float lv = kd > 0.5 ? 0.7 + 0.3 * n : 0.06 * n;
				vec3 tn = vec3(0.14 * (h1(uint(gl_FragCoord.x / 3.0), row + sd + 3u) - 0.5), -0.05 * n, 0.18 * (h1(uint(gl_FragCoord.x / 4.0), row + sd + 5u) - 0.5));
				rgb = mix(rgb, vec3(lv) + tn, di * 0.88);
			}
		}
	}
	// grano: por bloques de Grain Size px, nuevo a Grain FPS, más fuerte en los medios tonos
	if (uGrain.x > 0.0) {
		uvec2 g = uvec2(floor(gl_FragCoord.xy / max(uGrain.y, 1.0)));
		uint s = uint(uTime.y);
		uint k = g.x * 73856093u ^ g.y * 19349663u;
		float lm = clamp(Luma(rgb), 0.0, 1.0);
		float w = mix(1.0, 4.0 * lm * (1.0 - lm), uGrain.w);
		float n = (h1(k, s) + h1(k, s + 7919u)) - 1.0;                     // ~ triangular, −1..1
		if (uGrain.z > 0.5)
			rgb += vec3(n, (h1(k, s + 31u) + h1(k, s + 37u)) - 1.0, (h1(k, s + 41u) + h1(k, s + 43u)) - 1.0) * uGrain.x * w;
		else
			rgb += n * uGrain.x * w;
	}
	// tubo: brillo del fósforo, scanlines, máscara, entrelazado, barra de refresco y borde del cristal
	if (uCrt.w > 0.0) {                              // solo lo claro sangra (en pantalla: no quema los fondos claros)
		vec3 gl = max(texture(sTD2DInputs[1], uv).rgb - 0.35, 0.0) / 0.65;
		rgb = 1.0 - (1.0 - rgb) * (1.0 - clamp(gl * uCrt.w * 0.5, 0.0, 0.95));
	}
	if (uCrt2.x > 0.0) {
		float s = 0.5 + 0.5 * cos(6.2831853 * gl_FragCoord.y / max(uCrt2.y, 1.0));
		float k = uCrt2.x * (1.0 - 0.35 * clamp(Luma(rgb), 0.0, 1.0));
		rgb *= mix(1.0, s, k) / (1.0 - 0.5 * k);
	}
	if (uCrt2.z > 0.0)
		rgb *= mix(vec3(1.0), PhosphorMask(gl_FragCoord.xy, max(uCrt3.x, 1.0), int(uCrt2.w + 0.5)), uCrt2.z);
	if (uCrt3.w > 0.0)
		rgb *= 1.0 - uCrt3.w * 0.5 * step(0.5, mod(floor(gl_FragCoord.y) + uCrt4.y, 2.0));
	if (uCrt3.z > 0.0) {
		float d = abs(fract(vUV.t - uCrt4.x + 0.5) - 0.5);
		rgb *= 1.0 + uCrt3.z * 0.4 * exp(-d * d / 0.012);
	}
	if (uCrt.z > 0.0)
		rgb *= 1.0 - uCrt.z * smoothstep(0.7, 1.0, length(sp) * 0.7071);
	rgb = clamp(rgb, 0.0, 1.0) * scr * rollmask;
	// fuera del cristal (o en el hueco del rodillo): negro opaco; dentro, el alpha de la imagen
	float a = (uCrt.x > 0.0 || uCrt.y > 0.0 || uVhs3.y > 0.0) ? mix(1.0, u.a, scr * rollmask) : u.a;
	fragColor = TDOutputSwizzle(vec4(rgb * a, a));
}

Aquesta part és en castellà.This part is in Spanish.

Decisiones de diseño
  • Partir en dos (el autor): película / cinta / tubo aquí, impresión en printFX. Se mantiene el nombre analogFX (los mapeos MIDI siguen valiendo) y los nombres de parámetro de la 1.1.
  • Sin Light Leak (el autor) y sin noise_tex (solo lo usaba la impresión): GLSL TOP de 3 entradas.
  • Todo en un shader de una pasada; solo los desenfoques van aparte a ¼ de resolución. Lo apagado no cocina.
  • Cinta a su propio ritmo (Tape Update Rate) y tracking como deriva continua con intermitencia: a 60 fps "se veía demasiado frenético".
  • Dropouts con forma (cabeza, cola, grano, desplazamiento) en vez de rectángulos blancos ("bastante fake").
  • Channel Offset con sliders (módulo y ángulo) y modo Radial: los campos x / y no tienen slider y eran "poco ágiles". Los valores x / y de la 1.1 se convierten solos al reconstruir.
  • Stocks como cargas de los controles de Tone: siguen editables; el menú vuelve a "Load Stock…".
  • Split toning aditivo: tiñe también los negros (con multiplicar se quedaban negros).
  • Glow del CRT en pantalla y solo de lo claro: sumado sin más quemaba los fondos claros.
  • Fuera del cristal, negro opaco: con curvatura o esquinas, el borde es parte de la pantalla.
Lo que falló y cómo se arregló
SíntomaCausaSolución
VHS "demasiado frenético" (el autor)La semilla de la cinta era el nº de frame (60 cambios/s) y el tracking se sorteaba entero en cada unoTape Update Rate (12 Hz) y tracking como ruido que deriva (Speed, Band Size, Randomness)
Dropouts "bastante fake"Rectángulos blancos de 3 px, bordes duros, sin relación con la imagen1–3 líneas, cabeza brillante y cola, grano y color, y desplazamiento de la imagen
Tape Noise poco variableUn nivel uniforme por celdaAncho por línea, zonas que derivan, renglones que suben y ruido de color
Glow del CRT dejaba el fondo blancoSe sumaba la imagen suave enteraPantalla de lo que pasa de 0,35
Dropouts poco visibles tras rehacerlosProbabilidad por línea baja y largo corto×2 la probabilidad y largo por defecto 80 px
h1() con tres argumentosError de escritura en el ruido de colorCombinar las coordenadas en un uint antes del hash
Comandos de parche desde PowerShell con comillas anidadas rompíanComillas en -c "…"Scripts de parche como archivo en el scratchpad (no es del módulo)
Cuánto cuesta

1280 × 720, misma imagen, medianas de ~22 frames con cook forzado (la GPU de un portátil cambia de reloj: cifras orientativas, #241):

Casoanalog GPUanalog CPU
Película completa (como la 1.1 sin impresión)~0,25 ms~0,43 ms
VHS completo~0,5 ms~0,36 ms
CRT completo~0,27 ms~0,38 ms
Polvo, rayas y split toning~0,38 ms~0,38 ms
Todo a la vez~0,82 ms~0,45 ms

El VHS es lo más caro (hasta 18 lecturas por píxel para la luma y la croma). Desenfoques a ¼ de resolución: solo con Softness, Glow o Halation.