Skip to content

Commit 483edcb

Browse files
committed
Fix getPixelInputs description and getColor description
1 parent 58d8e5d commit 483edcb

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

src/webgl/ShaderGenerator.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,23 +1821,27 @@ if (typeof p5 !== 'undefined') {
18211821
/**
18221822
* @method getPixelInputs
18231823
* @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
18411845
*
18421846
* Return the modified object to update the fragment.
18431847
*
@@ -2001,15 +2005,14 @@ if (typeof p5 !== 'undefined') {
20012005
* @method getColor
20022006
* @description
20032007
* 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
20112014
*
2012-
* Return a four component vector `[r, g, b, a]` for the pixel.
2015+
* Return a four-component vector `[r, g, b, a]` for the pixel.
20132016
*
20142017
* This hook is available in:
20152018
* - <a href="#/p5/baseFilterShader">baseFilterShader()</a>

0 commit comments

Comments
 (0)