From 71985c4eb535c49aab344da01139dbfb7858270c Mon Sep 17 00:00:00 2001 From: Primitive Date: Thu, 26 Nov 2026 08:24:05 +0800 Subject: [PATCH] Face the studio lights the right way so dark finishes keep their colour The studio environment assumed the wrong equirect orientation, so its key softbox sat behind-left of the model, exactly where flat glossy tops mirror it into the default front-right camera. Black vinyl, paint and plastic read as silver. Orient the map the way three.js samples it, and keep the rim light and rim strip low behind the model. --- src/engine/renderer.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/engine/renderer.ts b/src/engine/renderer.ts index 7a322c7..624b78e 100644 --- a/src/engine/renderer.ts +++ b/src/engine/renderer.ts @@ -105,7 +105,8 @@ function createStudioHdrEquirectTexture(): THREE.DataTexture { for (let x = 0; x < width; x++) { const u = x / (width - 1); - const phi = u * Math.PI * 2; + // three.js samples equirect maps at u = atan2(z, x) / 2π + 0.5, so u = 0 faces -x. + const phi = u * Math.PI * 2 - Math.PI; const dx = sinT * Math.cos(phi); const dy = cosT; const dz = sinT * Math.sin(phi); @@ -140,9 +141,9 @@ function createStudioHdrEquirectTexture(): THREE.DataTexture { g += fillBox * 0.76; b += fillBox * 0.84; - // Crisp rear rim strip light - const rimDot = -dx * 0.32 + dy * 0.34 - dz * 0.88; - const rimStrip = THREE.MathUtils.smoothstep(rimDot, 0.84, 0.94); + // Crisp rear rim strip light, kept near the horizon for the same reason as the rim light. + const rimDot = -dx * 0.34 + dy * 0.12 - dz * 0.93; + const rimStrip = THREE.MathUtils.smoothstep(rimDot, 0.9, 0.96); r += rimStrip * 3.1; g += rimStrip * 3.35; b += rimStrip * 3.75; @@ -457,7 +458,9 @@ export class DecoderViewport { this.scene.add(this.keyLight); this.rimLight = new THREE.DirectionalLight('#93c5fd', 1.18); - this.rimLight.position.set(-6, 5, -7); + // Low behind the model: at (-6, 5, -7) every flat glossy top mirrored it straight into the + // default front-right camera, so dark plastics and paint read as silver. + this.rimLight.position.set(-6, 1.4, -7); this.scene.add(this.rimLight); this.fillLight = new THREE.DirectionalLight('#dbeafe', 0.65);