Skip to main content

sdf_gradient

Function sdf_gradient 

Source
pub fn sdf_gradient(sdf: &dyn Fn([f64; 3]) -> f64, p: [f64; 3]) -> [f64; 3]
Expand description

Estimate the surface normal at p using central differences on sdf.

Returns a normalised [f64; 3] gradient vector. The step size eps is 1e-4 by default (hard-coded).