fix: 玻璃 mesh 改为仅 layer 10,消除折射 FBO 反馈环(GL_INVALID_OPERATION 每帧刷屏的根源)

- 原 enable(10) 会叠加层,mesh 仍留在 layer 0,被 layer-0 mask 的 FBO 通道画进自己采样的折射纹理 → 反馈环
- 现在 FBO 通道的 layer-0 mask 能真正排除玻璃;主相机 enable(10) 保持可见
- 验证:全组件开启 gl.getError()=0(修复前恒 1282),next build / tsc 通过
This commit is contained in:
2026-09-01 16:37:27 +08:00
parent eac0785cf6
commit 903b79dd2b
+11 -4
View File
@@ -404,11 +404,18 @@ function GlassModel({
return merged; return merged;
}, [gltf]); }, [gltf]);
// Glass renders on layers 0+10: visible in the main pass, excluded from the // Glass renders ONLY on layer 10: the FBO refraction pass forces the camera
// layer-0-mask FBO pass that feeds the refraction texture (no self-refraction). // mask to layer 0, so the glass mesh is excluded from its own refraction
// texture (an object with layer 0 kept enabled would pass the mask test and
// draw into the FBO it samples — a GL feedback loop, GL_INVALID_OPERATION
// every frame). The main camera enables layer 10 below, so glass stays
// visible in the normal pass. Matches the original GlassSystem.
useEffect(() => { useEffect(() => {
meshLayerRef.current?.layers.enable(10); const mesh = meshLayerRef.current;
}, [mergedGeometry]); if (!mesh) return;
mesh.layers.set(10);
camera.layers.enable(10);
}, [mergedGeometry, camera]);
const tintYRange = useMemo<[number, number]>(() => { const tintYRange = useMemo<[number, number]>(() => {
if (!mergedGeometry) return [0, 1]; if (!mergedGeometry) return [0, 1];