Analytic LTC Cylindrical and Tube Area Lights
Extends Linearly Transformed Cosines from flat polygons to cylindrical tube and linear area lights, evaluating specular and diffuse shading analytically in transformed cosine space without Monte Carlo noise.
Also known as LTC linear lights, LTC tube lights, LTC capsule lights, linear-light LTC
In the family Light transport & global illumination, analytic direct lighting
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | RectAreaLight + RectAreaLightUniformsLib implements rectangular LTC area lights only, not cylindrical or tube LTC emitters. |
| Babylon.js 9.38.0 | Built in | new BABYLON.RectAreaLight(...) (LTC area light evaluation; tube approximation via narrow rect) docs |
| Godot 4.7 | None found | Godot 4.4 ships OmniLight3D, SpotLight3D, and DirectionalLight3D; no built-in LTC cylindrical or tube area light node. |
| Unity | Built in | HDRP Light > Type = Area > Shape = Tube (LightType.Tube evaluated via analytic LTC line integration I_diffuse_line / ComputeLineWidthFactor in AreaLighting.hlsl) docs HDRP-only; URP does not support real-time tube area lights. |
| Unreal 5.7 | Built in | Point Light > Light > Source Length and Source Radius turn a point light into an analytic capsule/tube area light docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
In standard Linearly Transformed Cosines for Area Lights, an inverse 3×3 matrix M^-1 fetched from a precomputed roughness-and-view-angle LUT maps a GGX microfacet lobe onto a clamped cosine hemisphere. Applying that same transform to a finite cylindrical tube light (parameterized by segment endpoints p1, p2 and radius R) yields a sheared cylinder in cosine space that can be integrated in closed form.
Following Heitz and Hill's linear-light formulation, the transformed line segment defines a local orthonormal frame whose plane contains the origin and the transformed segment. Because the cosine distribution integrates linearly over a thin glowing wire, the irradiance along an infinite line has a compact closed-form expression in terms of the closest-point distance and the tangent vector; subtracting the two semi-infinite tails beyond the clipped segment endpoints yields the exact finite-segment contribution. For finite-radius tubes, the cylinder is split into its line-segment integral scaled by radius plus optional spherical or disk endcaps, clipped smoothly against the shading horizon.
Diffuse lighting reuses the exact same evaluator with M^-1 = I, and the same 64×64 LTC lookup tables already used for rectangular lights require no extra texture memory.
When to choose it
Reach for it when
- need real-time specular reflections from neon or fluorescent tubes
- line lights look wrong on rough glossy pbr surfaces
- approximate capsule area light without ray tracing or sampling noise
- want analytic tube light shading with linearly transformed cosines
- sci-fi corridor lighting bars need accurate grazing highlights
Choose it for real-time fluorescent tubes, neon strips, saber glows, and architectural linear fixtures on rough or glossy PBR materials where you want crisp, noise-free elongated highlights at minimal shader cost.
Prefer Linearly Transformed Cosines for Area Lights for flat rectangular windows, softboxes, or arbitrary convex polygons. Prefer ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting when a scene contains dozens of shadowed tube emitters, because analytic LTC is unshadowed. Prefer Split-Sum Image-Based Lighting for distant environment illumination.
Field marks
- Produces unshadowed direct lighting; shadows require separate shadow maps, distance-field occlusion, or ray-traced visibility
- Thin-line approximation breaks down when the shading point sits closer to the tube than its radius, causing energy spikes unless capped or switched to capsule/disk endcap terms
- Horizon clipping of a sheared cylinder is approximate near grazing angles where the tube intersects the tangent plane
- Inherits LTC fit error for grazing Fresnel behavior and highly anisotropic BRDFs unless paired with anisotropic LTC tables
Presets
Analytic LTC cylindrical tube lights — exact glossy GGX specular & diffuse linear tube area lighting
{
"P_ROUGHNESS": 0.24,
"P_TUBE_RADIUS": 0.06,
"P_TUBE_LEN": 1.05,
"P_ANIM_SPEED": 1
}Show GLSL (151 lines)
const float P_ROUGHNESS = 0.24; // P Floor Roughness [0.06, 0.78, 0.02]
const float P_TUBE_RADIUS = 0.06; // P Tube Radius [0.025, 0.14, 0.005]
const float P_TUBE_LEN = 1.05; // P Tube Length [0.45, 1.65, 0.05]
const float P_ANIM_SPEED = 1.0; // P Tube Motion [0.0, 2.5, 0.05]
float sdCapsule(vec3 p, vec3 a, vec3 b, float r) {
vec3 pa = p - a, ba = b - a;
float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
return length(pa - ba * h) - r;
}
float sdBox(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
// Analytic diffuse + LTC-approximated representative-point GGX specular for a finite cylindrical tube (a -> b)
vec3 evalTubeLight(vec3 p, vec3 n, vec3 v, vec3 a, vec3 b, float tubeR, vec3 radCol, float rough) {
vec3 L0 = a - p;
vec3 L1 = b - p;
float d0 = max(length(L0), 1e-4);
float d1 = max(length(L1), 1e-4);
// Exact analytical diffuse line-light integral (Picott / Karis / Heitz LTC diffuse form factor)
float cos0 = dot(n, L0 / d0);
float cos1 = dot(n, L1 / d1);
float diffFF = max((cos0 + cos1) / max(d0 * d1 + dot(L0, L1) + 0.15, 0.15), 0.0);
vec3 diffTerm = radCol * diffFF * 0.28 * (1.0 + tubeR * 4.5);
// Representative closest point on tube segment to reflection ray R (Karis / LTC cylindrical lobe)
vec3 R = reflect(-v, n);
vec3 Ld = L1 - L0;
float rDotL0 = dot(R, L0);
float rDotLd = dot(R, Ld);
float l0DotLd = dot(L0, Ld);
float ld2 = max(dot(Ld, Ld), 1e-5);
float tSeg = clamp((rDotL0 * rDotLd - l0DotLd) / max(ld2 - rDotLd * rDotLd, 1e-4), 0.0, 1.0);
vec3 closestLine = L0 + Ld * tSeg;
// Expand toward tube cylinder radius around closest point on axis
vec3 centerToRay = dot(closestLine, R) * R - closestLine;
vec3 repVec = closestLine + centerToRay * clamp(tubeR / max(length(centerToRay), 1e-4), 0.0, 1.0);
float dist = max(length(repVec), 0.08);
vec3 lDir = repVec / dist;
// Energy-conserving LTC/GGX roughness broadening across tube radius & finite segment length
float alpha = max(rough * rough, 0.006);
float alphaPrime = clamp(alpha + tubeR / max(2.0 * dist, 0.1), 0.008, 1.0);
float normE = (alpha / max(alphaPrime, 1e-4)) * clamp(sqrt(ld2) / max(dist * 1.4, 0.25), 0.35, 2.2);
vec3 H = normalize(lDir + v);
float ndh = max(dot(n, H), 0.0);
float ndl = max(dot(n, lDir), 0.0);
float denom = ndh * ndh * (alphaPrime * alphaPrime - 1.0) + 1.0;
float D = (alphaPrime * alphaPrime) / max(3.14159265 * denom * denom, 1e-5);
float F = 0.06 + 0.94 * pow(1.0 - max(dot(H, v), 0.0), 5.0);
vec3 specTerm = radCol * D * F * normE * ndl * 0.22 / (0.25 + dist * dist * 0.35);
return diffTerm + specTerm;
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float tAnim = iTime * max(P_ANIM_SPEED, 0.0);
float rough = clamp(P_ROUGHNESS, 0.05, 0.85);
float tubeR = clamp(P_TUBE_RADIUS, 0.02, 0.16);
float halfL = clamp(P_TUBE_LEN, 0.35, 1.8) * 0.5;
vec3 ro = vec3(0.0, 0.52, 2.75);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.12, -1.52));
// 3 vibrant neon cylindrical tube area lights suspended above a glossy studio floor
vec3 t0A = vec3(-1.05, 0.22 + 0.14 * sin(tAnim * 0.7), -0.75 - halfL * 0.7);
vec3 t0B = vec3(-0.72, 0.88 + 0.14 * sin(tAnim * 0.7), -0.75 + halfL * 0.7);
vec3 c0 = vec3(0.18, 1.65, 2.45); // electric cyan
vec3 t1A = vec3(-halfL, 0.58 + 0.12 * cos(tAnim * 0.55), -1.45);
vec3 t1B = vec3(halfL, 0.58 - 0.12 * cos(tAnim * 0.55), -1.45);
vec3 c1 = vec3(2.45, 1.35, 0.32); // warm tungsten gold
vec3 t2A = vec3(0.75, 0.84 - 0.12 * sin(tAnim * 0.8), -0.82 + halfL * 0.65);
vec3 t2B = vec3(1.10, 0.18 - 0.12 * sin(tAnim * 0.8), -0.82 - halfL * 0.65);
vec3 c2 = vec3(2.35, 0.28, 1.35); // neon magenta
// Raymarch gallery geometry (glossy floor + rear curved wall + matte monoliths + glowing tubes)
vec3 col = vec3(0.015, 0.020, 0.032);
float t = 0.0;
float matId = 0.0;
bool hit = false;
for (int i = 0; i < 68; i++) {
vec3 p = ro + rd * t;
float d = p.y + 0.55; matId = 1.0; // glossy floor
float dBack = 2.15 + p.z; if (dBack < d) { d = dBack; matId = 2.0; }
float dPlinth = sdBox(p - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32)) - 0.03;
if (dPlinth < d) { d = dPlinth; matId = 3.0; }
float dT0 = sdCapsule(p, t0A, t0B, tubeR); if (dT0 < d) { d = dT0; matId = 4.0; }
float dT1 = sdCapsule(p, t1A, t1B, tubeR); if (dT1 < d) { d = dT1; matId = 5.0; }
float dT2 = sdCapsule(p, t2A, t2B, tubeR); if (dT2 < d) { d = dT2; matId = 6.0; }
if (d < 0.002) { hit = true; break; }
t += d;
if (t > 12.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
if (matId > 3.5) {
if (matId < 4.5) col = c0 * 2.2;
else if (matId < 5.5) col = c1 * 2.2;
else col = c2 * 2.2;
} else {
vec3 n = vec3(0.0, 1.0, 0.0);
float localRough = rough;
vec3 baseAlb = vec3(0.18, 0.20, 0.24);
if (matId < 1.5) {
n = vec3(0.0, 1.0, 0.0);
// Subtle spatial roughness variation across stone floor tiles
vec2 tile = floor(p.xz * 1.25);
float tv = fract(sin(dot(tile, vec2(12.98, 78.23))) * 43758.5);
localRough = clamp(rough * (0.78 + 0.44 * tv), 0.04, 0.9);
baseAlb = mix(vec3(0.14, 0.16, 0.20), vec3(0.22, 0.24, 0.28), tv);
} else if (matId < 2.5) {
n = vec3(0.0, 0.0, 1.0);
localRough = clamp(rough + 0.22, 0.12, 0.92);
baseAlb = vec3(0.20, 0.22, 0.26);
} else {
vec2 e = vec2(0.0025, 0.0);
n = normalize(vec3(
sdBox(p + e.xyy - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32)) - sdBox(p - e.xyy - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32)),
sdBox(p + e.yxy - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32)) - sdBox(p - e.yxy - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32)),
sdBox(p + e.yyx - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32)) - sdBox(p - e.yyx - vec3(0.0, -0.30, -0.52), vec3(0.38, 0.25, 0.32))
));
localRough = clamp(rough * 0.72, 0.05, 0.8);
baseAlb = vec3(0.26, 0.28, 0.32);
}
vec3 v = -rd;
vec3 lit = baseAlb * vec3(0.03, 0.035, 0.05);
lit += evalTubeLight(p, n, v, t0A, t0B, tubeR, c0, localRough);
lit += evalTubeLight(p, n, v, t1A, t1B, tubeR, c1, localRough);
lit += evalTubeLight(p, n, v, t2A, t2B, tubeR, c2, localRough);
col = lit;
}
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| ltc-cylindrical-tube-lights-live | Tesla T4 1920x1080 | 30.1× baseline (heavy) · 0.945 ms / 0.997 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| ltc-cylindrical-tube-lights-live | NVIDIA L4 1920x1080 | 27.4× baseline (heavy) · 0.434 ms / 0.438 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| ltc-cylindrical-tube-lights-live | NVIDIA A100-SXM4-40GB 1920x1080 | 20.0× baseline (heavy) · 0.576 ms / 0.579 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Linearly Transformed Cosines for Area Lights: Reuses the exact same precomputed GGX LTC lookup textures to support both polygonal and cylindrical lights in one shader.
- Split-Sum Image-Based Lighting: Combines analytic local tube lighting with prefiltered environment maps for ambient reflections.
Sources
- primaryEric Heitz, Stephen Hill (2017). Linear-Light Shading with Linearly Transformed Cosines. GPU Zen, 2017.Verified via live page · 2026-11-30
- primaryEric Heitz, Jonathan Dupuy, Stephen Hill, David Neubelt (2016). Real-time polygonal-light shading with linearly transformed cosines. ACM Transactions on Graphics.Verified via crossref · 2026-11-30doi:10.1145/2897824.2925895
- implementationselfshadow (2017). selfshadow/ltc_code. Code for "Real-Time Polygonal-Light Shading with Linearly Transformed Cosines"GitHub API · license NOASSERTION · 2026-11-30
- implementationmrdoob (2026). mrdoob/codevember-2026. Daily creative agentic coding experiments for November 2026.GitHub API · license MIT · 2026-11-30