Documentation / @ripl/3d / shadeSurface
Function: shadeSurface() ​
shadeSurface(
normal,position,viewDirection,surface,lights,out):SurfaceIllumination
Defined in: 3d/src/core/shading.ts:163
Resolves the light arriving at a surface point, writing into out rather than allocating.
This is the single source of truth for the lighting model: the CPU painter calls it per face and the WGSL fragment shader mirrors it term for term, so the two backends agree by construction rather than by review. Falloff and cone attenuation match three.js's conventions so a rig tuned against those conventions reads the same here.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
normal | Vector3 | The unit-length world-space surface normal. |
position | Vector3 | The world-space point being shaded. |
viewDirection | Vector3 | The unit-length direction from the surface towards the camera. |
surface | ResolvedSurface | The surface's specular and emissive terms. |
lights | ResolvedLight[] | The lights illuminating the scene. |
out | SurfaceIllumination | The illumination to write into, reused across calls. |
Returns ​
out, for convenience.