参考 combineColors

combineColors

此 API 是实验性的

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

A shader hook block that modifies how color components are combined in the fragment shader. This hook can be used inside buildMaterialShader() and similar shader modify() calls to control the final color output of a material. Modifications happen between the .begin() and .end() methods of the hook.

combineColors has the following properties:

  • baseColor: a three-component vector representing the base color (red, green, blue).
  • diffuse: a single number representing the diffuse reflection.
  • ambientColor: a three-component vector representing the ambient color.
  • ambient: a single number representing the ambient reflection.
  • specularColor: a three-component vector representing the specular color.
  • specular: a single number representing the specular reflection.
  • emissive: a three-component vector representing the emissive color.
  • opacity: a single number representing the opacity.

Call .set() on the hook with a vector with four components (red, green, blue, alpha) for the final color.

This hook is available in:

示例

Notice any errors or typos? Please let us know. Please feel free to edit src/strands/p5.strands.js and open a pull request!

相关参考