# TexelAtlas Babylon.js 3D Look-Dev Playbook

> Compact, zero-truncation agent guide for building game-quality 3D scenes in **Babylon.js** (8.x / 9.x (WebGL2 & WebGPU); verified against `9.38.0`).
> Read this BEFORE writing scene code. Every technique `slug` resolves to `https://texelatlas.vercel.app/t/<slug>.md` with verified equations, parameters, and failure modes.

## 1. Recommended Babylon.js Pipeline Architecture

- 1. `PBRMaterial` / `OpenPBRMaterial` with prefiltered `.env` IBL (`scene.environmentTexture`).
- 2. `CascadedShadowGenerator` (`usePercentageCloserFiltering = true` or `useContactHardeningShadow = true`) for large worlds, or tight `ShadowGenerator` for compact scenes.
- 3. Optional scene-specific layers: `MirrorTexture` with `clipPlane` for flat mirrors/water, `SSRRenderingPipeline` for glossy floors, and `@babylonjs/addons` `Atmosphere` for outdoor skies.
- 4. `SSAO2RenderingPipeline` (`expensiveBlur = true`) + `DefaultRenderingPipeline` (`bloomEnabled`, `fxaaEnabled` / `samples = 4`, `imageProcessing.toneMappingType = AGX` or `KHR_PBR_NEUTRAL`).

## 2. Scene Archetype Recipes (Pick 1 Technique Per Stage)

### Outdoor Architecture (`outdoor-architecture`)
Daylight or dusk exteriors, streets, plazas, buildings, and walkable outdoor spaces with crisp near-to-far shadows and atmospheric depth.
- **sky/ibl**: `split-sum-ibl` (builtin) + `hillaire-sky-atmosphere` (official) · **shadows**: `cascaded-shadow-maps` (builtin) + `percentage-closer-soft-shadows` (builtin) · **ao/gi**: `n8ao` + `ground-truth-ambient-occlusion` · **materials/micro**: `clearcoat-layer` (builtin) + `parallax-occlusion-mapping` (builtin) · **water/volumes**: `planar-reflections-oblique-clipping` (builtin) + `exponential-height-fog` · **post/aa**: `dual-filter-bloom` (builtin) + `agx-tonemapping`

### Interiors, Characters & Product Look-Dev (`interior-product`)
Rooms, galleries, character portraits, and automotive/product turntables with accurate area lights, local reflections, and layered PBR materials.
- **sky/ibl**: `split-sum-ibl` (builtin) + `ltc-area-lights` (builtin) · **shadows**: `percentage-closer-soft-shadows` (builtin) + `contact-shadows` · **ao/gi**: `ground-truth-ambient-occlusion` + `multi-bounce-ambient-occlusion` · **materials/micro**: `disney-principled-brdf` (builtin) + `clearcoat-layer` (builtin) · **water/volumes**: `screen-space-reflections` (builtin) · **post/aa**: `khronos-pbr-neutral` (builtin) + `agx-tonemapping`

### Sci-Fi, Cyberpunk, Space & Night Scenes (`scifi-night-neon`)
Dark moody interiors, rain-slicked neon streets, cockpits, and space environments with area lights, wet reflections, volumetric beams, and controlled HDR bloom.
- **sky/ibl**: `split-sum-ibl` (builtin) + `ltc-area-lights` (builtin) · **shadows**: `percentage-closer-soft-shadows` (builtin) + `contact-shadows` · **ao/gi**: `ground-truth-ambient-occlusion` + `n8ao` · **materials/micro**: `anisotropic-ggx` (builtin) + `clearcoat-layer` (builtin) · **water/volumes**: `screen-space-reflections` (builtin) + `volumetric-light-scattering-god-rays` (builtin) · **post/aa**: `dual-filter-bloom` (builtin) + `agx-tonemapping`

### Stylized, Painterly & NPR Worlds (`stylized-npr`)
Cohesive cel-shaded, anime, watercolor, ink-contour, or dithered 3D worlds with clean silhouette discipline and anti-aliased shading bands.
- **sky/ibl**: `environment-mapping-cubemaps` (builtin) + `hosek-wilkie-sky` · **shadows**: `cascaded-shadow-maps` (builtin) + `percentage-closer-filtering` (builtin) · **ao/gi**: `n8ao` + `hbao` · **materials/micro**: `inverted-hull-outline` (builtin) + `toon-shading` (official) · **water/volumes**: `exponential-height-fog` · **post/aa**: `kuwahara-filter` + `xdog-stylization`

### Oceans, Lakes & Coastal Environments (`water-coastal`)
Open seas, rivers, pools, and shorelines combining physical Fresnel, oblique planar reflections or FFT/Gerstner waves, and caustics.
- **sky/ibl**: `split-sum-ibl` (builtin) + `hillaire-sky-atmosphere` (official) · **shadows**: `cascaded-shadow-maps` (builtin) + `percentage-closer-filtering` (builtin) · **ao/gi**: `ground-truth-ambient-occlusion` + `n8ao` · **materials/micro**: `fresnel-schlick-approximation` (builtin) + `hex-tiling` (builtin) · **water/volumes**: `planar-reflections-oblique-clipping` (builtin) + `fft-ocean` · **post/aa**: `dual-filter-bloom` (builtin) + `agx-tonemapping`

### Large Terrain, Forests & Open Landscapes (`terrain-foliage`)
Wide natural vistas with anti-aliased grass and foliage, distance LOD, non-repeating rock/ground textures, clouds, and aerial perspective.
- **sky/ibl**: `split-sum-ibl` (builtin) + `hillaire-sky-atmosphere` (official) · **shadows**: `cascaded-shadow-maps` (builtin) + `contact-shadows` · **ao/gi**: `ground-truth-ambient-occlusion` + `multi-bounce-ambient-occlusion` · **materials/micro**: `hex-tiling` (builtin) + `triplanar-mapping` (official) · **water/volumes**: `exponential-height-fog` + `nubis-volumetric-clouds` · **post/aa**: `temporal-anti-aliasing` (builtin) + `agx-tonemapping`

## 3. Prototype Shortcuts to Avoid (Upgrade Table)

| Common Agent Shortcut | Visual Symptom | TexelAtlas Upgrade |
|---|---|---|
| Single DirectionalLight shadow frustum stretched across a large (>20m) scene | Blurry, blocky shadows up close and objects looking detached from the ground | `cascaded-shadow-maps`, `percentage-closer-soft-shadows` — Use Cascaded Shadow Maps (`CSM` in Three.js or built-in CSM in Godot/Unity/Unreal) for large worlds, or tightly fitted `PCSS` + `contact-shadows` for compact scenes, with tuned `normalBias`. |
| Uniform roughness/metalness PBR materials with default flat normal maps | Flat, plastic-looking surfaces where painted metal, glass, cloth, skin, wood, and stone read identically | `clearcoat-layer`, `parallax-occlusion-mapping`, `toksvig-mipmapping` — Separate materials physically (`MeshPhysicalMaterial` / OpenPBR `clearcoat`, `sheen`, `anisotropy`, `iridescence`, or subsurface scattering), author varied roughness/AO maps, use POM/detail normals on close-up surfaces, and add `toksvig-mipmapping` to curb specular shimmer. |
| Skipping ambient occlusion or applying heavy monochrome SSAO | Props, characters, and geometry look pasted onto floors, or bright surfaces turn muddy gray in crevices | `n8ao`, `ground-truth-ambient-occlusion`, `multi-bounce-ambient-occlusion` — Enable `N8AO` or `GTAO` (half-res depth-aware denoise) and pair with multi-bounce albedo tinting so bright crevices stay clean and natural. |
| Repeating UV textures on large floors, walls, roads, or terrain | Obvious grid/checkerboard repetition across wide surfaces | `hex-tiling`, `triplanar-mapping`, `weathering-simulation` — Break periodicity with `hex-tiling` or `triplanar-mapping` (for steep slopes/cliffs) and layer low-frequency world-space roughness/color variation. |
| Hard alphaTest cutouts or unsorted alpha-blended cards (foliage, hair, fences, decals) | Sparkling distant edges, popping silhouettes, or broken transparency sorting | `hashed-alpha-testing`, `octahedral-impostors` — Use `alphaToCoverage` + hashed alpha testing (`hashed-alpha-testing`) with MSAA for order-independent anti-aliased cutouts. |
| Flat ambient fill + uncalibrated exposure / linear sRGB clipping (no IBL) | Washed-out shadows, flat ungrounded reflections, and neon/sun highlights clipping to harsh yellow or white | `split-sum-ibl`, `agx-tonemapping`, `exponential-height-fog` — Bake your environment (HDRI, studio rig, or procedural sky) into a prefiltered IBL cubemap (`PMREM`), add subtle atmospheric depth where appropriate, and finish with `AgX` or `Khronos PBR Neutral` + selective HDR bloom (`threshold >= 0.9`). |
| Hand-rolled `sin(x)*cos(y)` surface ripples or mirror blends without Fresnel/oblique clip | Artificial repeating stripes on liquids or broken reflection clipping on glossy/mirror planes | `planar-reflections-oblique-clipping`, `screen-space-reflections`, `fresnel-schlick-approximation` — Use physical Schlick Fresnel (`F0`), Lengyel oblique near-plane clipping for flat mirrors/water, `screen-space-reflections` for wet streets/glossy floors, and multi-directional or FFT/Gerstner waves for open water. |

## 4. Babylon.js Pitfalls & Pass Ordering

- Enable `scene.imageProcessingConfiguration.toneMappingEnabled = true` and avoid double-tonemapping in custom `NodeMaterial` graphs.
- Use `CascadedShadowGenerator.stabilizeCascades = true` to eliminate shadow edge swimming during camera movement.

## 5. Top Verified Babylon.js Built-In & Official Switches (100 total; fetch `https://texelatlas.vercel.app/t/<slug>.md`)

### Sky, IBL & GI
- **Reflection probes with parallax-corrected cubemaps** (`reflection-probes-parallax-corrected-cubemaps`) [builtin · 0.0607ms T4] — `new ReflectionProbe(name, size, scene); cubeTexture.boundingBoxSize`
- **Split-Sum Image-Based Lighting** (`split-sum-ibl`) [builtin · 0.0613ms T4] — `scene.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(url, scene) (PBR uses `
- **Environment mapping, cubemaps and skyboxes** (`environment-mapping-cubemaps`) [builtin · 0.1615ms T4] — `new BABYLON.CubeTexture(url, scene); scene.environmentTexture`
- **Linearly Transformed Cosines for Area Lights** (`ltc-area-lights`) [builtin · 0.2775ms T4] — `new BABYLON.RectAreaLight('l', position, width, height, scene)`
- **Planar reflections with oblique near-plane clipping** (`planar-reflections-oblique-clipping`) [builtin · 0.6098ms T4] — `new MirrorTexture(name, size, scene); mirrorTexture.mirrorPlane = plane`
- **Scalable Production Sky and Atmosphere (Hillaire)** (`hillaire-sky-atmosphere`) [official · 3.393ms T4] — `import { Atmosphere } from '@babylonjs/addons/atmosphere'`

### Shadows & Ambient Occlusion
- **Percentage-Closer Filtering** (`percentage-closer-filtering`) [builtin · 0.6316ms T4] — `shadowGenerator.usePercentageCloserFiltering = true (or usePoissonSampling)`
- **Percentage-Closer Soft Shadows** (`percentage-closer-soft-shadows`) [builtin · 1.6496ms T4] — `shadowGenerator.useContactHardeningShadow = true (PCSS)`
- **Cascaded Shadow Maps** (`cascaded-shadow-maps`) [builtin · 2.1515ms T4] — `new BABYLON.CascadedShadowGenerator(1024, directionalLight); csm.numCascades = 4`
- **Shadow map depth bias (constant, slope-scale, normal offset)** (`shadow-map-bias-slope-scale-normal-offset`) [builtin · 0.0325ms T4] — `shadowGenerator.bias, shadowGenerator.normalBias`
- **Shadow Mapping** (`shadow-mapping`) [builtin · 0.0984ms T4] — `new BABYLON.ShadowGenerator(1024, light); shadowGenerator.getShadowMap().renderList.push(mesh)`
- **Screen-Space Ambient Occlusion** (`ssao`) [builtin · 0.861ms T4] — `new BABYLON.SSAO2RenderingPipeline('ssao', scene, ratio, cameras)`

### Materials, BRDF & Micro-Detail
- **Schlick Fresnel approximation** (`fresnel-schlick-approximation`) [builtin · 0.0514ms T4] — `Used internally by PBRMaterial (fresnelSchlickGGX)`
- **Anisotropic GGX** (`anisotropic-ggx`) [builtin · 0.0614ms T4] — `pbrMaterial.anisotropy.isEnabled = true (PBRAnisotropicConfiguration)`
- **OpenPBR Surface** (`openpbr-surface`) [builtin · 0.0625ms T4] — `new BABYLON.OpenPBRMaterial('m', scene)`
- **Charlie sheen (Estevez-Kulla)** (`charlie-sheen`) [builtin · 0.0669ms T4] — `pbrMaterial.sheen.isEnabled = true (PBRSheenConfiguration)`
- **Disney principled BRDF** (`disney-principled-brdf`) [builtin · 0.0703ms T4] — `new BABYLON.OpenPBRMaterial(...) or PBRMaterial (Burley diffuse + GGX + clearcoat + sheen + ani`
- **Clearcoat layer** (`clearcoat-layer`) [builtin · 0.0727ms T4] — `pbrMaterial.clearCoat.isEnabled = true (PBRClearCoatConfiguration)`

### Water, Fog & Volumes
- **Screen-space Volumetric Light Scattering (God Rays)** (`volumetric-light-scattering-god-rays`) [builtin · 1.4269ms T4] — `new BABYLON.VolumetricLightScatteringPostProcess('vls', 1.0, camera, mesh, 100, ..., engine)`
- **Ray-marched Rayleigh/Mie Single Scattering** (`rayleigh-mie-single-scattering`) [official · 1.3947ms T4] — `@babylonjs/materials SkyMaterial (rayleigh, mieCoefficient, mieDirectionalG)`
- **Screen-space fluid rendering (curvature flow)** (`screen-space-fluid-rendering`) [builtin · 6.747ms T4] — `new FluidRenderer(scene); fluidRenderer.addParticleSystem(...)`
- **Henyey-Greenstein Phase Function** (`henyey-greenstein-phase-function`) [official · 0.1049ms T4] — `@babylonjs/addons atmosphereFunctions.fx miePhase (Henyey-Greenstein Mie scattering phase)`
- **Precomputed Atmospheric Scattering** (`precomputed-atmospheric-scattering`) [official · 0.6278ms T4] — `@babylonjs/addons Atmosphere (LUT-based physically based atmospheric scattering)`

### Post-Processing, Tonemapping & AA
- **Khronos PBR Neutral tone mapper** (`khronos-pbr-neutral`) [builtin · 0.0423ms T4] — `imageProcessingConfiguration.toneMappingType = ImageProcessingConfiguration.TONEMAPPING_KHR_PBR`
- **Temporal Anti-Aliasing** (`temporal-anti-aliasing`) [builtin · 0.1956ms T4] — `new BABYLON.TAARenderingPipeline('taa', scene, cameras)`
- **Screen-space reflections** (`screen-space-reflections`) [builtin · 0.5894ms T4] — `new BABYLON.SSRRenderingPipeline('ssr', scene, cameras)`
- **Dual-filter and progressive-downsample bloom** (`dual-filter-bloom`) [builtin · 3.5692ms T4] — `DefaultRenderingPipeline.bloomEnabled (BloomEffect)`
- **Linear-space rendering and gamma correction** (`linear-color-workflow`) [builtin · 0.0291ms T4] — `PBRMaterial shades in linear space with automatic sRGB-to-linear texture conversion`
- **Reinhard photographic tone reproduction** (`reinhard-tonemapping`) [builtin · 0.0383ms T4] — `new BABYLON.TonemapPostProcess('t', BABYLON.TonemappingOperator.Reinhard, exposure, camera)`

### Stylized, Foliage & Performance
- **Inverted-hull outlines** (`inverted-hull-outline`) [builtin · 0.0752ms T4] — `mesh.renderOutline = true; mesh.outlineWidth / outlineColor`
- **Reverse-Z and floating-point depth buffers** (`reverse-z-depth-buffer`) [builtin · 0.0943ms T4] — `engine.useReverseDepthBuffer = true`
- **Toon / cel shading with lighting ramps** (`toon-shading`) [official · 0.2921ms T4] — `new BABYLON.CellMaterial('m', scene) from @babylonjs/materials`
- **Posterization** (`posterization`) [builtin · 0.052ms T4] — `PosterizeBlock in Node Material Editor`
- **Basis Universal / KTX2 supercompression** (`basis-universal-ktx2`) [builtin · 0.1162ms T4] — `KhronosTextureContainer2 / KHR_texture_basisu loader (KTX2 Basis transcoding)`
- **GPU hardware occlusion queries** (`hardware-occlusion-queries`) [builtin · 0.1309ms T4] — `mesh.occlusionType = AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC; mesh.occlusionQueryAlgorithmType`

## 6. Quantitative Look-Dev Gates & Mandatory Phase-2 Polish Pass

- **Roughness Contrast Gate:** Span `<= 0.06` (wet puddles, clearcoat, glass, polished metal) to `>= 0.88` (matte asphalt, plaster, fabric, dry bark) using paired PBR maps — never let a scene collapse into uniform `0.4–0.6` plastic.
- **Lighting & HDR Discipline:** Establish a clear warm-vs-cool focal hierarchy backed by prefiltered IBL + area lights; drive emissives at HDR `1.5–4.5` with bloom `threshold >= 0.92` so glow kisses sources without milky wash.
- **Silhouette & Framing Rule:** Never leave bare box primitives or unframed glowing rectangles; frame walls, eaves, signs, and openings with trim, bevels, conduits/cables, and grounded street/floor props, and verify curved UV orientation (`LatheGeometry` labels).
- **Mandatory Phase-2 Polish Pass:** After building v1, capture screenshots across Hero, Close-Up, and Grazing views, score all 8 checkpoints at https://texelatlas.vercel.app/guides/scene-audit.md (matching defects against https://texelatlas.vercel.app/api/v1/symptoms.json or MCP `texel_diagnose`), and execute a dedicated upgrade pass fixing your **3 weakest visual areas** before finishing.
