Skip to content

Soften diffuse light on a normal-mapped surface like Cycles' bump shadowing (codepawl/crucible#1842) - #58

Merged
anxuanng merged 1 commit into
mainfrom
1842-bump-shadowing
Nov 16, 2026
Merged

anxuanng merged 1 commit into
mainfrom
1842-bump-shadowing

Conversation

@anxuanng

Copy link
Copy Markdown
Contributor

Part of codepawl/crucible#1842 (and #1111).

Cause

Cycles scales the value of a diffuse lobe whose normal came from a bump or normal map by bsdf_G<GGX>(min(0.125 * tan2(deviation), 1), |cos(smooth normal, light)|) (bump_shadowing_term, on by default as "bump map correction"). Cook had only the hard half of that term, so a tilted normal lit the part of a curved surface that faces away from the light.

It was not tangent generation: error is independent of tessellation (16, 48 and 96 segments all gave about 1.01), not concentrated at the poles, and Cycles' own tilted normal (rendered as an emission colour) is within 0.5 degrees of the analytic one. With one light and no ambient, Cook matched an analytic Lambert model while Cycles kept 21 percent of it at cos(smooth normal, light) 0 to 0.05, 53 percent at 0.05 to 0.1 and 77 percent at 0.1 to 0.2.

Change

closure_bump_shadowing_weight returns the factor and closure_eval scales the lobe value by it (pdf untouched, as in Cycles), for diffuse and diffuse transmission lobes, only when the scene has a normal map.

Evidence

Cycles 5.3, 480x270, 256 spp, flattened scenes, mean ratio / relMSE / tiles over 5 percent:

scene before after
UV sphere, bumpy map 1.0122 / 0.0011 / 5 0.9998 / 1.8e-5 / 0
UV sphere, tilt along red 1.018 / 0.0015 / 6 0.9992 / 2.1e-5 / 0
UV sphere, tilt along green not run 1.0000 / 3e-6 / 0
UV sphere, 16 / 96 segments 1.009 / 1.013 0.9977 / 0.9999
UV sphere, no map 0.9999 / 4e-6 / 0 unchanged
instanced plane, 1.8 x 1.8 x 1 1.0015 / 4e-6 / 0 0.9999 / 2e-6 / 0

Still open: a flattened non-uniformly scaled plane (matrix baked into the vertices) keeps the full tilt, 0.956 before and 0.951 after.

node tools/run-cargo-tests.mjs: 140 and 23 passed. release-guard: clean.

…dowing (codepawl/crucible#1842)

Cycles multiplies the value of a diffuse lobe whose normal was perturbed by a
bump or normal map with bsdf_G<GGX>(min(0.125 * tan2(deviation), 1), |cos(smooth
normal, light)|), the default "bump map correction". Cook only had the hard half
of that term (zero light when the light, the smooth normal and the lobe normal
disagree about the side), so a tilted normal lit the part of a curved surface
that faces away from the light, 20 to 45 percent more than Cycles in the band
within 12 degrees of the terminator.

closure_bump_shadowing_weight now returns the factor and closure_eval scales the
lobe value by it (the pdf is left alone, as in Cycles). It applies to the diffuse
and diffuse transmission lobes, and only when the scene has a normal map.

Measured against Cycles 5.3 at 480x270, 256 spp, flattened scenes, UV sphere with
the bumpy map: mean ratio 1.0122, relMSE 0.0011, 5 of 64 tiles over 5 percent
(worst 1.121) became 0.9998, relMSE 1.8e-5, 0 tiles over (worst 0.995). Constant
tilt along the map's red axis: 1.018, 0.0015, 6 tiles over became 0.9992, 2.1e-5,
0 tiles over. A sphere without a map and the instanced plane are unchanged.
@anxuanng
anxuanng merged commit 1457f87 into main Nov 16, 2026
5 checks passed
@anxuanng
anxuanng deleted the 1842-bump-shadowing branch November 16, 2026 21:29
anxuanng added a commit to codepawl/crucible that referenced this pull request Nov 16, 2026
Cook 158384e4 (codepawl/cook#58, unmerged) scales a normal-mapped diffuse lobe by
Cycles' bump shadowing term. Part of #1111.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant