07 / 08 · RELIGHTING
Add time without breaking the light加入时间,别让光照出错
Derive inverse-transpose normals and dynamic visibility.推导逆转置法线与动态可见性。
Keep the normal perpendicular让法线始终垂直
A tangent t lies along a surface and its normal n is perpendicular: nᵀt=0. A local linear deformation A turns the tangent into At. We need a new normal whose dot product with At is still zero.切线 t 沿着表面,法线 n 与它垂直,即 nᵀt=0。局部线性形变 A 把切线变成 At。我们需要新法线与 At 的点积仍为零。
Choose n′=A⁻ᵀn. Transpose it: n′ᵀ=nᵀA⁻¹. Then n′ᵀAt=nᵀA⁻¹At=nᵀt=0. The inverse cancels the deformation. Normalize the result because the BRDF needs unit directions.取 n′=A⁻ᵀn,转置后 n′ᵀ=nᵀA⁻¹。于是 n′ᵀAt=nᵀA⁻¹At=nᵀt=0,逆矩阵抵消形变。最后归一化,因为 BRDF 需要单位方向。
Stretch a diagonal surface by hand手算倾斜表面的拉伸
In 2D take n=(1,1)/√2 and t=(1,−1). Stretch x by 2: A=diag(2,1), so t′=(2,−1). Correct n′ is proportional to (1/2,1), giving dot product 1−1=0. The tempting An is proportional to (2,1), giving 4−1=3 instead.二维中取 n=(1,1)/√2,t=(1,−1)。令 A=diag(2,1) 将 x 拉伸两倍,新切线 t′=(2,−1)。正确 n′ 正比于 (1/2,1),点积 1−1=0。容易误用的 An 正比于 (2,1),点积却是 4−1=3。
For pure rotation R, R⁻ᵀ=R; rotating positions and normals alike works. Nonuniform scale or shear breaks this shortcut. Set time to 0.25 in the lab and toggle the intentionally wrong transform to see the shading error.纯旋转 R 满足 R⁻ᵀ=R,位置与法线用同样的旋转没问题。非均匀缩放或剪切会让捷径失效。在实验里把时间设为 0.25,再切换故意错误的变换,观察着色错误。
Time also changes visibility时间也会改变可见性
For nonlinear motion x′=f(x,t), use local A=∂f/∂x. Transport covariance by AΣAᵀ, normals by A⁻ᵀ, and material identity with the canonical point. Degenerate A needs rejection or a defined fallback. A separately learned normal field needs supervision or consistency constraints.非线性运动 x′=f(x,t) 应使用局部 A=∂f/∂x。协方差按 AΣAᵀ 传输,法线按 A⁻ᵀ 传输,材质身份跟随 canonical 点。退化 A 需要拒绝或明确回退。独立学习的法线场则需要监督或一致性约束。
Moving geometry changes light visibility V(x,l,t); a static occlusion bake cannot follow a moving blocker. BEAM studies volumetric video, BecomingLit specializes in heads, and DR-GS drives reconstructed assets with simulation/animation. These are different dynamic settings, not interchangeable 4DGS loaders.运动几何改变光照可见性 V(x,l,t),静态遮挡烘焙无法跟随运动遮挡物。BEAM 研究体积视频,BecomingLit 专注头部,DR-GS 用模拟/动画驱动重建资产。这些是不同动态设定,不是可互换的 4DGS 加载器。
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.rs · L106–139
fn surfel(n: Vec3, frame: RelightFrame) -> Splat {
let a = frame.transform();
let helper = if n.y.abs() < 0.9 { Vec3::Y } else { Vec3::X };
let u = n.cross(helper).normalize() * 0.065;
let v = n.cross(u).normalize() * 0.065;
let normal_matrix = if frame.wrong_normals {
a
} else {
a.inverse().transpose()
};
Splat {
center: (a * n).extend(0.96).to_array(),
u: (a * u).extend(0.0).to_array(),
v: (a * v).extend(0.0).to_array(),
w: (a * n * 0.008).extend(0.0).to_array(),
normal: (normal_matrix * n).normalize().extend(0.0).to_array(),
base: BASE.extend(0.0).to_array(),
}
}
fn scene(frame: RelightFrame, view: Mat4) -> Vec<Splat> {
let mut data: Vec<_> = (0..COUNT)
.map(|i| {
let y = 1.0 - 2.0 * (i as f32 + 0.5) / COUNT as f32;
let phi = i as f32 * 2.3999632;
let r = (1.0 - y * y).sqrt();
surfel(Vec3::new(r * phi.cos(), y, r * phi.sin()), frame)
})
.collect();
data.sort_by(|a, b| {
let z = |s: &Splat| view.transform_point3(Vec3::from_slice(&s.center[..3])).z;
z(a).total_cmp(&z(b)) // RH camera looks along -Z: far first
});
data
}Check your understanding检查是否真正理解
Can a moving object change shading and shadows even with a fixed light and camera?光源和相机不动,运动物体能改变着色与阴影吗?
Reveal the reasoning展开推理
Yes. Its normal changes the BRDF/cosine and its geometry changes light visibility. The material can stay the same while both effects vary.能。法线改变 BRDF/余弦,几何改变光照可见性。材质可以不变,而两种效果都会变化。