Skip to content

Frustum Ray Builder

ExodusCoder9 edited this page Jun 20, 2026 · 1 revision

Frustum Ray Builder

FrustumRayBuilder computes four corner rays from an inverse projection-view matrix and bilinearly interpolates ray directions.

FrustumRayBuilder builder = new FrustumRayBuilder();

// Set from inverse projection-view matrix
builder.set(inverseProjView);

// Interpolate ray direction at normalized coordinates [0,1]×[0,1]
Vector3d ray = builder.getRay(0.5f, 0.5f);   // center of screen
Vector3d ray = builder.getRay(x, y, dest);    // no-alloc version

// Normalize all four corner directions
builder.normalize();

Clone this wiki locally