How the Raycast Node Works in Blender
The Raycast node in Blender Geometry Nodes projects invisible rays from a source geometry in a specified direction to detect intersections with a target geometry. By analyzing where these rays hit, the node retrieves vital spatial data—such as hit locations, surface normals, and interpolated attributes—making it essential for tasks like projecting objects onto terrain, conforming geometry to uneven surfaces, and controlling procedural scattering based on line-of-sight.
Core Functionality
At its fundamental level, the Raycast node acts as a geometric collision detector. For every point, vertex, or face on the source geometry, the node shoots a ray along a defined vector. If that ray collides with the target mesh, the node records the collision data and outputs various parameters regarding the hit point.
Primary Inputs
- Target Geometry: The external mesh that the rays are being cast toward to detect collisions.
- Source Position: The starting point from which each ray is cast (defaults to the position of the evaluated element).
- Ray Direction: A vector defining the orientation in which the ray travels (commonly negative Z for downward projections onto terrain).
- Ray Length: The maximum distance a ray can travel before stopping if it does not encounter the target geometry.
- Attribute: Any data (such as vertex colors, UV maps, or custom values) from the target geometry that you want to sample at the exact point of intersection.
Primary Outputs
- Is Hit: A boolean output indicating whether the ray successfully collided with the target surface within the specified ray length.
- Hit Position: The exact 3D coordinates in world/local space where the ray intersected the target geometry.
- Hit Normal: The direction perpendicular to the target surface at the exact point of collision, commonly used to align the rotation of scattered instances to the slope of a surface.
- Hit Distance: The float distance from the ray’s starting position to the intersection point.
- Interpolated Attribute: The sampled attribute value from the target geometry at the point of impact.
Common Practical Applications
- Terrain Snapping: Placing objects—such as trees,
rocks, or buildings—accurately onto uneven terrain by casting rays
downward from above and moving instances directly to the
Hit Position. - Surface Normal Alignment: Combining the
Hit Normaloutput with an Align Euler to Vector node to rotate placed assets so they match the slope of hills, cliffs, or curved meshes. - Shrinkwrapping and Conforming: Deforming clothing, straps, or procedural curves to wrap around complex character meshes without manual retopology.
- Visibility and Occlusion Masking: Filtering out
instances that are hidden beneath overhangs, ceilings, or inside caves
using the
Is HitorHit Distancethresholds.