code wiki / (root) / nx_subsurface_warmth.nx

nx_subsurface_warmth.nx

buildroot/runtime/nx_subsurface_warmth.nx

5325 B155 linesdepth 5pulls 6 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_subsurface_warmth.nx -- detect subsurface scatter (SSS) by R/G ratio in shadows. Real skin transmits red wavelength deeper than green/blue. In shadow regions (low overall luminance), real skin shows ELEVATED red-to-green ratio relative to the lit side. Mannequin renders / SDXL plastic renders show flat R:G ratio across light and shadow. Math: 1. Pick skin-mask pixels with luminance below median (shadow side). 2. Compute mean R, mean G across those pixels. 3. Mean R / Mean G in Q10. SSS-positive when > 1100 (≈1.075). 4. Score Q10: how far above the SSS threshold. Output flat-array (result[]): result[0] = shadow_pixel_count result[1] = mean_R_q10 (mean R*4 to keep precision) result[2] = mean_G_q10 result[3] = R_to_G_q10 (ratio in Q10) result[4] = sss_score_q10 (0=no SSS, 1024=strong SSS) result[5] = verdict (0=MANNEQUIN, 1=SLIGHT, 2=NATURAL)

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_image.nx nx_subsurface_warmth.nx nx_mannequin_index.nx nx_mannequin_index_test.nx

imports: nx_syscalls.nxnx_image.nx

imported by: nx_mannequin_index.nxnx_mannequin_index_test.nx

structs

none

consts

31const NX_SSS_RES_COUNT: i64 = 0
32const NX_SSS_RES_MEAN_R: i64 = 1
33const NX_SSS_RES_MEAN_G: i64 = 2
34const NX_SSS_RES_RATIO: i64 = 3
35const NX_SSS_RES_SCORE: i64 = 4
36const NX_SSS_RES_VERDICT: i64 = 5
37const NX_SSS_RES_FIELDS: i64 = 6
39const NX_SSS_VERDICT_MANNEQUIN: i64 = 0 // ratio ≈ 1.0 (flat)
40const NX_SSS_VERDICT_SLIGHT: i64 = 1 // 1.05..1.075
41const NX_SSS_VERDICT_NATURAL: i64 = 2 // > 1.075
43const NX_SSS_THRESH_NATURAL_Q10: i64 = 1100 // 1.075 in Q10
44const NX_SSS_THRESH_SLIGHT_Q10: i64 = 1075 // 1.05 in Q10

functions

48func nx_sss_luminance_median(rgb: *Image, mask: *Image) -> i64
88func nx_subsurface_warmth(rgb: *Image, mask: *Image, result: *i64) -> i64