Constants
On this page
TSL Functions
const closestPointToTriangle: FunctionNodeWGSL function node that finds the closest point on a triangle to p and returns the barycoord.
const intersectRayTriangle: FunctionNodeWGSL function node that tests a ray against a single triangle and returns an
rayIntersectionResultStruct result. Useful when writing a custom intersectRangeFn
for BVHComputeData#getShapecastFn.
const ndcToCameraRay: FunctionNodeWGSL function node that builds a camera ray (origin + far-plane direction) from an NDC coordinate and an inverse model-view-projection matrix. Works for both perspective and orthographic projections. The origin sits on the near plane, the returned direction is normalized, and "maxDist" is the world-space distance to the far plane so traversal clips there.
TSL Structs
const rayStruct: StructTypeNodeWGSL struct node representing a ray with an origin, direction, and maximum trace distance. Used as the input to BVH traversal and intersection functions. Traversal ignores hits at or beyond "maxDist", and a value of 0 (the zero-initialized default) means unbounded.
const rayIntersectionResultStruct: StructTypeNodeWGSL struct node describing a ray–triangle intersection result, including barycentric coordinates, world-space normal, hit distance, face side, triangle indices, and the object index within the TLAS.
const pointQueryResultStruct: StructTypeNodeWGSL struct node describing a closest-point query result, including the world-space closest point, squared distance, barycentric coordinates, face normal, side, triangle indices, and the object index within the TLAS.
Barycoord convention matches rayIntersectionResultStruct: (bary_a, bary_b, bary_c)
where each component is the weight for the corresponding vertex in faceIndices.xyz.