nx_lighting_quality.nx
buildroot/runtime/nx_lighting_quality.nx
about
nx_lighting_quality.nx -- lighting composition grader.
Per honest audit 2026-05-16: lighting quality was unmeasured. This
primitive grades a scene's lighting setup on 5 axes adapted from
cinematography conventions (three-point lighting + time-of-day
appropriateness).
AXES (Q14 [0, Q]; higher = better):
0. KEY_FILL_RATIO: key/fill light ratio. Target [2x, 4x] (the
classic "1.5-stop key" cinematography rule); outside drops linearly.
1. RIM_PRESENCE: rim_intensity / key_intensity; target [0.3, 0.8].
Rim light separates subject from background.
2. SHADOW_DENSITY: 1 - (min_visible / max_visible) brightness range.
Target [0.5, 0.85] (high contrast but not crushed blacks).
3. TIME_OF_DAY_APPROPRIATE: sun_zenith_q14 within reasonable bounds
for the lighting setup. Penalty for "noon sun with deep shadows"
contradictions.
4. COLOR_TEMPERATURE: warm/cool key vs fill complement (Q14
representation of K_key / K_fill ratio; target [0.9, 1.6] for
natural daylight or [0.6, 1.0] for sunset).
EMITS LAYER_VERDICT (kind = NX_LAYER_KIND_COLOR -- closest existing
kind; lighting/color belong together).
genealogy_id: lowell_2000_cinematography + nathan_1999_film_lighting +
three_point_lighting_canon
lineage_id: nx_lighting_quality_5axis_v1
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_layer_verdict.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 39 | const NX_MAGIC_5500: i64 = 5500 |
| 40 | const NX_MAGIC_5000: i64 = 5000 |
| 42 | const NX_LQ_Q: nx_int = 16384 |
| 44 | const NX_LQ_AXIS_KEY_FILL: nx_int = 0 |
| 45 | const NX_LQ_AXIS_RIM_PRESENCE: nx_int = 1 |
| 46 | const NX_LQ_AXIS_SHADOW_DENSITY: nx_int = 2 |
| 47 | const NX_LQ_AXIS_TIME_OF_DAY: nx_int = 3 |
| 48 | const NX_LQ_AXIS_COLOR_TEMP: nx_int = 4 |
| 49 | const NX_LQ_AXIS_COUNT: nx_int = 5 |
| 78 | const NX_LIGHTING_REC_STRIDE: nx_int = 8 |
| 79 | const NX_LIGHTING_OFF_KEY: nx_int = 0 |
| 80 | const NX_LIGHTING_OFF_FILL: nx_int = 1 |
| 81 | const NX_LIGHTING_OFF_RIM: nx_int = 2 |
| 82 | const NX_LIGHTING_OFF_AMBIENT: nx_int = 3 |
| 83 | const NX_LIGHTING_OFF_SUN_ZENITH: nx_int = 4 |
| 84 | const NX_LIGHTING_OFF_KEY_TEMP: nx_int = 5 |
| 85 | const NX_LIGHTING_OFF_FILL_TEMP: nx_int = 6 |
functions
| 51 | func _lq_band_score(val: nx_int, lo_q: nx_int, hi_q: nx_int) -> nx_int |
| 88 | func _lq_key_fill_q14(rec: *i64) -> nx_int |
| 97 | func _lq_rim_q14(rec: *i64) -> nx_int |
| 106 | func _lq_shadow_density_q14(rec: *i64) -> nx_int |
| 120 | func _lq_time_of_day_q14(rec: *i64) -> nx_int called by 1: nx_lighting_quality_grade |
| 137 | func _lq_color_temp_q14(rec: *i64) -> nx_int |
| 152 | func nx_lighting_quality_grade(rec: *i64, out_verdict: *i64) |
| 169 | func main() -> i64 |