You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/webgl/ShaderGenerator.js
+38-17Lines changed: 38 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1689,7 +1689,18 @@ if (typeof p5 !== 'undefined') {
1689
1689
* @function combineColors
1690
1690
* @experimental
1691
1691
* @description
1692
-
* Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to control the final color output of a material. The callback receives color components (baseColor, diffuse, ambientColor, ambient, specularColor, specular, emissive, opacity) and returns a vec4 for the final color.
1692
+
* Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to control the final color output of a material. The callback receives an object with the following properties:
1693
+
*
1694
+
* - `baseColor`: a vector with three components representing the base color (red, green, blue)
1695
+
* - `diffuse`: a single number representing the diffuse reflection
1696
+
* - `ambientColor`: a vector with three components representing the ambient color
1697
+
* - `ambient`: a single number representing the ambient reflection
1698
+
* - `specularColor`: a vector with three components representing the specular color
1699
+
* - `specular`: a single number representing the specular reflection
1700
+
* - `emissive`: a vector with three components representing the emissive color
1701
+
* - `opacity`: a single number representing the opacity
1702
+
*
1703
+
* The callback should return a vector with four components (red, green, blue, alpha) for the final color.
* A callback function which receives color components (baseColor, diffuse, ambientColor, ambient, specularColor, specular, emissive, opacity) and returns a vec4 for the final color.
1712
+
* A callback function which receives the object described above and returns a vector with four components for the final color.
1702
1713
*
1703
1714
* @example
1704
1715
* <div modernizr='webgl'>
@@ -1709,20 +1720,19 @@ if (typeof p5 !== 'undefined') {
1709
1720
* myShader = baseMaterialShader().modify(() => {
1710
1721
* combineColors(components => {
1711
1722
* // Custom color combination: add a red tint
1712
-
* let r = components.baseColor.r * components.diffuse.r +
@@ -1742,13 +1752,24 @@ if (typeof p5 !== 'undefined') {
1742
1752
* @function getPointSize
1743
1753
* @experimental
1744
1754
* @description
1745
-
* Registers a callback to modify the size of points when rendering with a shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() or similar, when drawing points (e.g., with the point() function in WEBGL mode). The callback receives the current point size (number) and should return the new size (number).
1755
+
* Registers a callback to modify the size of points when rendering with a shader.
1756
+
*
1757
+
* This hook can be used inside the following shader modify functions:
0 commit comments