| 1 | --- |
| 2 | description: All world/item shaders must respect night darkness unless unlit or bloom. |
| 3 | alwaysApply: true |
| 4 | --- |
| 5 | |
| 6 | # Shaders respect darkness |
| 7 | |
| 8 | Lit world and item shaders **must** apply the scene darkness value (e.g. `u_darkness` / ambient night darkening) unless explicitly exempt. |
| 9 | |
| 10 | ## Must darken |
| 11 | |
| 12 | - Entity sprites, equipment overlays, ground items |
| 13 | - Ground/block tiles (atlas or individual), water, wade foam, coastline foam |
| 14 | - Potion liquid recolor / tint passes drawn in the lit world |
| 15 | |
| 16 | Compose effects **before** darkness when possible: tint/foam/recolor first, then `mix(rgb, vec3(0.0), darkness)`. |
| 17 | |
| 18 | ## Exempt (unlit) |
| 19 | |
| 20 | - Bloom-layer sprites (`RENDER_LAYER_BLOOM` / bloom companions) |
| 21 | - Explicitly unlit utilities (chunk edges, editor overlays, UI chrome) |
| 22 | - Pure UI elements not drawn through the world lit pipeline (DOM inventory panels may tint without world darkness; world-dropped potions still must darken) |
| 23 | |
| 24 | ```text |
| 25 | # ❌ BAD — fancy tint ignores night |
| 26 | rgb = mix(rgb, potionColor, 1.0); |
| 27 | gl_FragColor = vec4(rgb, a); |
| 28 | |
| 29 | # ✅ GOOD — tint then darkness |
| 30 | rgb = mix(rgb, potionColor, fill); |
| 31 | rgb = mix(rgb, vec3(0.0), u_darkness); |
| 32 | gl_FragColor = vec4(rgb, a); |
| 33 | ``` |
| 34 | |
| 35 | When adding a new fragment shader for the game world, default to respecting darkness; document any unlit exception in code comments. |