参考 transformNormal()

transformNormal()

此 API 是实验性的

其行为可能在 p5.js 的未来版本中发生变化。

Applies a p5.strands transform to a surface direction.

A normal describes which way a surface faces, and lighting uses it to work out how bright each spot should be. Normals can't be moved the way positions are: a move must be ignored, and an uneven resize like scale(t, 2, 1, 1) would tilt them the wrong way if the transform were applied directly. transformNormal() handles both cases and returns a normalized result, so lighting stays correct.

Pass the same transform used with transformPoint() for the position, so the shape and its lighting stay in step.

Note: transformNormal() can only be used inside a p5.strands shader callback.

示例

语法

transformNormal(transform, normal)

参数

transform
a transform created with transform2D() or transform3D().
normal
the surface direction to transform.

返回值

the transformed surface direction, normalized.

相关参考