fullseye

bump_normals_fbm — 3D terrain op

使い方

Perturb a normal map with the gradient of a seeded multi-octave height field

(sub-facet relief the geometry cannot afford to displace) → unit normals (H, W, 3).

h(x) = Σ_k A_k n_k(x) is the same value-noise field :func:mesh_displace_spectrum would displace with (same seed ⇒ same lattice), so passing the octaves that the displacement’s band gate rejected makes the shading continue the same amplitude spectrum below the facet size (no fake sandpaper: an octave of amplitude A at wavelength λ tilts the normal by about 2πA/λ at most). The bumped normal is normalize(n − ∇_t h) (first-order shading normal of a height field over the surface; ∇_t = tangential gradient by central differences with step = min(λ)/64). positions are world coordinates (H, W, 3) (NaN = background, left untouched); if rotation (3×3, world → normal frame, e.g. pose[:3,:3]) is given the normals are taken in that frame.

local_edge (optional (H, W) map of the mesh’s local edge length under each pixel) makes the bump the exact complement of the displacement’s band gate: octave k is bumped with weight 1 − gate_k where gate_k is :func:displacement_band_weights’s rule with the same nyquist / fade — so an octave the geometry carried at a pixel is not added twice, and one it could not carry is fully supplied by the bump. Without it every octave is bumped at full amplitude. Deterministic; fail-closed.

入出力はともに (H, W, 3) 画像。positions に NaN を含む画素、または法線の長さが 1e-12 以下の画素は背景として 元の値のまま 残す(render3d.render_mesh の空画素)。 有効画素が一つも無ければ入力のコピーを返す。

高さ場を 3 軸の中心差分で微分するので評価は 1 画素あたり 6 回。法線の傾きは max |∇h| ≈ 2π A_k / λ_k 程度なので、振幅が波長に近づくほど法線が大きく寝る (既定は A/λ = 0.1 前後)。結果は phong_shade / brdf_hapke 等の 法線マップ入力へそのまま渡せる。

参考(サンプルデータ・文献)

実行できる例(この op を実際に呼ぶ検証済みサンプル)

型が繋がる次の op(normalmap を入力に取れる)

fuse_to_voxel · render_shaded · phong_shade · matcap_shade · brdf_lommel_seeliger · brdf_hapke · integrate_normals · render_lambertian

同カテゴリ(terrain)

mesh_displace_fbm · terrain_region_mask · mesh_scatter_boulders · mesh_edge_lengths · mesh_subdivide · displacement_band_weights · mesh_displace_spectrum


Provenance: render3d.py — 3D operator registry. この per-op ノートは tools/opdocs.py md が自動生成(手編集しない)。

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.