From 526148f774654b1fdfccad19c2782f227ab2f3f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Feb 2026 04:04:36 +0000 Subject: [PATCH] fix: force normal recomputation and fix material properties for decorations Decorations had triangle artifacts because: 1. cloneGeometryForGPU only computed normals when missing, not forcing recomputation of bad normals from AI models 2. extractMaterial didn't apply the same fixes as AssetManager (disable vertex colors, clear aoMap/lightMap) Now decorations get the same treatment as units/buildings, ensuring proper normals and clean materials for GTAO. https://claude.ai/code/session_012kqvccEiiHNQHAjUEoposi --- src/rendering/InstancedDecorations.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/rendering/InstancedDecorations.ts b/src/rendering/InstancedDecorations.ts index e1730a11..873c2d5d 100644 --- a/src/rendering/InstancedDecorations.ts +++ b/src/rendering/InstancedDecorations.ts @@ -107,9 +107,9 @@ function cloneGeometryForGPU(source: THREE.BufferGeometry): THREE.BufferGeometry } // Ensure normal coordinates exist - required for proper lighting and SSAO - // Some models from Tripo/Meshy AI lack normals, causing GTAO to reconstruct - // normals from depth gradients which creates visible triangular artifacts - if (!cloned.attributes.normal && cloned.attributes.position) { + // ALWAYS recompute normals - AI models from Tripo/Meshy often have incorrect + // or flat normals that cause dark triangular artifacts, especially with GTAO + if (cloned.attributes.position) { cloned.computeVertexNormals(); } @@ -196,6 +196,15 @@ function extractMaterial(object: THREE.Object3D, assetId?: string): THREE.Materi // Apply rendering hints for MeshStandardMaterial if ((material as THREE.MeshStandardMaterial).isMeshStandardMaterial) { const stdMaterial = material as THREE.MeshStandardMaterial; + + // Fix AI model artifacts - disable vertex colors and clear baked maps + // AI-generated models bake ambient occlusion into vertex colors causing triangles + stdMaterial.vertexColors = false; + stdMaterial.aoMap = null; + stdMaterial.aoMapIntensity = 0; + stdMaterial.lightMap = null; + stdMaterial.lightMapIntensity = 0; + const hints = assetId ? AssetManager.getRenderingHints(assetId) : null; if (hints) {