parallaxPlane
A flat layer at a fixed depth inside the shape, like scenery seen through a window.
parallaxPlane(
ray: InteriorRay,
opts: {depth: number; pan?: {x: Expr; y: Expr}; panRate?: number; hint?: string},
): {x: Expr; y: Expr; z: Expr}
Import volume from shaders/std and use volume.parallaxPlane.
depth is a fraction of the ray's length: 0 at the entry, 1 at the far side, beyond 1 for a backdrop behind the shape. Give it a pan (the rotationSensor of the frame) and the layer slides as the shape rotates, panRate times as far. Deeper layers with higher rates give the parallax of real depth. Returns the position to sample content at, plus its depth z.
Parameters
| Name | Type | Notes |
|---|---|---|
ray | InteriorRay | |
opts | {depth: number; pan?: {x: Expr; y: Expr}; panRate?: number; hint?: string} |
Example
const far = parallaxPlane(ray, {depth: 1.1, pan: rotationSensor(frame), panRate: 1.3, hint: 'far'})
Tip. Two planes at different depths and rates are enough to sell a starfield.
See also
interiorRay— The line of sight through a shape: where it enters, how far it travels inside, and where it is at any depth.volumeMarch— Walk a ray through the medium front to back, adding up what glows and what dims.