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
* Registers a callback to modify the world-space properties of each vertex in a shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to customize vertex positions, normals, texture coordinates, and colors before rendering. "World space" refers to the coordinate system of the 3D scene, before any camera or projection transformations are applied.
1649
1649
*
@@ -1666,7 +1666,8 @@ if (typeof p5 !== 'undefined') {
1666
1666
* getWorldInputs(inputs => {
1667
1667
* // Move the vertex up and down in a wave in world space
1668
1668
* // In world space, moving the object (e.g., with translate()) will affect these coordinates
@@ -1684,7 +1685,7 @@ if (typeof p5 !== 'undefined') {
1684
1685
*/
1685
1686
1686
1687
/**
1687
-
* @function combineColors
1688
+
* @method combineColors
1688
1689
* @description
1689
1690
* 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:
1690
1691
*
@@ -1743,7 +1744,8 @@ if (typeof p5 !== 'undefined') {
1743
1744
*/
1744
1745
1745
1746
/**
1746
-
* @function beforeVertex
1747
+
* @method beforeVertex
1748
+
* @private
1747
1749
* @description
1748
1750
* Registers a callback to run custom code at the very start of the vertex shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to set up variables or perform calculations that affect every vertex before processing begins. The callback receives no arguments.
1749
1751
*
@@ -1760,7 +1762,8 @@ if (typeof p5 !== 'undefined') {
1760
1762
*/
1761
1763
1762
1764
/**
1763
-
* @function afterVertex
1765
+
* @method afterVertex
1766
+
* @private
1764
1767
* @description
1765
1768
* Registers a callback to run custom code at the very end of the vertex shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to perform cleanup or final calculations after all vertex processing is done. The callback receives no arguments.
1766
1769
*
@@ -1777,7 +1780,8 @@ if (typeof p5 !== 'undefined') {
1777
1780
*/
1778
1781
1779
1782
/**
1780
-
* @function beforeFragment
1783
+
* @method beforeFragment
1784
+
* @private
1781
1785
* @description
1782
1786
* Registers a callback to run custom code at the very start of the fragment shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to set up variables or perform calculations that affect every pixel before color calculations begin. The callback receives no arguments.
1783
1787
*
@@ -1803,7 +1807,7 @@ if (typeof p5 !== 'undefined') {
1803
1807
* });
1804
1808
* getFinalColor(color => {
1805
1809
* // Use the value set in beforeFragment to tint the color
1806
-
* color[0] *= this.brightness; // Tint red channel
1810
+
* color.r *= this.brightness; // Tint red channel
1807
1811
* return color;
1808
1812
* });
1809
1813
* });
@@ -1820,7 +1824,7 @@ if (typeof p5 !== 'undefined') {
1820
1824
*/
1821
1825
1822
1826
/**
1823
-
* @function getPixelInputs
1827
+
* @method getPixelInputs
1824
1828
* @description
1825
1829
* Registers a callback to modify the properties of each fragment (pixel) before the final color is calculated in the fragment shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to change opacity or other per-pixel properties. The callback receives an object with the following properties:
1826
1830
* - `opacity`: a number between 0 and 1 for the pixel's transparency
@@ -1844,7 +1848,8 @@ if (typeof p5 !== 'undefined') {
@@ -1862,7 +1867,7 @@ if (typeof p5 !== 'undefined') {
1862
1867
*/
1863
1868
1864
1869
/**
1865
-
* @function shouldDiscard
1870
+
* @method shouldDiscard
1866
1871
* @description
1867
1872
* Registers a callback to decide whether to discard (skip drawing) a fragment (pixel) in the fragment shader. This hook can be used inside <a href="#/p5/baseStrokeShader">baseStrokeShader()</a>.modify() and similar shader modify calls to create effects like round points or custom masking. The callback receives a boolean:
1868
1873
* - `willDiscard`: true if the fragment would be discarded by default
@@ -1899,7 +1904,7 @@ if (typeof p5 !== 'undefined') {
1899
1904
*/
1900
1905
1901
1906
/**
1902
-
* @function getFinalColor
1907
+
* @method getFinalColor
1903
1908
* @description
1904
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
1910
* - `[r, g, b, a]`: the current color (red, green, blue, alpha)
@@ -1924,8 +1929,8 @@ if (typeof p5 !== 'undefined') {
1924
1929
* myShader = baseColorShader().modify(() => {
1925
1930
* getFinalColor(color => {
1926
1931
* // Make the output color fully opaque and add a green tint
1927
-
* color[3] = 1.0;
1928
-
* color[1] += 0.2;
1932
+
* color.a = 1;
1933
+
* color.g += 0.2;
1929
1934
* return color;
1930
1935
* });
1931
1936
* });
@@ -1942,7 +1947,8 @@ if (typeof p5 !== 'undefined') {
1942
1947
*/
1943
1948
1944
1949
/**
1945
-
* @function afterFragment
1950
+
* @method afterFragment
1951
+
* @private
1946
1952
* @description
1947
1953
* Registers a callback to run custom code at the very end of the fragment shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to perform cleanup or final per-pixel effects after all color calculations are done. The callback receives no arguments.
1948
1954
*
@@ -1964,7 +1970,7 @@ if (typeof p5 !== 'undefined') {
1964
1970
* myShader = baseColorShader().modify(() => {
1965
1971
* getFinalColor(color => {
1966
1972
* // Add a purple tint to the color
1967
-
* color[2] += 0.2;
1973
+
* color.b += 0.2;
1968
1974
* return color;
1969
1975
* });
1970
1976
* afterFragment(() => {
@@ -1985,7 +1991,7 @@ if (typeof p5 !== 'undefined') {
1985
1991
*/
1986
1992
1987
1993
/**
1988
-
* @function getColor
1994
+
* @method getColor
1989
1995
* @description
1990
1996
* 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:
1991
1997
* - `inputs`: an object with properties like `texCoord`, `canvasSize`, `texelSize`, etc.
@@ -2017,15 +2023,15 @@ if (typeof p5 !== 'undefined') {
2017
2023
* background(180);
2018
2024
* // Draw something to the canvas
2019
2025
* fill('yellow');
2020
-
* ellipse(0, 0, 150, 150);
2026
+
* circle(0, 0, 150);
2021
2027
* filter(myShader);
2022
2028
* }
2023
2029
* </code>
2024
2030
* </div>
2025
2031
*/
2026
2032
2027
2033
/**
2028
-
* @function getObjectInputs
2034
+
* @method getObjectInputs
2029
2035
* @description
2030
2036
* Registers a callback to modify the properties of each vertex before any transformations are applied in the vertex shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to move, color, or otherwise modify the raw model data. The callback receives an object with the following properties:
2031
2037
* - `position`: a vector with three components representing the original position of the vertex
@@ -2053,7 +2059,8 @@ if (typeof p5 !== 'undefined') {
2053
2059
* myShader = baseColorShader().modify(() => {
2054
2060
* getObjectInputs(inputs => {
2055
2061
* // Create a sine wave along the x axis in object space
@@ -2070,7 +2077,7 @@ if (typeof p5 !== 'undefined') {
2070
2077
*/
2071
2078
2072
2079
/**
2073
-
* @function getCameraInputs
2080
+
* @method getCameraInputs
2074
2081
* @description
2075
2082
* Registers a callback to adjust vertex properties after the model has been transformed by the camera, but before projection, in the vertex shader. This hook can be used inside <a href="#/p5/baseColorShader">baseColorShader()</a>.modify() and similar shader modify calls to create effects that depend on the camera's view. The callback receives an object with the following properties:
2076
2083
* - `position`: a vector with three components representing the position after camera transformation
@@ -2098,9 +2105,10 @@ if (typeof p5 !== 'undefined') {
2098
2105
* myShader = baseColorShader().modify(() => {
2099
2106
* getCameraInputs(inputs => {
2100
2107
* // Move vertices in camera space based on their x position
0 commit comments