MoGe (Monocular Geometry Estimation) × Screen-Space Global Illumination
Bounce light inside a photograph. Drop a virtual lamp into a single photo and get coloured bounce light and occlusion from the photo's own surfaces. One network supplies the G-buffer, and the photo's pixels act as the radiance buffer that screen-space GI gathers from.
Open in StudioReproduced41.1× · 1.27 ms
Verified proof

Split-screen WebGL2 proof comparing a flat 2D additive light overlay painted onto a gallery photograph (left, ignoring 3D surface orientation, cast shadows, and indirect color bleed) against MoGe-style monocular metric depth & normal reconstruction driving direct relighting, screen-space contact shadows, and 1-bounce screen-space GI color bleed from a colored alcove wall onto neighboring surfaces (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · replaces flat 2D light overlays with physically grounded depth-reconstructed normal shading, contact shadows, and 1-bounce screen-space GI color bleed
Show GLSL proof (189 lines)
const float P_LIGHT_GAIN = 1.65; // P Virtual Light Power [0.4, 3.0, 0.05]
const float P_SSGI_BOUNCE = 1.45; // P 1-Bounce SSGI Gain [0.0, 2.8, 0.05]
const float P_SHADOW_LEN = 0.22; // P Contact Shadow Range [0.05, 0.40, 0.01]
const float P_LIGHT_SWING = 1.00; // P Virtual Light Orbit [0.0, 2.0, 0.05]
float sdBox2(vec2 p, vec2 b) {
vec2 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
}
// Synthetic gallery photograph + MoGe metric depth map: returns vec4(linearAlbedoRGB, metricDepthZ)
vec4 samplePhotoAndDepth(vec2 p) {
// Back plastered gallery wall at depth 2.40 + angled side alcove wall
float z = 2.40 - 0.35 * smoothstep(0.18, 0.46, abs(p.x));
vec3 alb = vec3(0.76, 0.72, 0.65);
// Subtle plaster trowel grain
float plaster = 0.96 + 0.04 * sin(p.x * 65.0 + sin(p.y * 52.0));
alb *= plaster;
// Left recessed cobalt-blue architectural panel (rich GI bounce source)
if (p.x < -0.17 && p.y > -0.24 && p.y < 0.36) {
z = min(z, 2.18);
alb = vec3(0.12, 0.38, 0.86) * plaster;
}
// Right warm vermilion gallery panel (second GI bounce source)
if (p.x > 0.19 && p.y > -0.24 && p.y < 0.36) {
z = min(z, 2.18);
alb = vec3(0.88, 0.26, 0.14) * plaster;
}
// Floor plane sloping forward below y = -0.24
if (p.y < -0.24) {
float fy = (-0.24 - p.y) / 0.26;
z = mix(2.38, 1.35, clamp(fy, 0.0, 1.0));
float plank = 0.90 + 0.10 * sin(p.x * 32.0);
alb = vec3(0.46, 0.42, 0.38) * plank;
}
// Foreground stone plinth & sculpted ceramic orb centered in alcove
float plinthD = sdBox2(p - vec2(0.0, -0.26), vec2(0.12, 0.13));
if (plinthD < 0.0) {
float pz = 1.68 + 0.06 * abs(p.x / 0.12);
if (pz < z) {
z = pz;
alb = vec3(0.68, 0.66, 0.62) * plaster;
}
}
// Sculpted matte plaster bust/sphere resting on plinth
vec2 sc = p - vec2(0.0, 0.02);
float sr = length(sc);
if (sr < 0.155) {
float sz = 1.72 - sqrt(max(0.155 * 0.155 - sr * sr, 0.0)) * 1.45;
if (sz < z) {
z = sz;
alb = vec3(0.86, 0.84, 0.80);
}
}
// Small terracotta pitcher on left of plinth
vec2 vc = p - vec2(-0.18, -0.17);
float vr = length(vc * vec2(1.25, 0.92));
if (vr < 0.085) {
float vz = 1.85 - sqrt(max(0.085 * 0.085 - vr * vr, 0.0)) * 1.35;
if (vz < z) {
z = vz;
alb = vec3(0.82, 0.36, 0.18);
}
}
return vec4(alb, z);
}
// Reconstruct 3D view-space position & normal from MoGe metric depth buffer
vec3 posFromDepth(vec2 p, float z) {
return vec3(p * z * 0.92, -z);
}
vec3 normalFromDepth(vec2 p) {
float e = 0.0045;
vec3 pC = posFromDepth(p, samplePhotoAndDepth(p).a);
vec3 pR = posFromDepth(p + vec2(e, 0.0), samplePhotoAndDepth(p + vec2(e, 0.0)).a);
vec3 pU = posFromDepth(p + vec2(0.0, e), samplePhotoAndDepth(p + vec2(0.0, e)).a);
vec3 n = normalize(cross(pR - pC, pU - pC));
return n.z < 0.0 ? -n : n;
}
// Screen-space contact shadow march toward inserted 3D virtual light
float ssContactShadow(vec2 p, vec3 wPos, vec3 lightPos) {
vec2 lightUV = lightPos.xy / max(-lightPos.z * 0.92, 0.2);
vec2 dir2 = lightUV - p;
float dist2 = length(dir2);
if (dist2 < 0.005) return 1.0;
dir2 /= dist2;
float maxStep = min(dist2, P_SHADOW_LEN);
const int STEPS = 12;
for (int i = 1; i <= STEPS; i++) {
float frac = float(i) / float(STEPS);
vec2 q = p + dir2 * (frac * maxStep);
float rayZ = mix(-wPos.z, -lightPos.z, clamp((frac * maxStep) / max(dist2, 1e-4), 0.0, 1.0));
float sampleZ = samplePhotoAndDepth(q).a;
if (sampleZ < rayZ - 0.025 && (rayZ - sampleZ) < 0.38) {
return 0.12;
}
}
return 1.0;
}
// Direct radiance at any screen point (used both for primary shading and 1-bounce SSGI gathering)
vec3 evalDirectRelight(vec2 p, vec3 lightPos, out vec3 outAlb, out vec3 outPos, out vec3 outN) {
vec4 pd = samplePhotoAndDepth(p);
outAlb = pd.rgb;
outPos = posFromDepth(p, pd.a);
outN = normalFromDepth(p);
vec3 toL = lightPos - outPos;
float dL = length(toL);
vec3 L = toL / max(dL, 1e-4);
float ndl = max(dot(outN, L), 0.0);
float atten = P_LIGHT_GAIN / (0.28 + 1.45 * dL * dL);
vec3 lightCol = vec3(1.15, 0.98, 0.78);
return outAlb * lightCol * ndl * atten;
}
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 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
bool useSSGI = uv.x > 0.0;
vec2 p = vec2(useSSGI ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
p.x *= 1.85;
// Animated virtual gallery spotlight moving in front of the photographed alcove
vec3 lightPos = vec3(0.42 * sin(iTime * 0.75 * P_LIGHT_SWING), 0.24 + 0.14 * cos(iTime * 0.55 * P_LIGHT_SWING), -1.32);
vec2 lightUV = lightPos.xy / (-lightPos.z * 0.92);
vec3 alb, wPos, N;
vec3 direct = evalDirectRelight(p, lightPos, alb, wPos, N);
vec3 basePhotoAmbient = alb * vec3(0.14, 0.15, 0.18);
vec3 col = vec3(0.0);
if (!useSSGI) {
// Left: naive 2D flat additive spotlight overlay on photo (no depth normals, no shadows, no color bounce)
float d2 = length(p - lightUV);
float flatFalloff = P_LIGHT_GAIN * 0.42 / (0.12 + 4.8 * d2 * d2);
col = basePhotoAmbient * 1.45 + alb * vec3(1.15, 0.98, 0.78) * flatFalloff;
} else {
// Right: MoGe metric-depth normal shading + contact shadows + 8-direction 1-bounce SSGI gather
float sh = ssContactShadow(p, wPos, lightPos);
vec3 gi = vec3(0.0);
float visAO = 0.0;
const int DIRS = 8;
for (int i = 0; i < DIRS; i++) {
float a = (float(i) + 0.5) * 6.2831853 / float(DIRS);
vec2 dir2 = vec2(cos(a), sin(a));
float maxElev = -0.5;
for (int s = 1; s <= 3; s++) {
float r = float(s) * 0.072;
vec2 q = p + dir2 * r;
if (abs(q.x) > 0.48 || abs(q.y) > 0.48) break;
vec3 qAlb, qPos, qN;
vec3 qRad = evalDirectRelight(q, lightPos, qAlb, qPos, qN);
vec3 diff = qPos - wPos;
float dist = length(diff);
if (dist > 0.02) {
vec3 dDir = diff / dist;
float cosRecv = max(dot(N, dDir), 0.0);
float cosEmit = max(dot(qN, -dDir), 0.15);
float elev = dot(N, dDir);
if (elev > maxElev) {
float form = cosRecv * cosEmit / (0.18 + dist * dist * 2.8);
gi += qRad * form * 0.72;
maxElev = elev;
}
}
}
visAO += clamp(1.0 - max(maxElev, 0.0) * 0.75, 0.15, 1.0);
}
gi = (gi / float(DIRS)) * P_SSGI_BOUNCE;
float ao = visAO / float(DIRS);
col = basePhotoAmbient * ao + direct * sh + alb * gi * 2.2;
}
// Subtle glowing virtual bulb reticle showing inserted light position
float bulb = exp(-length(p - lightUV) * 46.0);
col += vec3(1.6, 1.35, 0.95) * bulb;
col = acesTone(col);
if (abs(uv.x) < 0.003) 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
MoGe (Monocular Geometry Estimation) outputs a point map from one image, with depth, normals and a field of view derived from it. Screen-Space Global Illumination consumes depth, normals and radiance: depth and normals come from MoGe (the depth hop), and the radiance input is the photo's linearised colour plus the virtual light's direct contribution. Gathering then treats visible photo pixels as small emitters, so a red sofa near the new lamp tints the floor and walls. The output radiance is added to the photo, and the same samples give directional occlusion around inserted objects.
How to build it
Python, or a WebGPU tool. Run MoGe, recover the focal length, and build view-space positions and normals at photo resolution. Linearise the photo and estimate rough albedo by dividing out a smoothed luminance, to avoid doubling existing light. Add a point or area light and shade its direct contribution with that albedo and the normals, optionally with a Screen-Space Contact Shadows march for grounding. Run a hierarchical-depth SSGI trace over the combined radiance for one bounce, denoise spatially, and composite. Inserted 3D objects can be rasterised into the same depth buffer so they both receive and cast bounce light.
Field marks
- Photo colour already contains lighting, so naive gathering double-counts it.
- Monocular normals are smooth and miss small creases, softening occlusion.
- Screen-space gathering cannot see surfaces outside or behind the frame.
- Glass and mirrors produce wrong geometry and wrong bounces.
Prior art
No prior art found on 2026-11-29.
Searches run (4)
- arXiv: all:"monocular geometry" AND all:"relighting" → 0 results
- GitHub repos: "monocular geometry" relighting → 0 results
- arXiv: all:"single image" AND all:"virtual light" AND all:"global illumination" → 0 results
- GitHub repos: "single image" "virtual light" "global illumination" → 0 results