Geometry & 3D node

Raycast

Fires a ray at a mesh and reports where it lands: Hit, the Position struck, the surface Normal there, the Distance travelled and which Triangle was hit. Cable a Geometry output plus an Origin and a Direction — the direction need not be normalized. Max Distance 0 means unbounded. The answer arrives the same frame, so it drives picking, feelers and alignment directly.

Inputs

PortTypeDefault
GeometryThe mesh to test against — cable any Geometry output. The acceleration structure is built once and refitted when the shape changes, so casting against a moving mesh costs no more than a static one.structure—
OriginWhere the ray starts, in Grafit units. A point value: cable Make Point, Mouse, a Points output, or split floats.structure—
DirectionWhich way the ray travels. It does not need to be normalized — only its proportions matter. A zero direction reports no hit rather than guessing.structure—
Max DistanceHow far the ray reaches, in Grafit units. 0 means unbounded. Bounding it is cheaper and is usually what you want for a probe or a feeler.float0

Outputs

PortType
Hitbool
Positionstructure
Normalstructure
Distancefloat
Triangleint

How It Works

Raycast fires a ray at a mesh on the GPU and reports where it lands: Hit, the Position struck, the surface Normal there, the Distance travelled and which Triangle was hit.

Cable a Geometry output plus an Origin and a Direction — the direction need not be normalized. Max Distance at 0 means unbounded.

The answer arrives the same frame, which is what makes it usable for picking, feelers and alignment rather than only for offline queries.

Use Cases

  • Pick with the mouse — Mouse position as the ray origin, straight into the scene.
  • Place something on a surface — Cast downward and put an object at the Position, oriented by the Normal.
  • Feelers — Several rays around a moving object to detect what is near it.
  • Align to a surface — The returned Normal into Direction to Rotation.
  • Measure — Distance is how far the surface is along that ray.

Tips

  • The ray tests the geometry, so a Mesh node's scene placement does not move it — use Geometry Transform when the position must be reachable by a ray.
  • Combine meshes first when you want one cast against a whole assembly.
  • Check Hit before using Position: on a miss the other outputs are not meaningful.
  • Direction need not be normalized, but Distance is measured in the direction's own units if it is not — normalize when the number matters.
  • A decimated proxy works for rough feelers and is much cheaper on a dense mesh.

Open Raycast in the interactive catalog →

Raycast is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Geometry & 3D nodes