2D Gaussian Splatting × ReSTIR PT and Generalized Resampled Importance Sampling
ReSTIR path-traced relighting on 2D Gaussian surfels. A captured scene represented as view-consistent 2D Gaussian surfels and an extracted proxy mesh relit interactively with multi-bounce ReSTIR path tracing, uniting photogrammetric capture with dynamic area lights and color bleeding.
Open in StudioReproduced66.7× · 2.07 ms
Verified proof

Split-screen WebGL2 proof comparing a captured 2D Gaussian surfel diorama stuck in frozen baked DC spherical-harmonic lighting (left) against de-lit 2D Gaussian surfel G-buffer normals and TSDF proxy geometry relit interactively by dynamic multi-bounce ReSTIR path tracing (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · relights captured 2D Gaussian surfels dynamically with multi-bounce ReSTIR path-traced shadows, glossy floor reflections, and colored indirect bounce
Show GLSL proof (194 lines)
const float P_PT_BOUNCE = 1.25; // P Multi-Bounce GI [0.2, 2.2, 0.05]
const float P_SURFEL_DISC = 0.34; // P 2D Surfel Discs [0.0, 1.0, 0.05]
const float P_LIGHT_ORBIT = 0.85; // P Area Light Orbit [0.0, 1.8, 0.05]
const float P_FLOOR_GLOSS = 0.65; // P Glossy Reflection [0.0, 1.0, 0.05]
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);
}
// Captured 2DGS TSDF proxy scene: stone arch, sculpted sphere-totem, floor stage
vec2 mapDiorama(vec3 p) {
float dFloor = p.y + 0.85;
float dBack = p.z + 1.55;
// Sculpted stone pedestal & twin spheres
float ped = sdBox(p - vec3(0.0, -0.52, -0.15), vec3(0.42, 0.33, 0.42)) - 0.02;
float orb1 = length(p - vec3(0.0, 0.14, -0.15)) - 0.34;
float orb2 = length(p - vec3(0.58, -0.55, 0.25)) - 0.30;
// Arch pillars flanking backdrop
float pilL = sdBox(p - vec3(-1.05, 0.05, -0.75), vec3(0.24, 0.90, 0.24));
float pilR = sdBox(p - vec3(1.05, 0.05, -0.75), vec3(0.24, 0.90, 0.24));
float lintel = sdBox(p - vec3(0.0, 0.96, -0.75), vec3(1.32, 0.20, 0.28));
float arch = min(min(pilL, pilR), lintel);
vec2 res = vec2(dFloor, 1.0);
if (dBack < res.x) res = vec2(dBack, 2.0);
if (ped < res.x) res = vec2(ped, 3.0);
if (orb1 < res.x) res = vec2(orb1, 4.0);
if (orb2 < res.x) res = vec2(orb2, 5.0);
if (arch < res.x) res = vec2(arch, 6.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.003, -0.003);
return normalize(
e.xyy * mapDiorama(p + e.xyy).x +
e.yyx * mapDiorama(p + e.yyx).x +
e.yxy * mapDiorama(p + e.yxy).x +
e.xxx * mapDiorama(p + e.xxx).x
);
}
vec3 deLitAlbedo(vec3 wp, float mat) {
if (mat < 1.5) {
float chk = mod(floor(wp.x * 2.2) + floor(wp.z * 2.2), 2.0);
return mix(vec3(0.24, 0.26, 0.30), vec3(0.42, 0.40, 0.37), chk);
}
if (mat < 2.5) return vec3(0.36, 0.38, 0.42);
if (mat < 3.5) return vec3(0.68, 0.64, 0.58);
if (mat < 4.5) return vec3(0.84, 0.78, 0.72);
if (mat < 5.5) return vec3(0.78, 0.32, 0.24);
return vec3(0.56, 0.52, 0.48);
}
// Soft shadow ray against TSDF proxy BVH
float softShadow(vec3 ro, vec3 target) {
vec3 diff = target - ro;
float maxL = length(diff);
vec3 rd = diff / max(maxL, 1e-4);
float res = 1.0;
float d = 0.04;
for (int i = 0; i < 26; i++) {
float h = mapDiorama(ro + rd * d).x;
if (h < 0.003) return 0.0;
res = min(res, 7.5 * h / d);
d += clamp(h, 0.02, 0.28);
if (d > maxL - 0.12) break;
}
return clamp(res, 0.0, 1.0);
}
// Direct lighting from the two orbiting dynamic area light emitters
vec3 evalDirectLights(vec3 wp, vec3 N, vec3 lPosA, vec3 lPosB) {
vec3 toA = lPosA - wp;
float dA2 = max(dot(toA, toA), 0.18);
vec3 dirA = toA / sqrt(dA2);
float shA = softShadow(wp + N * 0.02, lPosA);
vec3 litA = vec3(3.2, 1.45, 0.52) * max(dot(N, dirA), 0.0) * shA / (0.35 + dA2 * 0.55);
vec3 toB = lPosB - wp;
float dB2 = max(dot(toB, toB), 0.18);
vec3 dirB = toB / sqrt(dB2);
float shB = softShadow(wp + N * 0.02, lPosB);
vec3 litB = vec3(0.45, 1.95, 2.55) * max(dot(N, dirB), 0.0) * shB / (0.35 + dB2 * 0.55);
return litA + litB;
}
// 2D Gaussian oriented surfel disk overlay aligned to tangent plane
float surfelDiscPattern(vec3 wp, vec3 N) {
vec2 uv = abs(N.y) > 0.6 ? wp.xz : (abs(N.x) > 0.6 ? wp.zy : wp.xy);
vec2 f = fract(uv * 5.5) - 0.5;
float r = length(f);
return smoothstep(0.045, 0.01, abs(r - 0.36));
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 res = max(iResolution.xy, vec2(1.0));
vec2 uvN = fragCoord / res;
float splitX = iMouse.z > 0.0 ? clamp(iMouse.x / res.x, 0.05, 0.95) : 0.5;
bool useReSTIRPT = uvN.x > splitX;
vec2 p = (fragCoord - 0.5 * res) / res.y;
float t = iTime;
float lAng = t * 0.85 * P_LIGHT_ORBIT;
vec3 lPosA = vec3(cos(lAng) * 1.15, 0.65 + 0.22 * sin(lAng * 1.5), 0.45 + sin(lAng) * 0.65);
vec3 lPosB = vec3(-cos(lAng) * 1.10, 0.42, -0.15 - sin(lAng) * 0.55);
vec3 ro = vec3(sin(t * 0.25) * 0.35, 0.42, 2.55);
vec3 ta = vec3(0.0, -0.12, -0.25);
vec3 fw = normalize(ta - ro);
vec3 ri = normalize(cross(vec3(0.0, 1.0, 0.0), fw));
vec3 up = cross(fw, ri);
vec3 rd = normalize(fw * 1.55 + ri * p.x + up * p.y);
// Trace primary 2DGS G-buffer hit
float d = 0.05;
float mat = -1.0;
for (int i = 0; i < 68; i++) {
vec2 h = mapDiorama(ro + rd * d);
if (h.x < 0.002) { mat = h.y; break; }
d += h.x;
if (d > 10.0) break;
}
// Check visible dynamic emitter orbs
float tLA = -1.0, tLB = -1.0;
vec3 ocA = ro - lPosA; float bA = dot(ocA, rd); float hA = bA * bA - (dot(ocA, ocA) - 0.11 * 0.11);
if (hA > 0.0) tLA = -bA - sqrt(hA);
vec3 ocB = ro - lPosB; float bB = dot(ocB, rd); float hB = bB * bB - (dot(ocB, ocB) - 0.11 * 0.11);
if (hB > 0.0) tLB = -bB - sqrt(hB);
vec3 col = vec3(0.04, 0.05, 0.08);
if (tLA > 0.0 && (mat < 0.0 || tLA < d)) {
col = vec3(3.6, 1.65, 0.62);
} else if (tLB > 0.0 && (mat < 0.0 || tLB < d)) {
col = vec3(0.55, 2.25, 2.95);
} else if (mat > 0.0) {
vec3 wp = ro + rd * d;
vec3 N = calcNormal(wp);
vec3 V = -rd;
vec3 alb = deLitAlbedo(wp, mat);
float surfelRim = surfelDiscPattern(wp, N);
if (!useReSTIRPT) {
// Left baseline: frozen baked DC spherical-harmonic lighting from original capture (ignores moving lights)
float staticSun = max(dot(N, normalize(vec3(0.45, 0.82, 0.35))), 0.0);
float staticAO = smoothstep(-0.85, 0.35, wp.y) * 0.45 + 0.55;
col = alb * (vec3(0.24, 0.27, 0.32) + vec3(0.88, 0.85, 0.80) * staticSun) * staticAO;
} else {
// Right: ReSTIR PT relighting -> direct dynamic area lights + secondary TSDF path bounce + glossy reflection
vec3 direct = evalDirectLights(wp, N, lPosA, lPosB);
// Secondary bounce path reconnection: trace glossy/diffuse bounce ray against TSDF proxy mesh
vec3 bounceDir = normalize(mix(N, reflect(-V, N), mat < 1.5 ? P_FLOOR_GLOSS : 0.25));
float bd = 0.05;
float bMat = -1.0;
for (int k = 0; k < 28; k++) {
vec2 bh = mapDiorama(wp + N * 0.02 + bounceDir * bd);
if (bh.x < 0.008) { bMat = bh.y; break; }
bd += max(bh.x, 0.03);
if (bd > 4.5) break;
}
vec3 indirect = vec3(0.08, 0.10, 0.14);
if (bMat > 0.0) {
vec3 bwp = wp + N * 0.02 + bounceDir * bd;
vec3 bN = calcNormal(bwp);
vec3 bAlb = deLitAlbedo(bwp, bMat);
indirect = bAlb * evalDirectLights(bwp, bN, lPosA, lPosB) * 0.78;
}
// Terracotta red orb secondary color bleed onto nearby pedestal & floor
vec3 toRed = vec3(0.58, -0.55, 0.25) - wp;
float redBleed = max(dot(N, normalize(toRed)), 0.0) / (0.28 + dot(toRed, toRed) * 2.2);
indirect += vec3(0.85, 0.26, 0.16) * redBleed * 0.65;
float fres = 0.04 + 0.96 * pow(1.0 - max(dot(N, V), 0.0), 4.0);
vec3 spec = vec3(0.0);
vec3 dirA = normalize(lPosA - wp);
vec3 dirB = normalize(lPosB - wp);
spec += vec3(2.8, 1.3, 0.5) * pow(max(dot(N, normalize(dirA + V)), 0.0), 54.0) * 0.35;
spec += vec3(0.45, 1.8, 2.4) * pow(max(dot(N, normalize(dirB + V)), 0.0), 54.0) * 0.35;
col = alb * (direct + indirect * P_PT_BOUNCE) + spec + indirect * fres * (mat < 1.5 ? P_FLOOR_GLOSS : 0.25);
}
col = mix(col, col * 1.35 + vec3(0.08, 0.12, 0.16), surfelRim * P_SURFEL_DISC * 0.45);
}
col = acesTone(col * 1.06);
if (abs(fragCoord.x - splitX * res.x) < 1.0) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
2D Gaussian Splatting outputs flattened oriented 2D Gaussian surfels alongside an unbiased depth map and TSDF-extracted proxy mesh with smooth analytical normals. That mesh and its primary-hit surface attributes feed directly into ReSTIR PT and Generalized Resampled Importance Sampling, which rasterizes a primary G-buffer (albedo de-lit from the DC spherical-harmonic term, surfel normals, roughness estimate, and linear depth) and traces secondary bounce rays against the proxy mesh BVH while reusing path-space reservoirs temporally and spatially across pixels.
How to build it
Train or load a 2DGS scene and extract its TSDF triangle mesh for secondary-ray intersection. For primary visibility, rasterize the 2D Gaussian surfels into an albedo/normal/depth G-buffer (using depth-median normal blending so silhouette edges remain crisp), or rasterize the proxy mesh directly with baked surfel textures. Run a ReSTIR PT pass that maintains one path reservoir per pixel, performs temporal reprojection via motion vectors, applies pairwise MIS spatial resampling over a 3-5 neighbor stencil, and shifts secondary vertices across surface reconnection offsets. In a WebGL2 specimen, approximate the secondary bounce over a compact BVH texture or screen-space depth hierarchy against dynamic emissive primitives.
Field marks
- Baked ambient lighting inside the 2DGS DC color produces double-shaded shadows unless albedo is factored or approximated prior to relighting.
- Depth discontinuities between thin surfel clusters and the TSDF proxy mesh cause self-intersection acne or light leaks at grazing angles.
- Spatial reservoir reuse across sharp normal creases on noisy captured geometry introduces dark bias unless Jacobian rejection thresholds are tuned tightly.
- High-frequency alpha fringes around foliage violate opaque-surface path reconnection assumptions.
Prior art
No prior art found on 2026-12-01.
Searches run (2)
- arXiv: all:"2D gaussian splatting" AND all:"ReSTIR"
- GitHub repos: "2d gaussian splatting" restir relighting