Skip to main content

buffered_gradient_normals

Function buffered_gradient_normals 

Source
pub fn buffered_gradient_normals(
    vertices: &QuantizedVertices,
    bounds: &TileBounds,
    buffered: &BufferedElevations,
) -> Vec<[f32; 3]>
Expand description

Compute vertex normals from the DEM gradient on a buffer-extended grid.

For every vertex the local east/north slope is read from the same DEM samples that the neighbour tile would read — so the same physical edge sees the same gradient from either side, eliminating the tile-boundary shading seam that face_normals exhibits.

§Pipeline

  1. Map the vertex’s (u, v) into the buffered grid’s index space.
  2. Sample the buffered grid bilinearly at a half-cell stencil to get the central differences ∂h/∂x and ∂h/∂y (metres per metre).
  3. Build a local ENU normal (-∂h/∂x, -∂h/∂y, 1) and rotate it into ECEF, which is what Cesium expects for oct-encoded normals.

The returned vectors are unit-length ECEF normals.