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
* // Discard fragments based only on the default logic
1889
+
* return willDiscard;
1894
1890
* });
1895
1891
* }
1896
1892
* function draw() {
@@ -1906,7 +1902,7 @@ if (typeof p5 !== 'undefined') {
1906
1902
/**
1907
1903
* @method getFinalColor
1908
1904
* @description
1909
-
* Registers a callback to change the final color of each pixel after all lighting and mixing is done in the fragment shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to adjust the color before it appears on the screen. The callback receives a color array:
1905
+
* Registers a callback to change the final color of each pixel after all lighting and mixing is done in the fragment shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to adjust the color before it appears on the screen. The callback receives a four component vector representing red, green, blue, and alpha:
1910
1906
* - `[r, g, b, a]`: the current color (red, green, blue, alpha)
1911
1907
*
1912
1908
* Return a new color array to change the output color.
@@ -1929,8 +1925,8 @@ if (typeof p5 !== 'undefined') {
1929
1925
* myShader = baseColorShader().modify(() => {
1930
1926
* getFinalColor(color => {
1931
1927
* // Make the output color fully opaque and add a green tint
1932
-
* color.a = 1;
1933
-
* color.g += 0.2;
1928
+
* // Add a blue tint to the output color
1929
+
* color.b += 0.2;
1934
1930
* return color;
1935
1931
* });
1936
1932
* });
@@ -1994,10 +1990,15 @@ if (typeof p5 !== 'undefined') {
1994
1990
* @method getColor
1995
1991
* @description
1996
1992
* Registers a callback to set the final color for each pixel in a filter shader. This hook can be used inside <a href="#/p5/baseFilterShader">baseFilterShader()</a>.modify() and similar shader modify calls to control the output color for each pixel. The callback receives the following arguments:
1997
-
* - `inputs`: an object with properties like `texCoord`, `canvasSize`, `texelSize`, etc.
1993
+
* - `inputs`: an object with the following properties:
1994
+
* - `texCoord`: a vec2 representing the texture coordinates of the pixel
1995
+
* - `canvasSize`: a vec2 representing the size of the canvas in pixels
1996
+
* - `texelSize`: a vec2 representing the size of a single texel (pixel) in texture space
1997
+
* - `color`: a vec4 representing the color of the pixel before the filter is applied
1998
+
* - (other properties may be available depending on the shader)
1998
1999
* - `canvasContent`: a sampler2D texture with the sketch's contents before the filter is applied
1999
2000
*
2000
-
* Return a color array `[r, g, b, a]` for the pixel.
2001
+
* Return a four component vector `[r, g, b, a]` for the pixel.
0 commit comments