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
+28-25Lines changed: 28 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -1821,23 +1821,27 @@ if (typeof p5 !== 'undefined') {
1821
1821
/**
1822
1822
* @method getPixelInputs
1823
1823
* @description
1824
-
* Registers a callback to modify per-fragment inputs before the final color is computed in the fragment shader. The available properties differ by shader:
1825
-
* - For baseMaterialShader():
1826
-
* - `normal` (vec3): surface normal
1827
-
* - `texCoord` (vec2): texture coordinates
1828
-
* - `ambientLight` (vec3): ambient light color
1829
-
* - `ambientMaterial` (vec3): ambient material color
1830
-
* - `specularMaterial` (vec3): specular material color
1831
-
* - `emissiveMaterial` (vec3): emissive material color
1832
-
* - `color` (vec4): base color (unpremultiplied)
1833
-
* - `shininess` (float)
1834
-
* - `metalness` (float)
1835
-
* - For baseStrokeShader():
1836
-
* - `color` (vec4): base color
1837
-
* - `tangent` (vec2): tangent direction
1838
-
* - `center` (vec2): stroke center for the current fragment
1839
-
* - `position` (vec2): fragment position in stroke space
1840
-
* - `strokeWeight` (float)
1824
+
* 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 adjust per-pixel data before lighting/mixing.
1825
+
*
1826
+
* The callback receives an `Inputs` object. Available fields depend on the shader:
1827
+
*
1828
+
* - In <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>:
1829
+
* - `normal`: a vector with three components representing the surface normal
1830
+
* - `texCoord`: a vector with two components representing the texture coordinates (u, v)
1831
+
* - `ambientLight`: a vector with three components representing the ambient light color
1832
+
* - `ambientMaterial`: a vector with three components representing the material's ambient color
1833
+
* - `specularMaterial`: a vector with three components representing the material's specular color
1834
+
* - `emissiveMaterial`: a vector with three components representing the material's emissive color
1835
+
* - `color`: a vector with four components representing the base color (red, green, blue, alpha)
1836
+
* - `shininess`: a number controlling specular highlights
1837
+
* - `metalness`: a number controlling the metalness factor
1838
+
*
1839
+
* - In <a href="#/p5/baseStrokeShader">baseStrokeShader()</a>:
1840
+
* - `color`: a vector with four components representing the stroke color (red, green, blue, alpha)
1841
+
* - `tangent`: a vector with two components representing the stroke tangent
1842
+
* - `center`: a vector with two components representing the cap/join center
1843
+
* - `position`: a vector with two components representing the current fragment position
1844
+
* - `strokeWeight`: a number representing the stroke weight in pixels
1841
1845
*
1842
1846
* Return the modified object to update the fragment.
1843
1847
*
@@ -2001,15 +2005,14 @@ if (typeof p5 !== 'undefined') {
2001
2005
* @method getColor
2002
2006
* @description
2003
2007
* 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:
2004
-
* - `inputs`: an object with the following properties:
2005
-
* - `texCoord`: a vec2 representing the texture coordinates of the pixel
2006
-
* - `canvasSize`: a vec2 representing the size of the canvas in pixels
2007
-
* - `texelSize`: a vec2 representing the size of a single texel (pixel) in texture space
2008
-
* - `color`: a vec4 representing the color of the pixel before the filter is applied
2009
-
* - (other properties may be available depending on the shader)
2010
-
* - `canvasContent`: a sampler2D texture with the sketch's contents before the filter is applied
2008
+
* - `inputs`: an object with the following properties:
2009
+
* - `texCoord`: a vector with two components representing the texture coordinates (u, v)
2010
+
* - `canvasSize`: a vector with two components representing the canvas size in pixels (width, height)
2011
+
* - `texelSize`: a vector with two components representing the size of a single texel in texture space
2012
+
* - `color`: a vector with four components representing the current pixel color (red, green, blue, alpha)
2013
+
* - `canvasContent`: a texture containing the sketch's contents before the filter is applied
2011
2014
*
2012
-
* Return a fourcomponent vector `[r, g, b, a]` for the pixel.
2015
+
* Return a four-component vector `[r, g, b, a]` for the pixel.
0 commit comments