05 / 08 · RELIGHTING
Use SH for light, not just appearanceSH 不只表达外观,也能表达光照
Understand lighting coefficients, transfer and TranSplat.理解光照系数、传输与 TranSplat。
Same basis, different functions同一套基底,不同的函数
Appearance SH maps outgoing viewing direction to captured RGB. Lighting SH maps incoming direction to environment radiance. Both can use Yₖ, but coefficients represent different functions. Each RGB channel is evaluated separately, then combined for display.外观 SH 把出射观察方向映射到捕获 RGB;光照 SH 把入射方向映射到环境辐亮度。两者可用相同 Yₖ,但系数代表不同函数。RGB 各通道独立求值,最后合成显示。
Our BRDF v points from surface to camera. Some GS appearance code uses camera-to-Gaussian instead. Negating a direction changes odd SH band signs: never copy coefficients without checking direction, normalization and basis ordering.这里 BRDF 的 v 从表面指向相机。有些 GS 外观代码使用相机指向 Gaussian。方向取反会改变奇数阶 SH 符号,所以复制系数前必须核对方向、归一化与基函数顺序。
Turn the integral into a dot product把积分变成点积
Define transfer K(ω)=V(ω)max(n·ω,0). Expand light and transfer in the same orthonormal real SH basis. Multiply their sums and integrate. Different basis pairs integrate to zero, matching pairs to one. Only matching coefficient products remain.定义传输 K(ω)=V(ω)max(n·ω,0)。将光照与传输展开到同一组标准正交实 SH 基底。两个求和相乘再积分,不同基函数对积分为 0,相同基函数对为 1,只剩对应系数相乘再相加。
For unoccluded diffuse light the cosine kernel is smooth. Bands l=0,1,2 give 1+3+5=9 coefficients per channel, often a good approximation of irradiance. Sharp shadows and mirror reflections need more directional detail. Moving geometry changes K even with a fixed environment.无遮挡漫反射的余弦核很平滑。l=0、1、2 阶每通道共 1+3+5=9 个系数,往往能较好近似辐照度。锐利阴影与镜面反射需要更多方向细节。即使环境固定,运动几何也会改变 K。
Why an irradiance ratio can help为什么辐照度比率能派上用场
In a purely diffuse thought experiment, with unchanged normals and visibility, old color is proportional to ρEold and new color to ρEnew. Dividing cancels ρ. The ratio fails when old irradiance is tiny, shadows change, or specularity violates the assumption. A denominator floor prevents numerical explosion; it does not recover missing information.在法线与可见性不变的纯漫反射思想实验中,旧颜色正比于 ρEold,新颜色正比于 ρEnew,相除可以消去 ρ。当旧辐照度很小、阴影改变或存在镜面反射时,假设会失效。分母下限能防止数值爆炸,却不能恢复缺失信息。
TranSplat (ICCP 2026) transfers trained oriented 2D Gaussian surfels using source/target environment maps, with separate specular treatment. Its official code was released in July 2026. It is a useful reproduction target, not a direct conversion of this STG-Lite asset. This simple ratio explains an intuition, not the complete method.TranSplat(ICCP 2026)使用源/目标环境贴图转移已训练的有方向 2D Gaussian surfel,并单独处理镜面反射。官方代码于 2026 年 7 月发布。它适合后续复现,但不能直接转换当前 STG-Lite 资产。这个简单比率只解释直觉,不是完整方法。
Predict it, then run it先预测,再运行
Open this experiment →打开对应实验 →The formula meets actual code公式连接真实代码
This excerpt is extracted from the repository during the site build. SH environment lighting and inverse training are future extensions; their chapters point to the current direct-light/data boundary, not an implemented trainer.此片段在网站构建时从仓库提取。SH 环境光照与逆向训练是未来扩展;对应章节指向当前直射光/数据接口,不代表已实现训练器。
src/relight.wgsl · L24–54
fn masking(cosine: f32, a2: f32) -> f32 {
return 2.0 * cosine / max(cosine + sqrt(a2 + (1.0-a2)*cosine*cosine), 1e-6);
}
fn shade(s: Splat) -> vec3<f32> {
let n = normalize(s.normal.xyz);
let v = normalize(g.eye.xyz - s.center.xyz);
let l = g.light.xyz;
let mode = u32(g.material.z);
if mode == 3u { return n * 0.5 + 0.5; }
if mode == 4u { return s.base.xyz; }
let nl = max(dot(n,l), 0.0);
let nv = max(dot(n,v), 0.0);
if nl <= 0.0 || nv <= 0.0 { return vec3(0.0); }
let h = normalize(l+v);
let nh = max(dot(n,h), 0.0);
let vh = max(dot(v,h), 0.0);
let a = g.material.x * g.material.x;
let a2 = a*a;
let denominator = nh*nh*(a2-1.0)+1.0;
let d = a2 / (3.14159265359 * denominator * denominator);
let f0 = mix(vec3(0.04), s.base.xyz, g.material.y);
let fresnel = f0 + (1.0-f0)*pow(1.0-vh, 5.0);
let geometry = masking(nl,a2)*masking(nv,a2);
let specular = d*fresnel*geometry / max(4.0*nl*nv, 1e-6);
let diffuse = (1.0-fresnel)*(1.0-g.material.y)*s.base.xyz/3.14159265359;
var brdf = diffuse+specular;
if mode == 1u { brdf = diffuse; }
if mode == 2u { brdf = specular; }
// One white distant light, no occlusion, no indirect illumination.
return brdf * nl * g.light.w;
}Check your understanding检查是否真正理解
Can nine lighting SH coefficients accurately reproduce a tiny sharp highlight?九个光照 SH 系数能准确复现很小很锐利的高光吗?
Reveal the reasoning展开推理
Usually no. Low-order SH loses high-frequency detail. Specular IBL commonly uses prefiltered environment maps and a BRDF lookup, or more expensive integration.通常不能。低阶 SH 丢失高频细节。镜面 IBL 常用预过滤环境贴图和 BRDF 查表,或更昂贵的积分。