Docs / Ray tracing

Glossary: RayHit

The members of RayHit, in alphabetical order.

Color legend plain property method

What a closest hit found: how far along the ray, which instance, which triangle, and where in it.

A struct of public fields, filled by Tlas.Intersect. The CPU queries page shows it in context, with code.

Names are colored by what they are: a property or a method; values and fields keep the plain color.

Properties

HasHit →

bool · Read-only. Something was hit: InstanceIndex isn’t −1.

Fields

Distance →

float · The ray parameter of the hit: the point is ray.Position + ray.Direction * Distance. For a direction of length 1 it is the distance in world units, and for one of length 2 half of it. The maximum distance asked for when nothing was hit.

InstanceId →

ulong · The id the instance hit was declared with, in Tlas.Add. Means nothing unless HasHit.

InstanceIndex →

int · The instance’s place in Tlas.Instances, which has its BLAS and its matrix; −1 for no hit. Good until the next BeginUpdate.

TriangleIndex →

int · The triangle hit, in the instance’s mesh, as GetTriangle numbers it; −1 for no hit.

U →

float · The hit’s barycentric weight of the triangle’s second corner, v1. Not a texture coordinate: with V, where in the triangle the ray landed, v0 * (1 - U - V) + v1 * U + v2 * V. The same weights blend anything else the corners carry, see attributes at a hit.

V →

float · The weight of the triangle’s third corner, v2. See U.

Methods

None() →

None(float maxDistance = float.MaxValue) · Static. Returns RayHit: a hit of nothing, at the distance given, its two indexes −1. What Intersect hands back when it finds nothing.

Parameter Type Description
maxDistance float The Distance it carries. Default: float.MaxValue.