viewRay

The direction the viewer looks along at this pixel, for reflections that sweep across a face.

viewRay(params: GpuFragmentParams, field: SurfaceField, fov: number = 0.6): Expr

Import materials from shaders/std and use materials.viewRay.

A unit 3D vector pointing into the canvas. fov sets how much it leans off-axis toward the edges (0.6 is the usual value, 0.55 flatter).

Parameters

NameTypeNotes
paramsGpuFragmentParams
fieldSurfaceField
fovnumberOptional. Default 0.6.

Example

const view = viewRay(params, field)

See also

  • grazingOf — How edge-on the surface is to the viewer: 0 face-on, 1 grazing.
  • reflect — The direction i bounced off a surface with unit normal n.
  • studioSoftboxes — The brightness of a five-light studio seen in a reflected direction.

Used by

BrushedMetal, CarbonFiber, Chrome, LiquidMetal, Nebula, Obsidian