Atlaslog / Field Notes / three.js rendering
Field note · three.js rendering
Stacked transparent glass renders as solid slabs
Quick answer
With transparent: true and opacity 0.4 the glass panes still occlude everything behind them, so the interior or the next facade never shows through. Transparent meshes keep depthWrite enabled and are sorted per object, not per face.
Symptom
- A single pane looks correct, but two panes front to back make the rear one invisible or swap order as the camera rotates.
- Interior columns and furniture behind the glazing never appear.
- A glass box made of many faces shows some faces missing and some stacking a darker colour.
Checklist
- Set depthWrite: false on the glass material and see whether the rear surface appears.
- Temporarily set transparent: false and opacity 1 to confirm geometry and winding.
- Try side: THREE.DoubleSide to rule out back-face culling.
- Check whether the glass is one mesh with many faces, which per-object sorting cannot order.
Fix
Use MeshPhysicalMaterial with depthWrite: false, side: THREE.DoubleSide, transmission 0.6 and renderOrder 10, or assign renderOrder 100 - i per layer so distant panes draw first; use alphaTest 0.5 with transparent: false for cut-out foliage.
Code
var glassMat = new THREE.MeshPhysicalMaterial({
color: 0x9fc6e8,
transparent: true,
opacity: 0.35,
roughness: 0.1,
metalness: 0,
depthWrite: false, // 关键
side: THREE.DoubleSide,
transmission: 0.6
});
glassMat.renderOrder = 10; // 数值大的后画glassLayers.forEach(function (mesh, i) {
mesh.material.depthWrite = false;
mesh.renderOrder = 100 - i; // 远景先画
});
Watch out
- Turning transparent off to remove the sorting artifact makes the glass fully opaque and hides the interior.
- Keeping depthWrite: true and only lowering opacity still culls the rear panes in the depth test.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). Stacked transparent glass renders as solid slabs. https://www.jingweizhi.com/en/cookbook/three-material-transparent.html (accessed 2026-11-03).