code wiki / (root) / nx_shadow_integration.nx

nx_shadow_integration.nx

buildroot/runtime/nx_shadow_integration.nx

4526 B112 linesdepth 5pulls 6 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_shadow_integration.nx -- Best Compositing (shadow half). Real subjects in real scenes cast shadows onto environment objects. AI renders often drop the shadow → subject reads "pasted on". Detector measures: in the region around the subject's silhouette edge, is there a darkening band ON the environment side that matches what a subject-cast shadow would look like? Math: 1. Define a band along the subject's outer edge on the BG side. 2. Compare mean luminance INSIDE that band vs background baseline luminance further away. 3. Real shadow: band is 10-25% darker than baseline. 4. No shadow: band is similar to baseline. Inputs: gray image + subject_mask + env_baseline_bbox. Output flat-array: result[0] band_mean_Y result[1] baseline_mean_Y result[2] shadow_depth_pct (baseline - band) * 100 / baseline result[3] verdict

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_image.nx nx_shadow_integration.nx nx_oscar_batch_test.nx

imports: nx_syscalls.nxnx_image.nx

imported by: nx_oscar_batch_test.nx

structs

none

consts

33const NX_SHADOW_RES_BAND_Y: i64 = 0
34const NX_SHADOW_RES_BASELINE_Y: i64 = 1
35const NX_SHADOW_RES_DEPTH_PCT: i64 = 2
36const NX_SHADOW_RES_VERDICT: i64 = 3
37const NX_SHADOW_RES_FIELDS: i64 = 4
39const NX_SHADOW_V_MISSING: i64 = 0 // < 5% depth
40const NX_SHADOW_V_WEAK: i64 = 1 // 5-10%
41const NX_SHADOW_V_NATURAL: i64 = 2 // 10-25%
42const NX_SHADOW_V_OVERDARK: i64 = 3 // > 25%

functions

47func nx_shadow_mean_y_masked(rgb: *Image, mask: *Image,
called by 1: nx_shadow_integration calls 1: nx_image_get
84func nx_shadow_integration(rgb: *Image, subject_mask: *Image,
called by 1: main calls 1: nx_shadow_mean_y_masked