RayHit

template<IsSpectral TSpectral>
struct Interaction

Surface interaction information for rendering.

Stores geometric and shading information at a surface intersection point, including position, normals, tangent frame, texture coordinates, interpolated vertex albedo, and outgoing direction. Used in BSDF evaluation, texture lookup, and light transport calculations.

Template Parameters:

TSpectral – The spectral type (e.g., RGB, Visible8)

Public Members

Vec3<float> position = {}

Intersection point in world space.

Vec3<float> normal_g = {}

Geometric normal at the intersection.

Vec3<float> normal_s = {}

Shading normal at the intersection.

Vec3<float> tangent = {}

Tangent vector (for normal mapping / anisotropic BSDFs).

Vec3<float> bitangent = {}

Bitangent vector (cross(normal_s, tangent)).

Vec2<float> uv = {}

Texture coordinates (u, v).

Vec3<float> wo = {}

Outgoing direction (towards camera), world space.

TSpectral vertex_albedo = {1}

Interpolated vertex color (default: white / unity).

float p_err = {0.0f}

Conservative bound on the numerical error of position (meters). Set by SceneView::resolve_hit from the local- and world-frame coordinate magnitudes; consumed by offset_spawn_point().

inline Vec3<float> huira::offset_spawn_point(const Vec3<float> &p, const Vec3<float> &n, float p_err) noexcept

Offsets a spawn point along the (already side-flipped) geometric normal by the propagated position-error bound.

Used only for rays whose direction differs from the incident ray (BSDF bounces, shadow rays); a displacement along the geometric normal guarantees clearance from the surface’s tangent plane for every spawn direction, including grazing ones — a property a tnear interval cannot provide, since the parametric distance to a false re-hit grows as 1/sin(theta) at grazing incidence. Rays that keep their direction (alpha pass-through, transmittance marching) must NOT use this: they continue the same ray via Ray::tnear() and advance_ray_t(), which is exact.

Parameters:
  • p – Resolved intersection position (world space)

  • n – Geometric normal, pre-flipped toward the spawn hemisphere

  • p_err – Position error bound from Interaction::p_err