Skip to the content
Receivers

Receivers

A KausticsReceiver is a rectangle that caustics land on: a table top, a wall, a pool floor. Each receiver gets its own irradiance texture covering exactly its rectangle, so you can use it in your own shaders. A renderer draws at most eight receivers, and KausticsRenderer.maxReceivers says so.

Swift
.floor(size: [2, 2])
.wall(center: [0, 1, -1], facing: [0, 0, 1], size: [2, 2])

#Making one

Made with What it is
.floor(center:size:resolution:) A horizontal rectangle facing up, its width along x.
.wall(center:facing:size:resolution:) A vertical rectangle facing facing, its height up the world’s y.
KausticsReceiver(center:normal:uAxis:size:resolution:) Any rectangle. uAxis is made square to the normal if it is not.

#Properties

Property Meaning
center The rectangle’s middle, in world space.
size Its width, along uAxis, and its height, along vAxis, in world units.
normal The unit normal, which is the side light lands on. Light only lands on that side.
uAxis The unit axis along its width, and texture x.
vAxis The unit axis along its height, and texture y. It is always cross(normal, uAxis).
resolution Texels along its longer side, rounded to a multiple of 32. nil uses the renderer’s resolution, 1024 by default.

#Texture coordinates

Texture x runs along uAxis and texture y along vAxis. Two methods move between the world and the texture:

Swift
let uv = receiver.uv(of: worldPoint)    // 0 to 1 across the rectangle
let point = receiver.point(at: uv)      // the world point at that uv

In a shader, you sample the irradiance texture at that same UV. See Your own Metal pipeline.

#Where receivers meet

Each receiver takes every triangle against its own plane. That is seamless where receivers meet at an edge and face into the same space, like a floor and its walls, or the inside of a pool.

Receivers that hide one another from the light, such as a box standing on a floor, both get the light.