BlueGit

timfa questward

Files

questward / .cursor / rules / shader-darkness.mdc

shader-darkness.mdc

shader-darkness.mdc 1.3 KiB Download Raw
1---
2description: All world/item shaders must respect night darkness unless unlit or bloom.
3alwaysApply: true
4---
5
6# Shaders respect darkness
7
8Lit 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
16Compose 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
26rgb = mix(rgb, potionColor, 1.0);
27gl_FragColor = vec4(rgb, a);
28
29# ✅ GOOD — tint then darkness
30rgb = mix(rgb, potionColor, fill);
31rgb = mix(rgb, vec3(0.0), u_darkness);
32gl_FragColor = vec4(rgb, a);
33```
34
35When adding a new fragment shader for the game world, default to respecting darkness; document any unlit exception in code comments.